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 are ideal for building Flows and testing changes to the codebase. Flows are typically created in these environments for client demonstrations and User Acceptance Testing (UAT). Once UAT is approved, the flows are migrated to the production environment.

To determine if you are in a production environment, use the following code:

from ganymede_sdk import lib

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

Additional Methods to Detect Environment State

Detecting Cron Flows

To check if the current flow is a cron flow, use:

from ganymede_sdk import lib

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

Identifying Notebooks

To determine if you are in an editor notebook or an analysis notebook, use the following:

For editor notebooks (that are part of a Flow):

from ganymede_sdk import lib

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

For analysis notebooks:

from ganymede_sdk import lib

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

For Agent notebooks:

from ganymede_sdk import lib

if lib._is_agent_notebook_():
print("This is an Agent notebook")
else:
print("This is not an Agent notebook")

Checking Containers

To check if the code is running in a container, use:

from ganymede_sdk import lib

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

Detecting Agent Execution

To verify if the code is being executed by an agent, use:

from ganymede_sdk import lib

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

Detecting Airflow Pipeline Execution

To check if the flow is running in Airflow, use:

from ganymede_sdk import lib

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