Skip to content

How do I compute the cold start of a scheduled job? #20777

Answered by jamiedemaria
rob-apella asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @rob-apella when a job is scheduled, we apply a tag with the scheduled execution time. Between that and the RUN_START event you should have all the info you need! From the run_id you can get a DagsterRun object that contains the tags

something like

@op 
def compute_time_diff(context):
    scheduled_time = context.instance.get_run_by_id(run_id).tags.get(".dagster/scheduled_execution_time")
    run_start_time = datetime.datetime.fromtimestamp(
        context.instance.get_run_record_by_id(run_id).start_time
    ).astimezone(datetime.timezone.utc)
    context.log.info(f"SCHEDULED TIME: {scheduled_time}")
    context.log.info(f"START TIME: {run_start_time}")

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rob-apella
Comment options

@rob-apella
Comment options

@jamiedemaria
Comment options

Answer selected by rob-apella
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: schedule Related to schedules
2 participants