-
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
[feature/agent_framework] Changing resources created format #231
[feature/agent_framework] Changing resources created format #231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial pass, looks great, but just had a few thoughts
src/main/java/org/opensearch/flowframework/workflow/CreateConnectorStep.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial pass
src/main/java/org/opensearch/flowframework/common/WorkflowResources.java
Outdated
Show resolved
Hide resolved
* @return the resource that will be created | ||
* @throws IOException if workflow step doesn't exist in enum | ||
*/ | ||
public static String getResourceByWorkflowStep(String workflowStep) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we will only ever create a single resource in a given step? Why not return a list here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now I haven't seen a step that returns multiple resources. It makes it a little more complicated if we have to do a mapping of step 1 creates two fields "connector_id" and "model_id" for example and then we map each ID to the correct one when updating. If you think its likely we will have a step like this I can change the logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add this with my PR for converting the workflow-step.json to an enum if that is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried this out and there are some things to still decide on and I can expand in an issue. Basically making sure we map the right resource key to the right resource value could be a little tricky. For example if we have a list of resourcesCreatedTypes like (“connector_id”, “model_id”, “detector_id”). We need to create a map with each one of those as the key and to know which resource to get but that is arbitrary on how the resource looks like in the response.
List<String> resourceNames = WorkflowResources.getResourcesByWorkflowStep(getName());
Map<String, Object> map = resourceNames.stream()
.collect(Collectors.toMap(
key -> key, // Key Mapper: Use the list item as the key.
value -> {//getting correct corresponding value might not be straightforward cause we would}
// a mapping of each possible resource to the correct method for example"
// "connector_id" -> mlCreateConnectorResponse.getConnectorId()
// "detector" -> however that client defines it as and etc.
));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @dbwiddis here. We should return a list rather a single resource. Follow up PR should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amitgalitz why not create a global map here like we had List<WorkflowData>
in the execute method, name it as Map<String, ResourcesCreated>
and store the resources of a step in it as a new entry to the list.
This way with status API, we need to just iterate on the map which would have key as workflow_step_name and values as the resources created. It will be easy with the new Util method @dbwiddis has here #234
* @param resourceId The resources ID for relating to the created resource | ||
*/ | ||
public ResourceCreated(String workflowStepName, String resourceId) { | ||
public ResourceCreated(String workflowStepName, String workflowStepId, String resourceId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we keep the resource type together with its ID? In order to know the meaning of the resource ID here I need to know its step. This way forces me to look it up from the enum (assuming a 1:1 mapping which I'm not sure of).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by resource type here? the field of connector_id
will be the key here for resourceId
. Since we wanted to have a dynamic key it means it could be anything so I label it as resourceId here
src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
Signed-off-by: Amit Galitzky <[email protected]>
1c28e0e
to
72122e1
Compare
Signed-off-by: Amit Galitzky <[email protected]>
2baf8e7
to
97b3aaf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @amitgalitz ! Thanks for addressing the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good with a general comment of changing the exception to FlowFrameworkException
.
src/main/java/org/opensearch/flowframework/common/WorkflowResources.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/indices/FlowFrameworkIndicesHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Amit Galitzky <[email protected]>
1b4d5af
into
opensearch-project:feature/agent_framework
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]> Co-authored-by: Daniel Widdis <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Daniel Widdis <[email protected]>
* adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
* adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Daniel Widdis <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
…ch-project#231) * adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Daniel Widdis <[email protected]>
* adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Amit Galitzky <[email protected]>
* adding new resources created format and adding enum for resource types Signed-off-by: Amit Galitzky <[email protected]> * remove spotless from java 17 Signed-off-by: Amit Galitzky <[email protected]> * add action listener to update resource created Signed-off-by: Amit Galitzky <[email protected]> * fixing UT Signed-off-by: Amit Galitzky <[email protected]> * changed exception type Signed-off-by: Amit Galitzky <[email protected]> --------- Signed-off-by: Daniel Widdis <[email protected]>
Description
Added updates to resources_created section for register_model_group, register model, create index, create ingest pipeline and create connector steps.
Still didn't add this for register agent since there is more changes that will be merged for that soon.
I also added
retryOnConflict
here based on same number as ml-commons has, since adding this I haven't seen the version conflict issues but I will continue to see if there are better concurrency controls we can have, added a TODO for this.Changed the format of creating a resource to:
Issues Resolved
resolves #173
resolves #136
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.