Skip to main content
Version: 0.6

tecton.get_current_workspace

Returns the current tecton.Workspace set by environment variable, Tecton config file, or tecton workspace select command.

Parameters​

None

Note​

When defining Tecton Objects, it can be helpful to configure conditional logic based on the Workspace applied to. For example, you may want to use On Demand instances for materialization jobs in your production workspaces to improve job reliability, and Spot instances in your staging environment to reduce costs.

The get_current_workspace() method provides a convenient way to implement this conditional logic.

# use prod warehouse only in the prod environment
warehouse = "prod" if get_current_workspace() == "prod" else "dev"
datasource = BatchDataSource(
name="mytable", batch_config=SnowflakeConfig(warehouse=warehouse, table="mytable", timestamp_field="timestamp")
)

# save costs by materializing farther back only in the prod environment
start_time = datetime(2020, 1, 1) if get_current_workspace() == "prod" else datetime(2023, 1, 1)


@batch_feature_view(
sources=[FilteredSource(datasource)],
entities=[customer],
mode="spark_sql",
online=True,
feature_start_time=start_time,
batch_schedule=timedelta(days=1),
ttl=timedelta(days=3650),
)
def my_fv(source):
...

Was this page helpful?

🧠 Hi! Ask me anything about Tecton!

Floating button icon