Skip to content
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

refactor: raise PipelineError when Pipeline.from_dict receives an invalid type #8711

Merged
merged 8 commits into from
Jan 23, 2025

Conversation

tstadel
Copy link
Member

@tstadel tstadel commented Jan 13, 2025

Related Issues

  • fixes getting cryptic Value error if type '' is passed:
    ValueError: not enough values to unpack (expected 2, got 1)

Proposed Changes:

  • raise PipelineError

How did you test it?

  • added test

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I 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 documented my code
  • I ran pre-commit hooks and fixed any issue

@tstadel tstadel requested a review from a team as a code owner January 13, 2025 09:43
@tstadel tstadel requested review from anakin87 and removed request for a team January 13, 2025 09:43
@tstadel tstadel requested a review from a team as a code owner January 13, 2025 09:49
@tstadel tstadel requested review from dfokina and removed request for a team January 13, 2025 09:49
@coveralls
Copy link
Collaborator

coveralls commented Jan 13, 2025

Pull Request Test Coverage Report for Build 12928155465

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 31 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 91.336%

Files with Coverage Reduction New Missed Lines %
core/pipeline/base.py 31 88.64%
Totals Coverage Status
Change from base Build 12927997470: 0.0%
Covered Lines: 8855
Relevant Lines: 9695

💛 - Coveralls

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.

Thanks for the PR...

Do you know when this problem happens? When are we serializing empty types?

Also, what do you think about catching empty strings earlier in the process? It might be helpful to raise a clearer error message. Maybe extend the check here, for instance:
Extend the check here, for example

                if "type" not in component_data:
                    raise PipelineError(f"Missing 'type' in component '{name}'")

@tstadel
Copy link
Member Author

tstadel commented Jan 22, 2025

Thanks for the PR...

Do you know when this problem happens? When are we serializing empty types?

Also, what do you think about catching empty strings earlier in the process? It might be helpful to raise a clearer error message. Maybe extend the check here, for instance: Extend the check here, for example

                if "type" not in component_data:
                    raise PipelineError(f"Missing 'type' in component '{name}'")

I think this type of error is a bit exotic, dc's pipeline builder falls back to empty string if a component type is not known. But this can be fixed otherwise. For haystack, there should be just a reasonable error message in that case.

Do you think it's worth the granularity? An empty string is one case where it breaks, a string without "." is another. The proposed solution solves both in very simple way.

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.

Now I understand better, and I'm OK with this PR.

I only request some minor changes.

test/core/pipeline/test_pipeline.py Outdated Show resolved Hide resolved
@anakin87 anakin87 changed the title fix: error on invalid type refactor: raise PipelineError when Pipeline.from_dict receives an invalid type Jan 23, 2025
@github-actions github-actions bot added the type:documentation Improvements on the docs label Jan 23, 2025
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.

👍

@tstadel tstadel enabled auto-merge (squash) January 23, 2025 11:24
@tstadel tstadel merged commit 3119ae1 into main Jan 23, 2025
18 checks passed
@tstadel tstadel deleted the fix/error_msg_on_invalid_type branch January 23, 2025 11:40
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.

3 participants