get instance current CodeLocation
# ask-ai
d
get instance current CodeLocation
s
To get the current code location of an instance, you can extract it from the asset context within a Dagster asset definition. Here's an example provided in the documentation:
Copy code
python @asset def my_asset(context: AssetExecutionContext):   location_name = (context.get_step_execution_context()     .dagster_run.external_job_origin.external_repository_origin     .code_location_origin.location_name)
In this example,
location_name
will contain the name of the code location associated with the asset. This is useful when you need to programmatically access the code location information from within your Dagster assets.