Skip to content

Commit

Permalink
better error messages in case of unsatisfied steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Aethor committed Jul 2, 2024
1 parent b50f6e6 commit 5e0ae71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/pipeline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 68,7 @@ In that case, the ``tokens`` requirements is fulfilled at run time. If
you don't pass the parameter, Renard will throw the following
exception:

>>> ValueError: ["step 1 (NLTKNamedEntityRecognizer) has unsatisfied needs (needs : {'tokens'}, available : {'text'})"]
>>> ValueError: ["step 1 (NLTKNamedEntityRecognizer) has unsatisfied needs. needs: {'tokens'}. available: {'text'}). missing: {'tokens'}."]


For simplicity, one can use one of the preconfigured pipelines:
Expand Down
18 changes: 16 additions & 2 deletions renard/pipeline/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 632,27 @@ def check_valid(
return (
False,
[
f"step {i 1} ({step.__class__.__name__}) has unsatisfied needs (needs : {step.needs()}, available : {pipeline_state})"
"".join(
[
f"step {i 1} ({step.__class__.__name__}) has unsatisfied needs. "
f"needs: {step.needs()}. "
f"available: {pipeline_state}). "
f"missing: {step.needs() - pipeline_state}."
]
),
],
)

if not step.optional_needs().issubset(pipeline_state):
warnings.append(
f"step {i 1} ({step.__class__.__name__}) has unsatisfied optional needs : (optional needs : {step.optional_needs()}, available : {pipeline_state})"
"".join(
[
f"step {i 1} ({step.__class__.__name__}) has unsatisfied optional needs. "
f"needs: {step.optional_needs.needs()}. "
f"available: {pipeline_state}). "
f"missing: {step.optional_needs() - pipeline_state}."
]
)
)

pipeline_state = pipeline_state.union(step.production())
Expand Down

0 comments on commit 5e0ae71

Please sign in to comment.