https://dagster.io/ logo
#ask-ai
Title
# ask-ai
d

Deividas Jodogalvis

02/06/2024, 2:51 PM
get code location of a job
s

Scout

02/06/2024, 2:51 PM
To get the code location of a job in Dagster, you can extract information from the asset context within your asset definition. Here's an example provided in the discussions:
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 pattern can be used within an asset definition to programmatically access the code location of the job that the asset is a part of. Keep in mind that this code snippet is meant to be used within the context of an asset definition, and the context object provides access to the execution context from which you can navigate to the code location information.
12 Views