Skip to content

How to get job metadata and run stats #8417

Answered by yuhan
dagsir[bot] bot asked this question in Q&A
Discussion options

You must be logged in to vote

In a sensor or other places where the context arg is available, you can get run stats (timestamp, etc) from Dagster Instance by passing in a run_id:

@sensor(job=my_job)
def my_sensor(context):
    run_stats = instance.get_run_stats(my_run_id) # run_stats.start_time, run_stats.end_time, ...

If you'd also want to get these info outside a sensor, you can do:

from dagster import DagsterInstance

instance = DagsterInstance.get()
run_stats = instance.get_run_stats(my_run_id)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yuhan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant