-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix #17354: Preserve class binding in classmethod flows when using #17647
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #17647 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @vilhenad! I think it makes more sense to move the copying logic into .with_options
, since copying the function shouldn't be necessary during normal execution. Copying it on every call could increase memory usage for instance method flows.
Thank you for the quick review @desertaxle! I completely understand your point on increasing memory usage. However, if you don't mind clarifying, I've got a question. As you can see by my second unit test, this fix also addresses instance methods not preserving context when using a flow (without |
… using .with_options() Classmethod flows were losing their cls inheritance structure when copied with .with_options(), causing them to default to the base class implementation. The fix ensures proper context preservation by: 1. Creating deep copies of the function for each bound flow 2. Preserving all function attributes during copying Added test cases verify: - Classmethod inheritance is maintained after .with_options() Closes PrefectHQ#17354
19d765a
to
aeeb09a
Compare
…s__ and __prefect_self__) so that instance methods don't lose context and don't fail parameter binding.
@desertaxle I've pushed the changes you requested. One thing is confusing me: my unit test is passing fine locally, but consistently failing in the GitHub CI. The test code appears identical to the example from the issue page and works in isolation locally. |
Thanks for making those updates @vilhenad! I think it's failing on 3.13 because of changes in 3.13 that made |
Classmethod flows were losing their cls inheritance structure when copied with .with_options(), causing them to default to the base class implementation. This was particularly evident when subclassing (e.g., ChildProcessor.process would incorrectly use BaseProcessor.get_multiplier).
The fix ensures proper context preservation by:
Added test cases verify:
Closes #17354
Checklist
<link to issue>
"mint.json
.