fix: FCC behavior classes could not be pickled for distributed workers - #1603
Open
ikrommyd wants to merge 2 commits into
Open
fix: FCC behavior classes could not be pickled for distributed workers#1603ikrommyd wants to merge 2 commits into
ikrommyd wants to merge 2 commits into
Conversation
… ones The edm4hep1 overloads reused the same class names, so awkward's generated MCParticleRecord/Array module attributes pointed at the wrong classes and the pre-edm4hep1 behavior could no longer be pickled by reference. Assisted-by: ClaudeCode:claude-opus-4.8
ikrommyd
force-pushed
the
fix/fcc-behavior-class-shadowing
branch
from
July 21, 2026 19:06
ac109fc to
b84f28d
Compare
property keeps fget/fset/fdel in C slots and has no reduction of its own, so behavior classes defined in __main__ or a notebook could not be sent to a distributed worker. Assisted-by: ClaudeCode:claude-opus-4.8
ikrommyd
force-pushed
the
fix/fcc-behavior-class-shadowing
branch
from
July 21, 2026 19:17
b84f28d to
57ba19b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
The FCC tests pass when the file is run on its own but fail under
pytest tests:The
dask_clientfixture intests/conftest.pyis session-scoped anddistributed.Clientdefaults toset_as_default=True, so as soon as any test that uses it has run, every later.compute()in the session goes through the distributed scheduler instead of the local threaded one. That means the schema'sbehaviordict has to be pickled, and forFCCSchemait can't be.The
vector.backends.awkward.<lambda>message in the traceback is a red herring —distributed.protocol.pickle.dumpstries plain pickle first and falls back to cloudpickle, which handles those lambdas fine. The error that actually escapes is from the fallback:Shadowed behavior classes
methods/fcc.pydefinedMCParticle,ReconstructedParticle,ParticleID,ClusterandTracktwice — once forbehavior(pre-edm4hep1) and again forbehavior_edm4hep1, with# noqa: F811.awkward.mixin_classinjects the generated<Name>Record/<Name>Arrayclasses as module attributes, so the second batch overwrote the first, and the classes still held by the pre-edm4hep1behaviordict were no longer reachable ascoffea.nanoevents.methods.fcc.MCParticleRecord.cloudpickle only pickles a class by reference when
getattr(module, cls.__qualname__) is cls. That check now failed, so it fell back to pickling the class by value, walked its__dict__, and hit a_DaskProperty.The edm4hep1 classes are renamed with an
_edm4hep1suffix and keep their behavior keys viamixin_class(..., name=...), so nothing user-facing changes.FCCSchemawas the only schema affected.Note that by-value class pickling is worth avoiding on its own even when it succeeds: it bloats every graph and gives each worker a class object that is not the one in the module.
Unpicklable
dask_propertySeparately,
propertykeepsfget/fset/fdelin C-level slots and provides no reduction, so CPython refuses to pickle it (pickle.dumps(property(f))raises the sameTypeError). Any behavior mixin using@dask_propertyand defined outside an importable module —__main__, a notebook — therefore cannot be sent to a distributed worker, whether or not it lives in coffea._DaskPropertynow defines__reduce__._DaskMethodkeeps all of its state in a normal instance__dict__and already pickled fine, so it is unchanged.coffea's
_DaskPropertyis a copy of dask-awkward's, which has the same bug; fixed upstream in dask-contrib/dask-awkward#629.Tests
test_schema_behavior_survives_picklingchecks, for every schema, that the behavior dict cloudpickles and that every class in it is reachable under its own qualified name. The second half is the important one: with the__reduce__fix in place the shadowed FCC classes pickle successfully again, so only the qualname check still catches the regression.test_dask_property_is_picklableround-trips a class defined in a function body (forcing the by-value path) and checks the eager getter, the.daskdispatch andno_dispatch=Trueall survive.