<@ULVA73B9P> please tell me about `submit_to_run...
# ask-marvin
o
@Marvin please tell me about
submit_to_runner
function
m
The
submit_to_runner
function doesn't seem to be explicitly documented, but from the context provided around task runners in Prefect, it likely relates to the mechanism of submitting tasks for execution within the framework. In both Prefect 2.x and 3.x versions, task runners play a crucial role in managing how tasks are executed: - Using the
.submit()
method on a task function allows you to submit the task to a task runner. This is not the
submit_to_runner
function per se, but it serves a similar purpose by sending tasks to be managed by the task runner. Prefect's task runners can execute tasks concurrently or in parallel, using tools like Dask or Ray for distributed execution. - When a task is submitted this way, it returns a
PrefectFuture
. This object contains both the data returned by the task and the state of the task run. These task runners can significantly help in optimizing how tasks are executed, especially in more complex workflows. Here's some reading that should clarify this further: - Prefect 2.x Task Runners - Prefect 3.x Task Runners Also, there was a mention of a GitHub pull request that added handling logic for a
submit_to_runner
with an environment variable related to blocking failover, indicating advanced configurations or failsafe implementations. You can catch some more technical details in this GitHub pull request. I hope this helps you get a grip on the functionalities involving task submissions in Prefect. Now, wouldn't it be nice if life had a submit-to-runner button? "Here, please process my laundry and existential dread in parallel. Thanks!"
o
@Marvin Okay, in my recognition this function enable parallel execution of subflow by this PR https://github.com/PrefectHQ/prefect/pull/11476 but, this is not documented officialy. correct?
m
Yes, you are correct! The
submit_to_runner
function allowing for parallel execution of subflows was introduced in the GitHub pull request you mentioned (#11476), but it seems that this specific functionality isn't explicitly documented in the Prefect official documentation for either version 2.x or 3.x. Sometimes, new features are merged into the codebase before the documentation is fully updated. It's always a good idea to keep an eye on the official release notes and GitHub repository for the most up-to-date information on new features and changes. It's like having a secret tool in your utility belt that only the observant adventurers know about! 😄 If you want to stay updated on such features, the Prefect GitHub and their community discussions are great places to look!
o
@Marvin Thanks. And also I have a problem about this function. When I cancel parent flow from Prefect UI (self-hosted), subflow was not canceld. This issue is not reported in GitHub project?
m
It seems that there aren't any reported issues on GitHub about subflows not being canceled when the parent flow is canceled using
submit_to_runner
. This might mean the problem is either very recent, underreported, or possibly specific to your setup. I would suggest a couple of steps: 1. Ensure you've updated to the latest version of Prefect, as the issue might have been addressed in recent updates. 2. Check your configuration and logs to identify if there's any setup specific reason causing this behavior. 3. If the issue persists, consider reporting it on GitHub's Prefect repository, providing as much detail as possible. This helps the developers to address the issue in future updates. It's always a tad annoying to be the early discoverer of a bug, but you also become a pioneer, helping to improve the software for everyone else! If you decide to report it, the community usually appreciates the heads up. 🍀
o
thanks
n
hi @orangekame3 - i would recommend checking out background tasks if you’re looking at submit_to_runner. that utility may be removed in the future and background tasks are essentially a better version of the same thing (if you squint, since tasks are free to call flows)
o
@Nate thanks! background task is this? I"ll check it https://www.prefect.io/blog/background-tasks-why-they-matter-in-prefect
My motivation is the parallel execution of multiple subflows and the structuring of the execution. In this respect, submit_to_runner has been very satisfying. I was very satisfied with submit_to_runner in this respect, because if I call a flow that has already been deployed, I cannot control it from the parent flow. Also, the parallel execution of tasks did not meet my demand. I wanted to define tasks in parallel execution. Maybe bakground task does not meet my demand, but it is a very interesting feature. it would be nice to have a parallel execution like submit_to_runner with full control over the flow... The attached is the current parallel execution of flow. I really like the way the tasks are structured!
n
hi @orangekame3 - thank you for the the feedback! this is something we’re still thinking about, i.e “what should flow.submit look like?” would you be open to codifying your thoughts in a discussion so that it could be a springboard for more thinking on design?
o
Thanks @Nate I consider about it.