https://prefect.io logo
Title
h

Hannah Amundson

08/14/2020, 10:13 PM
Hi! I need a specific task to run if a previous task was completed + it is a certain day of the week. Is there a way to use the schedule component for filters?
👀 2
n

nicholas

08/14/2020, 10:45 PM
Hi @Hannah Amundson - yes! If for example, this should be run only on a weekday, you could do this to implement the skip logic in your task:
from prefect.engine import signals

@task
def my_task():
  is_weekday = datetime.datetime.today().weekday() < 6
  if not is_weekday:
    raise signals.SKIP(message="Wrong day of the week!")

  # do task stuff here
👍 1
And then whichever task should be completed for this to run you could set as an upstream dependency in your flow context.