This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
feat: Add Component inputs/outputs functions #158
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why:
To enable introspection of Canals components, namely the ability to retrieve information about component inputs and outputs programmatically.
What:
Two methods,
component_inputs
andcomponent_outputs
, were added incanals/component/descriptions.py
How can it be used:
Once this PR is merged, Canals component instances could be inspected for inputs/outputs:
The
component_inputs
method returns a dictionary where each key is an input socket name while values are its type and optionality, and thecomponent_outputs
method similarly returns a dictionary mapping output socket names to their types.How did you test it:
Unit tests have been added to
test/component/test_component.py
to verify that thecomponent_inputs
andcomponent_outputs
methods function as expected, providing the correct details for each socket.Notes for reviewer:
I first added these methods to the component itself dynamically and then realized that outputs and inputs could be a field declared by the creator of the component class. This happened even in some of our test classes, causing massive test failures. I then realized it is better and safer to create class external methods - as described above. This approach is nicely symmetrical to
find_pipeline_inputs
andfind_pipeline_outputs
.