I'm new to Pyspark and asking question for best design pattern/practice:
I'm developing a library that should run both, on local machine and on Databricks.
Currently working on loading secrets. If code runs on databricks, I should load secrets using dbutils.secrets.get while if code runs on local machine, dotenv.load_dotenv.
Question:
How can I create/refer to dbutils variable (which is readily provided in databricks instance)? pyspark doesnt have such module... even if I import SparkSession I still need DBUtils which is not found on pyspark local installation.
my current solution: if identify that code runs on Databricks, I create dbutils with:
dbutils = globals()['dbutils']