Skip to content

How to: execute daily-partitioned job after a file arrives or other external condition is met #7267

Answered by sryza
sryza asked this question in Q&A
Discussion options

You must be logged in to vote

Here's an implementation of a sensor that checks for some external condition to be true (like a file arriving in a filesystem) for a particular date.

Note that, if a file never arrives for a particular date, this sensor won't move past that date. This is desirable for some applications, but undesirable for other applications. It's also possible to write the sensor in a way that it will move past dates.

from dagster import (
    sensor,
    asset,
    SkipReason,
    repository,
    JobDefinition,
)
from datetime import datetime, timedelta


DATE_FORMAT = "%Y-%m-%d"
START_DATE = "2022-03-01"


def file_exists_for_date(date: str) -> bool:
    return ...


partitioned_job = ...
assets = ...
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sryza
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