Make Record pickle-safe (fix RecursionError via GCS IO manager)#85
Merged
Conversation
Record.__getattr__ read self._payload, so during unpickling — when pickle probes getattr(obj, "__setstate__") before __dict__ is restored — it recursed on the missing _payload until RecursionError. This broke the GCS pickle IO manager whenever a Record (or a payload nesting one) crossed between assets. Guard __getattr__: dunder lookups raise AttributeError (so pickle falls back to default state restore) and _payload is read via __dict__ to avoid re-entry. Verified bare and nested Records round-trip through pickle; 263 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Your pull request is automatically being deployed to Dagster Cloud.
|
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.
Problem
Materializing a downstream asset (e.g.
nm_waterlevel_trends) fails loading an upstream input:Record.__getattr__readsself._payload. During unpickling (the GCS pickle IO manager passing data between assets), pickle probesgetattr(obj, "__setstate__")before__dict__is restored, so_payloaddoesn't exist yet →__getattr__recurses on__getattr__('_payload')until it blows the stack. Triggers whenever aRecord— or a payload dict nesting one — crosses between assets.Fix
Guard
__getattr__:AttributeError(so pickle falls back to its default state restore);_payloadis read viaself.__dict__.get("_payload"), which can't re-enter__getattr__.Verification
Records now round-trip throughpickle.dumps/loads.Note
This was committed to the #84 branch after that PR was squash-merged, so it didn't reach
main. Standalone fix here — affects every IO-manager product (major-chemistry, waterlevel-trends, etc.), so worth merging promptly.🤖 Generated with Claude Code