Skip to content

Conversation

@julian-risch
Copy link
Member

@julian-risch julian-risch commented Jan 20, 2026

Related Issues

Proposed Changes:

  • Extend default_to_dict so that we call to_dict() for any init parameters that are of type ComponentDevice
  • Extend default_from_dict so that we call ComponentDevice.from_dict for any dict values that have single or multiple as value of field type and a device string or a device_map dict
  • Added tests to verify that the automatic ComponentDevice handling works through component_to_dict/component_from_dict, which internally use default_to_dict/default_from_dict

How did you test it?

Notes for the reviewer

Once this PR is merged I am happy to do a follow up PR that makes use of these changes in all ready-made components in Haystack that use ComponentDevice. I will simplify the to_dict and from_dict methods.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@julian-risch julian-risch requested a review from a team as a code owner January 20, 2026 17:02
@julian-risch julian-risch requested review from anakin87 and removed request for a team January 20, 2026 17:02
@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
haystack-docs Ready Ready Preview, Comment Jan 21, 2026 2:02pm

Request Review

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@julian-risch julian-risch enabled auto-merge (squash) January 21, 2026 14:01
@julian-risch julian-risch merged commit 2121e32 into main Jan 21, 2026
21 checks passed
@julian-risch julian-risch deleted the default-serde-component-device branch January 21, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle (de-)serialization of ComponentDevice in default_from_dict, default_to_dict automatically

3 participants