-
Notifications
You must be signed in to change notification settings - Fork 37
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
[REFACTOR] Eliminate duplication of required input / output List/Set #535
Comments
@dbwiddis can i pick this issue? |
i do see other strings are also repeated! and can be as well refactored. |
Hey @ajay83 go for it! |
@dbwiddis can you kindly elaborate more about point 3 , as per point 3 getInputs currently returns List.copyOf(inputs) and this should be class field as NAME? same for the output. |
The Currently we just do a temporary assignment of required inputs / keys with this assignment (and similar in every step): flow-framework/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java Lines 124 to 132 in 24bf51a
Elsewhere when we validate the template we are independently creating a list of exactly the same inputs: flow-framework/src/main/java/org/opensearch/flowframework/workflow/WorkflowStepFactory.java Lines 115 to 117 in 24bf51a
My suggestion is to change the Point 4 would do the same thing for the outputs. They are not currently defined in each workflow step, but we should define them there, as the eventual assignment happens there and it's easier to make sure they are in alignment (we had a recent issue where we discovered a mismatch much later.) This may be a bit more complicated in the cases that we look it up from the resource enum. flow-framework/src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java Line 98 in 24bf51a
|
Hey @ajayl83 how's it going with this issue? Need any help? |
Hey @ajayl83 I'm going to unassign this to let someone else work on it. If you are around and want to re-claim it just let us know. |
Is your feature request related to a problem?
The WorkflowValidatorTests class contains a lot of repetitive code that could be refactored to be more general.
This test class was originally written to validate the JSON file. Following #523 we now have an Enum and easier access to programmatically perform these tests, so it can be simplified.
What solution would you like?
The manual creation of a map here can be reduced to a single statement, which I've done as part of #530 .
The Input/Output size checks here could be improved.
Taking one entry as an example:
CreateConnectorStep.NAME
.get()
returns null and we try to get inputs or outputs.Set<String>
) and separately in theWorkflowStepValidator
class (as aList<String>
). This duplication should be removed by making the collection a class field with a getter similarly to howNAME
is declared.WorkflowStep
implementation classes, but we should do so to keep that declaration closer to where we actually populate theWorkflowData
when the step is complete.What alternatives have you considered?
Leave the code as-is and keep adding to it.
Do you have any additional context?
https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
The text was updated successfully, but these errors were encountered: