https://prefect.io logo
g

Giacomo Chiarella

07/17/2023, 12:50 PM
Is it possible to start a task of a flow run, getting the flow run via get_client().read_flow_runs()?
d

Deceivious

07/17/2023, 12:55 PM
What agent are you assuming to run the flow on?
g

Giacomo Chiarella

07/17/2023, 12:56 PM
I start the agent running
prefect agent start --pool
it runs on ec2 instance
d

Deceivious

07/17/2023, 12:56 PM
theres a method
create_flow
under client
but thats not it
create_flow_run
g

Giacomo Chiarella

07/17/2023, 12:57 PM
mmm that is the point, I don’t want to create another flow, I would like to run a task (like an inactive task) on the same flow run
so the flow is A->B->C->D and there is an E task which does nothing. When the associated deployment runs, creating a flow run, let’s call it Y, and it executes A->B->C->D. If this flow run is still executing during the execution of another flow run from a different deployment (let’s call it Z), I would like to run the task E of the flow run Y from the flow run Z
and the flow run Z will run independently from Y
I cannot say in Y to start Z when it finishes
d

Deceivious

07/17/2023, 1:05 PM
y not make E run all the time, and E can check for the state of flow runs in deployment Y using the api and do its thing?
g

Giacomo Chiarella

07/17/2023, 1:37 PM
it may work, but maybe there is a better way. I’ve just found create_task_run on the client which should be able to attach a task run to a flow run. That would be interesting because, if this works, you do not have to add the task to every flow code, instead Z would attach it
something to test
d

Deceivious

07/17/2023, 1:37 PM
give it a try
g

Giacomo Chiarella

07/17/2023, 1:38 PM
I will try it when I have some time ahahah 🫣
for now I opted for a semi-automatic solution