Hey all! We're trying to run a job every 30 second...
# ask-community
s
Hey all! We're trying to run a job every 30 seconds using a schedule, but we aren't sure if there's a good way to do this, since schedule only supports running every minute using cron. I thought about using time.sleep(30) in between two copies of the run request but that doesn't seem to be working. Any ideas would be much appreciated!
t
Have you thought about using a sensor to yield the run requests?
s
Is there a practical difference? We're just trying to trigger a run every 30 seconds external to any change
And how do we specify it to run every 30 seconds, or does it automatically do that?
t
Sensors can be evaluated in sub-minute intervals. ex. 30 seconds. https://docs.dagster.io/concepts/partitions-schedules-sensors/sensors#evaluation-interval
s
Gotcha. Thanks!
How do I prevent the sensor from skipping and have it run 30 seconds regardless? It says it skipped because the run already exists for the requested key. The schedule version of this runs fine and is the exact same logic
t
You can create another run key that's a random value (ex. a hash of the current epoch) per run
s
Fantastic, thanks! I also see here that if you pass in a run key of None it will run regardless: https://docs.dagster.io/_apidocs/schedules-sensors