Mehdi
11/19/2024, 4:02 PMbuild_from_flow(flow=MyClass.my_first_flow)
but when running the follow it will attempt to run my_first_flow without going through the classMarvin
11/19/2024, 4:03 PMbuild_from_flow
from a class method. While I couldn't retrieve the exact documentation details right now, an issue was found related to the creation of deployments through Python. It seems there is some functionality not automatically invoked, like creating certain files or configurations.
However, from your description, it sounds like the method invocation doesn't go through the expected class hierarchy. In Python, invoking a class method directly can sometimes bypass the class context if not handled correctly.
Here's a general suggestion you might try:
Ensure that MyClass.my_first_flow
is a static method or a class method if you’re trying to avoid direct instantiation. You might need to ensure that the flow is properly instantiated and called within the class. For example:
python
from prefect import Flow
from prefect.deployments import Deployment
class MyClass:
@staticmethod
def my_first_flow():
with Flow("example") as flow:
# Your tasks and logic here
pass
return flow
flow_instance = MyClass.my_first_flow()
deployment = Deployment.build_from_flow(flow=flow_instance)
deployment.apply()
Given the peculiarities of Prefect, make sure that the flow is returned correctly and that any context decorators in use are properly applied. You may also need to investigate more specific issues in GitHub or Prefect forums if there’s a version-specific bug or behavior.
If this doesn't help, I recommend exploring Prefect's GitHub issues further or asking on their forum where more version-specific solutions might exist. If only this search tool of mine wasn’t feeling particularly stubborn today!Nate
11/19/2024, 4:06 PMwhen running the follow it will attempt to run my_first_flow without going through the classwhat do you mean "going through the class"?
Mehdi
11/19/2024, 4:10 PMMehdi
11/19/2024, 4:10 PMMehdi
11/19/2024, 4:12 PMraise MissingFlowError(
prefect.exceptions.MissingFlowError: Flow function with name 'my_first_flow' not found in 'path/to/class/myclass_file.py'.
Mehdi
11/19/2024, 4:13 PMbuild_from_flow(flow=<http://MyClass.my|MyClass.my>_first_flow)
Mehdi
11/19/2024, 4:14 PMMehdi
11/19/2024, 4:14 PM