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

Add input and output handles to components #49

Merged
merged 4 commits into from
Oct 4, 2023

Conversation

ohltyler
Copy link
Member

@ohltyler ohltyler commented Oct 3, 2023

Description

This PR adds the input and output handles to the general WorkspaceComponent. Specifically, we add an InputHandle and OutputHandle class which adds the Handle reactflow component dynamically based on the component spec. These classes configure the data within the input and output handles so they can be processed correctly.

Also adds a custom isValidConnection helper fn to determine if a connection from a source to target is allowed. Currently, we do basic validation that 1/ the base classes are the same and 2/ prevent multiple connections if the input handle does not allow it. Short video below demonstrates this.

Current logic assumes the output handle may be multiple classes (string[]). These are serialized/deserialized by turning them into a pipe-delimited string. The input handle is under the assumption to just have one class for now.

Additional clean up

  • removed unnecessary id field from the component classes. The unique id for a node will just use the existing reactflow node that already has an id. When a user adds a component to the workspace (onDrop()), a random ID will be generated using the new generateId helper fn.
  • formalizes the classes from type string to a COMPONENT_CLASS enum

Testing

  • tested the isValidConnection fn works as expected for the different use cases
  • tested that 0/1/multiple input & output handles renders correctly
screen-capture.12.webm

Issues Resolved

Makes progress on #8, #10, and #16

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

{
id: 'text-embedding-processor',
label: 'Text embedding processor',
baseClass: COMPONENT_CLASS.TEXT_EMBEDDING_PROCESSOR,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, aware a lot of the questions I am asking might be not relevant as lots hasn't been decided. Here do we have the processor as an input for the index? I thought we wont be doing that as the processor is an input to the ingest pipeline creation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's undecided, refer to above comments.

// Validates that connections can only be made when the source and target classes align, and
// that multiple connections to the same target handle are not allowed unless the input configuration
// for that particular component allows for it.
export function isValidConnection(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick question if we do here the validation if the source class aligns with target class, what is left for the onConnect method where we do validation as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onConnect will handle any other updates we need to do after a connection is made, such as updating properties of the edge itself, or update properties of the node being connected potentially. isValidConnection is just for gatekeeping that a connection is allowed to be made or not.

const targetNodeId = connection.target;
const inputClass = sourceHandle || '';
// We store the output classes in a pipe-delimited string. Converting back to a list.
const outputClasses = targetHandle?.split('|') || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test here if we have a list of 3 output classes, and a list of 3 target classes, just one of them matching is enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Also, I was splitting the target handle instead of the source handle. Updated in latest commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of input/output language since that added some confusion.

Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: Tyler Ohlsen <[email protected]>
@ohltyler ohltyler merged commit a9113e8 into opensearch-project:main Oct 4, 2023
4 checks passed
@ohltyler ohltyler deleted the input-output branch October 4, 2023 22:59
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2023
* Add input & output handlers and some validation

Signed-off-by: Tyler Ohlsen <[email protected]>

* Clean up IDs & base classes

Signed-off-by: Tyler Ohlsen <[email protected]>

* Clean up isValidConnection

Signed-off-by: Tyler Ohlsen <[email protected]>

* Enforce baseclass in input

Signed-off-by: Tyler Ohlsen <[email protected]>

---------

Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit a9113e8)
ohltyler added a commit that referenced this pull request Oct 4, 2023
Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit a9113e8)

Co-authored-by: Tyler Ohlsen <[email protected]>
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