get_current_workspace
tecton workspace select
command.
When running tecton plan
or tecton apply
Tecton uses the workspace returned by this method.Returns
Optional
[str
]
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 Realtime 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=[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):
...