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

[feature/agent_framework] Changing resources created format #231

Conversation

amitgalitz
Copy link
Member

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:

 {
                "_index": ".plugins-workflow-state",
                "_id": "RvEFF4wBKbeLfRazqAdh",
                "_score": 1.0,
                "_source": {
                    "workflow_id": "RvEFF4wBKbeLfRazqAdh",
                    "state": "PROVISIONING",
                    "provisioning_progress": "IN_PROGRESS",
                    "provision_start_time": 1701193321252,
                    "resources_created": [
                        {
                            "workflow_step_name": "create_connector",
                            "workflow_step_id": "workflow_step_1-amit-test",
                            "connector_id": "TfEGF4wBKbeLfRazCwcp"
                        },
                        {
                            "workflow_step_name": "register_remote_model",
                            "workflow_step_id": "workflow_step_2",
                            "model_id": "T_EGF4wBKbeLfRazCwdx"
                        }
                    ],
                    "provision_end_time": 1701193305145
                }
            }

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.

Copy link
Member

@joshpalis joshpalis left a 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

build.gradle Outdated Show resolved Hide resolved
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Initial pass

.github/workflows/CI.yml 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 {
Copy link
Member

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?

Copy link
Member Author

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

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 could add this with my PR for converting the workflow-step.json to an enum if that is okay.

Copy link
Member Author

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. 
            ));

Copy link
Member

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.

Copy link
Member

@owaiskazi19 owaiskazi19 Dec 1, 2023

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) {
Copy link
Member

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).

Copy link
Member Author

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

@amitgalitz amitgalitz force-pushed the resoure-changes-feature branch from 1c28e0e to 72122e1 Compare December 1, 2023 20:04
Signed-off-by: Amit Galitzky <[email protected]>
@amitgalitz amitgalitz force-pushed the resoure-changes-feature branch from 2baf8e7 to 97b3aaf Compare December 1, 2023 21:58
Copy link
Member

@joshpalis joshpalis left a 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

Copy link
Member

@owaiskazi19 owaiskazi19 left a 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.

Signed-off-by: Amit Galitzky <[email protected]>
@amitgalitz amitgalitz merged commit 1b4d5af into opensearch-project:feature/agent_framework Dec 1, 2023
10 checks passed
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
…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]>
dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
…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]>
dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
…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]>
dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
…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]>
dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
…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]>
dbwiddis pushed a commit that referenced this pull request Dec 18, 2023
* 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]>
dbwiddis added a commit that referenced this pull request Dec 18, 2023
* 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]>
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 18, 2023
…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]>
dbwiddis added a commit to dbwiddis/flow-framework that referenced this pull request Dec 18, 2023
…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]>
dbwiddis pushed a commit that referenced this pull request Dec 18, 2023
* 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]>
dbwiddis added a commit that referenced this pull request Dec 18, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants