Skip to content

Raise error on wrong parameter mapping during pipeline definition #124

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

Merged
merged 36 commits into from
Sep 17, 2024

Conversation

stellasia
Copy link
Contributor

@stellasia stellasia commented Sep 9, 2024

Description

This PR improves the pipeline definition check by raising an error before the pipeline run starts if:

  • the same parameter is mapped twice: for instance:
pipe.connect("a", "b", {"value": "a.value"})
pipe.connect("c", "b", {"value": "c.value"})

"value" for component "b" can only be mapped to "a" or "b", not both.

  • A parameter is defined in the mapping but not expected by component, for instance:
class MyComponent(Component):
    def run(self, number: int) -> Result:
        pass

pipe.connect("something", "my_component", {"a": "something"})

"a" is not an valid input for "MyComponent".

In both cases, PipelineDefinitionError is raised.

Also, introduce an invalidate method, so that the instance attributes are cleaned properly when invalidating the pipeline (if not, when adding a component after the pipeline has already been validated, the validation would fail because the parameter already exists in the param mapping dict from the previous validation).

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: Low

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed
  • CHANGELOG.md updated if appropriate

stellasia added 29 commits June 25, 2024 09:36
…this dict when fetching the component inputs
…on to prepare for drawing pipelines (without user inputs)
…to feature/pipeline-viz

# Conflicts:
#	docs/source/user_guide_pipeline.rst
@stellasia stellasia changed the title Fix/errors in param mapping Raise error on wrong parameter mapping during pipeline definition Sep 10, 2024
@stellasia stellasia marked this pull request as ready for review September 11, 2024 09:06
@stellasia stellasia merged commit b90003b into neo4j:main Sep 17, 2024
8 checks passed
@stellasia stellasia deleted the fix/errors-in-param-mapping branch September 23, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants