You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use a custom flow decorator to automatically adjust flow names, descriptions, and versions, and deploy using a prefect.yaml. We found this method very helpful for standardizing how we name flows and ensures our repo URL's are added to every flow description. Our custom decorator no longer works starting with Prefect 2.19.
Digging into the prefect code base, it looks like the load_flow_argument_from_entrypoint function introduced in prefect 2.19 breaks a behavior we were relying on. This function load_flow_argument_from_entrypoint does not properly extract attributes that are manipulated by our custom flow decorator.
We use our customflow decorator just like prefect.flow:
where internal_package defines the flow decorator as:
importprefect.flowsfromprefect.flowsimportFlowfromprefectimporttask, get_run_loggerimportosfromfunctoolsimportwraps, partialimportinspectproject_name=os.environ["PROJECT_NAME"]
git_url=os.environ["GIT_URL"]
@taskdefinit_task():
logger=get_run_logger()
logger.info("this task always runs at the start of every flow")
defget_git_hash_version():
return'abc'defannotate_flow(flow: Flow):
""" - Prepend the project name to the flow name - Add the git url to the flow description - Set the flow version to the git hash """ifnotisinstance(flow, Flow):
raiseTypeError("flow must be a prefect Flow")
ifproject_nameisnotNone:
# Prepend the project name to the flow name.pfx=f'{project_name}: 'ifnotflow.name.startswith(pfx):
flow.name=pfx+flow.nameifgit_urlisnotNone:
description_suffix=f"\nGit Repo: {git_url}"description= (flow.descriptionor"")
ifdescription_suffixnotindescription:
flow.description=description+description_suffix# Set the version to the Git Hash.git_hash=get_git_hash_version()
ifgit_hash:
flow.version=f'git:{git_hash}'returnflowdefflow(fn=None, **kwargs):
""" A substitute for prefect's @flow decorator which: - Calls ecs_container_info() as the first task. - Annotates the flow with `annotate_flow` Any keyword arguments are passed to prefect.flows.Flow """iffnisNone:
returnpartial(flow, **kwargs)
@wraps(fn)defwrapped_flow(*args, **kwargs):
# Call the init_task as the first task in the flow.init_task()
returnfn(*args, **kwargs)
wrapped_flow.__signature__=inspect.signature(fn)
# Create a flow with the provided functionmy_flow=Flow(wrapped_flow, **kwargs)
my_flow=annotate_flow(my_flow)
returnmy_flow
Version info (prefect version output)
Version: 2.19.4
API version: 0.8.4
Python version: 3.11.6
Git commit: 867543a8
Built: Tue, Jun 4, 2024 3:14 PM
OS/Arch: darwin/arm64
Profile: test
Server type: cloud
Additional context
No response
The text was updated successfully, but these errors were encountered:
Hey @LeeMendelowitz! I'm pretty sure this bug was fixed in #14782 which was released in 2.20.0. Could you try upgrading to 2.20.0 and see if the issue persists?
Bug summary
We use a custom flow decorator to automatically adjust flow names, descriptions, and versions, and deploy using a prefect.yaml. We found this method very helpful for standardizing how we name flows and ensures our repo URL's are added to every flow description. Our custom decorator no longer works starting with Prefect 2.19.
Digging into the prefect code base, it looks like the
load_flow_argument_from_entrypoint
function introduced in prefect 2.19 breaks a behavior we were relying on. This functionload_flow_argument_from_entrypoint
does not properly extract attributes that are manipulated by our customflow
decorator.We use our custom
flow
decorator just likeprefect.flow
:where
internal_package
defines theflow
decorator as:Version info (
prefect version
output)Additional context
No response
The text was updated successfully, but these errors were encountered: