Search code examples
python-3.xazure-databricks

Python command to identify if a node is a databricks node or general node


I have a requirement to develop a python application which can run on a normal machine like windows, linux or databricks. My requirement is to allow python application to dynamically identify where the script is actually running. If my python code is running on Windows, it should know that the code is running on windows. Like wise for Linux. I use Platform.system() to get the information. But databricks will also have a OS platform. How can it differenciate a databricks node from a normal Linux/Unix node? Apart from using dbutils or sparksession, will we be able to run a command and know that the node on which the command has run was indeed a databricks node? I don't think that the databricks cli is installed on databricks cluster. so I haven't got any command to find out if the platform is Linux/Windows/Databricks.

Note:The application will be deployed on Windows/Linux/Databricks as a wheel file. So the requirement is that the application should identify, on which node the code is running. If it is running on windows/unix, it has to access the local file system and create some files on local file system. If it is running on databricks, it should access the mount point pointing to Azure ADLS and create/access files on/from ADLS.


Solution

  • The simplest check that you can do is to check presence of the /databricks folder on the driver node. Additional checks could be done by checking for /databricks/jars director,, /databricks/DBR_VERSION file, etc.