is there any way for a task to know that its flow has been triggered by a Schedule vs. the API? Something in the context perhaps?
👀 1
n
nicholas
10/05/2021, 6:41 PM
Hi @Kevin Weiler - flow runs scheduled by the Prefect Scheduler will have an
auto_scheduled
flag on the flow run object; when this is true, you know that it was an automatically generated run, otherwise it was created through the API or the UI. Runs created through the API will also have a
created_by
sub object if you’re running in Cloud, which will give you the id of the user that created the run through the UI/API
upvote 1
🙏 1
k
Kevin Weiler
10/05/2021, 7:55 PM
@nicholas - how do I access the flow_run object from inside a task? (let’s say an
@task
decorated function)
n
nicholas
10/05/2021, 8:04 PM
I think your best bet there is to grab the flow_run_id from context and make a query with the graphql client something like this:
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.