Search code examples
pythonpython-2.7python-3.xdsxdata-science-experience

Programmatically determine if running in DSX


How can I programmatically determine if the python code in my notebook is running under DSX?

I'd like to be able to do different things under a local Jupyter notebook vs. DSX.


Solution

  • While the method presented in another answer (look for specific environment variables) works today, it may stop working in the future. This is not an official API that DSX exposes. It will obviously also not work if somebody decides to set these environment variables on their non-DSX system.

    My take on this is that "No, there is no way to reliably determine whether the notebook is running on DSX".

    In general, (in my opinion) notebooks are not really designed as artifacts that you can arbitrarily deploy anywhere; there will always need to be someone wearing the "application developer" hat and transform them - how to do that, you could put into a markdown cell inside the notebook.