Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically convert non-flows into flows #17024

Merged
merged 12 commits into from
Feb 10, 2025
Merged

Conversation

jakekaplan
Copy link
Contributor

@jakekaplan jakekaplan commented Feb 6, 2025

This PR updates load_flow_from_entrypoint to automatically wrap any Python function in a Flow object if it is not already, removing the requirement that a user explicitly decorate their function with @flow if they want to deploy it. By doing so, we lower the barrier for using Prefect to remotely deploy and run code—allowing quick adoption without forcing users to modify existing codebases as existing scripts become immediately deployable/schedulable.

As far I can tell there is no technical reason why we can't do this and I think it is a very big value add. I would be happy only include this functionality behind an experimental flag if that is preferred.

Copy link

codspeed-hq bot commented Feb 6, 2025

CodSpeed Performance Report

Merging #17024 will not alter performance

Comparing all-flow-everything (c266704) with main (332413a)

Summary

✅ 2 untouched benchmarks

@jakekaplan jakekaplan changed the title test Automatically convert non-flows into flows Feb 6, 2025
@desertaxle
Copy link
Member

My initial reaction is that this is cool and should be its own utility. That way we can keep the behavior of the current utility consistent and sidestep any edge cases that might arise if we get a ScriptError while loading a function that isn't already decorated with @flow.

@jakekaplan
Copy link
Contributor Author

jakekaplan commented Feb 7, 2025

My initial reaction is that this is cool and should be its own utility. That way we can keep the behavior of the current utility consistent and sidestep any edge cases that might arise if we get a ScriptError while loading a function that isn't already decorated with @flow.

That sounds good to me! I made a tweak here (still need to fix tests). Is this what you had in mind? Or is there a different way/different place you'd recommend?

@jakekaplan jakekaplan marked this pull request as ready for review February 7, 2025 22:17
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

src/prefect/flows.py Outdated Show resolved Hide resolved
tests/test_flows.py Show resolved Hide resolved
@jakekaplan jakekaplan merged commit 6d04927 into main Feb 10, 2025
47 checks passed
@jakekaplan jakekaplan deleted the all-flow-everything branch February 10, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants