-
Notifications
You must be signed in to change notification settings - Fork 19
draccus.dump can fail with 'TypeError: cannot create weak reference to str object' #61
Copy link
Copy link
Open
Labels
agent-generatedCreated by an automated coding agentCreated by an automated coding agentbugSomething isn't workingSomething isn't working
Description
Summary
draccus.dump(...) can fail with:
TypeError: cannot create weak reference to 'str' object
We hit this while logging a dataclass config artifact from Levanter/Marin. The error is nonfatal in our caller, but it prevents config YAML artifact emission.
Context
Caller path:
with open(path, "w", encoding="utf-8") as f:
draccus.dump(hparams, f, encoding="utf-8")The surrounding caller is a tracker/logging utility that checks dataclasses.is_dataclass(hparams) before calling draccus.dump(...).
Observed traceback
TypeError: cannot create weak reference to 'str' object
The traceback originates from inside draccus.dump(...) when dumping our experiment config dataclass.
Notes
- This showed up repeatedly in long-running training jobs.
- In our case the training run continues, but config artifact logging is skipped.
- I do not yet have a smaller standalone repro than “nested experiment config dataclass with string fields”, but I wanted to file the bug with the exact failure mode because it is recurring.
Expected behavior
draccus.dump(...) should successfully serialize the dataclass, or fail with a more direct validation error if the input type is unsupported.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
agent-generatedCreated by an automated coding agentCreated by an automated coding agentbugSomething isn't workingSomething isn't working