Skip to main content

Environment Detection

Prod vs Dev

Dev or test environments are used for general testing and exploratory analysis of datasets. These environments can be used for developing operators, flows, or testing changes to the codebase. Flows are to be built in these environments for client demos and User Acceptance Testing (UAT). Once UAT is signed off, the flows are migrated to production.

To test if an environment is production, the following code may be used.

from ganymede_sdk import lib

if lib._is_prod_env():
print("This is a production environment")
else:
print("This is not a production environment")

Other useful methods to detect state

Cron flows

Cron flows can be checked by

from ganymede_sdk import lib

if lib._is_cron_flow():
print("This is a cron flow")
else:
print("This is not a cron flow")

Notebooks

Check whether or not you are in an editor notebook or an analysis notebook

from ganymede_sdk import lib

if lib._is_editor_notebook():
print("This is an editor notebook")
else:
print("This is not an editor notebook")
from ganymede_sdk import lib

if lib._is_notebook():
print("This is an analysis notebook")
else:
print("This is not an analysis notebook")

Containers

Containers can be checked by

from ganymede_sdk import lib

if lib._is_container():
print("This is a container")
else:
print("This is not a container")

Agent

Check if the code is run in an agent

from ganymede_sdk import lib

if lib._is_agent():
print("This is agent code")
else:
print("This is not agent code")

Airflow

Airflow can be checked by

from ganymede_sdk import lib

if lib._is_airflow():
print("Flow is running in airflow")
else:
print("Flow is not running in airflow")