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

Fix exception when invoke consumes with invalid field schema #842

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fondant/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def _validate_pipeline_definition(self, run_id: str):
if component_field.type != manifest_field.type:
msg = (
f"The invoked field '{component_field_name}' of the "
f"'{component_op.name}' component does not match the "
f"'{component_op.component_name}' component does not match the "
f"previously created field type.\n The '{manifest_field.name}' "
f"field is currently defined with the following type:\n"
f"{manifest_field.type}\nThe current component to "
Expand Down
34 changes: 34 additions & 0 deletions tests/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Fondant pipelines test."""
import copy
import re
from pathlib import Path

import dask.dataframe as dd
Expand Down Expand Up @@ -556,3 +557,36 @@ def test_schema_propagation():
location="/pipeline-id/chunk_text",
),
}


def test_invoked_field_schema_raise_exception():
"""Test that check if the invoked field schema not matches the
current schema raise an InvalidPipelineDefinition.
"""
pipeline = Pipeline(name="pipeline", base_path="base_path")

pipeline.get_run_id = lambda: "pipeline-id"

dataset = pipeline.read(
"load_from_hf_hub",
produces={
"image": pa.binary(),
},
)

dataset.write(
"write_to_file",
consumes={
"image": pa.string(),
},
)

expected_error_msg = re.escape(
"The invoked field 'image' of the 'write_to_file' component does not match the previously "
"created field type.\n The 'image' field is currently defined with the following "
"type:\nType(DataType(binary))\nThe current component to trying to invoke "
"it with this type:\nType(DataType(string))",
)

with pytest.raises(InvalidPipelineDefinition, match=expected_error_msg):
pipeline.validate("pipeline-id")
Loading