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

Check before delete #3209

Merged
merged 71 commits into from
Jan 24, 2025
Merged

Conversation

xinyual
Copy link
Collaborator

@xinyual xinyual commented Nov 11, 2024

Description

This pr is to check all downstream service before deleting ml model. Two downstream tasks are checking here:

  1. Agent
  2. Pipelines

For agent, we enforce this tool factory to implement a method to return the key field name of each tool. Then we create a should DSL query like

{
  "query" : {
    "bool" : {
      "must" : [ {
        "bool" : {
          "should" : [ {
            "bool" : {
              "must_not" : [ {
                "exists" : {
                  "field" : "is_hidden",
                  "boost" : 1.0
                }
              } ],
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          }, {
            "bool" : {
              "must" : [ {
                "terms" : {
                  "is_hidden" : [ false ],
                  "boost" : 1.0
                }
              }, {
                "exists" : {
                  "field" : "is_hidden",
                  "boost" : 1.0
                }
              } ],
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          } ],
          "adjust_pure_negative" : true,
          "boost" : 1.0
        }
      }, {
        "bool" : {
          "should" : [ {
            "terms" : {
              "tools.parameters.<fieldName>" : [ "<modelId>" ],
              "boost" : 1.0
            }
          }],
          "adjust_pure_negative" : true,
          "boost" : 1.0
        }
      } ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  }
}

For pipelines, we fetch all ingestion pipelines and search pipelines and check for each pipeline whether they contain the candidate model id.

Related Issues

#3191
#3087
#3088

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual temporarily deployed to ml-commons-cicd-env November 12, 2024 02:55 — with GitHub Actions Inactive
@xinyual xinyual had a problem deploying to ml-commons-cicd-env November 12, 2024 02:55 — with GitHub Actions Failure
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual had a problem deploying to ml-commons-cicd-env November 12, 2024 07:14 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env November 12, 2024 07:14 — with GitHub Actions Failure
@xinyual xinyual marked this pull request as ready for review November 12, 2024 07:15
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 06:14 — with GitHub Actions Failure
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 06:39 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 06:39 — with GitHub Actions Failure
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:19 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:19 — with GitHub Actions Failure
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:40 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:40 — with GitHub Actions Failure
Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:52 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 23, 2025 07:52 — with GitHub Actions Failure
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 24, 2025 00:37 — with GitHub Actions Failure
@xinyual xinyual temporarily deployed to ml-commons-cicd-env January 24, 2025 00:37 — with GitHub Actions Inactive
@xinyual xinyual had a problem deploying to ml-commons-cicd-env January 24, 2025 01:38 — with GitHub Actions Failure
@xinyual xinyual merged commit 570edaf into opensearch-project:main Jan 24, 2025
7 of 8 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 24, 2025
* add logic to detect agent before deleting

Signed-off-by: xinyual <xinyual@amazon.com>

* add logic to detect agent before deleting

Signed-off-by: xinyual <xinyual@amazon.com>

* add logic to detect pipelines before delete model

Signed-off-by: xinyual <xinyual@amazon.com>

* check pipeline before deleting

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* remove useless file

Signed-off-by: xinyual <xinyual@amazon.com>

* rename functions

Signed-off-by: xinyual <xinyual@amazon.com>

* fix failure test

Signed-off-by: xinyual <xinyual@amazon.com>

* add UT

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* renam

Signed-off-by: xinyual <xinyual@amazon.com>

* refactor to parallel check

Signed-off-by: xinyual <xinyual@amazon.com>

* concate error message

Signed-off-by: xinyual <xinyual@amazon.com>

* move logic after user access check

Signed-off-by: xinyual <xinyual@amazon.com>

* change agent model searcher map to set

Signed-off-by: xinyual <xinyual@amazon.com>

* rename and remove useless method

Signed-off-by: xinyual <xinyual@amazon.com>

* fix bug to fetch all pipelines

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* remove and add comment

Signed-off-by: xinyual <xinyual@amazon.com>

* rename and add more UTs

Signed-off-by: xinyual <xinyual@amazon.com>

* use correct key

Signed-off-by: xinyual <xinyual@amazon.com>

* simplify function

Signed-off-by: xinyual <xinyual@amazon.com>

* change to a better class

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* change compareAndSet to set

Signed-off-by: xinyual <xinyual@amazon.com>

* apply comment

Signed-off-by: xinyual <xinyual@amazon.com>

* change name and reformat logic

Signed-off-by: xinyual <xinyual@amazon.com>

* change name

Signed-off-by: xinyual <xinyual@amazon.com>

* remove useless line

Signed-off-by: xinyual <xinyual@amazon.com>

* change to a better method

Signed-off-by: xinyual <xinyual@amazon.com>

* change name

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* add java doc for function

Signed-off-by: xinyual <xinyual@amazon.com>

* add another interface

Signed-off-by: xinyual <xinyual@amazon.com>

* apply java spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* change interface to with model

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot less

Signed-off-by: xinyual <xinyual@amazon.com>

* add settings

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot less

Signed-off-by: xinyual <xinyual@amazon.com>

* add test for cluster setting

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spotless

Signed-off-by: xinyual <xinyual@amazon.com>

* recover useless change

Signed-off-by: xinyual <xinyual@amazon.com>

* change default value of cluster setting

Signed-off-by: xinyual <xinyual@amazon.com>

* rename setting and add comment

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* remove logic for hidden model

Signed-off-by: xinyual <xinyual@amazon.com>

* reorder code

Signed-off-by: xinyual <xinyual@amazon.com>

* reorder code

Signed-off-by: xinyual <xinyual@amazon.com>

* reorder code

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* add UT

Signed-off-by: xinyual <xinyual@amazon.com>

* add more UT

Signed-off-by: xinyual <xinyual@amazon.com>

* remove search for hidden agent

Signed-off-by: xinyual <xinyual@amazon.com>

* fix logic and apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* add exist for UT

Signed-off-by: xinyual <xinyual@amazon.com>

* change dsl to query index

Signed-off-by: xinyual <xinyual@amazon.com>

* change query logic

Signed-off-by: xinyual <xinyual@amazon.com>

* remove useless ut

Signed-off-by: xinyual <xinyual@amazon.com>

* rebert

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* rechange code

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* remove useless should

Signed-off-by: xinyual <xinyual@amazon.com>

* apply spot

Signed-off-by: xinyual <xinyual@amazon.com>

* fix final dsl logic and ut

Signed-off-by: xinyual <xinyual@amazon.com>

---------

Signed-off-by: xinyual <xinyual@amazon.com>
(cherry picked from commit 570edaf)
xinyual added a commit that referenced this pull request Jan 24, 2025
* add logic to detect agent before deleting



* add logic to detect agent before deleting



* add logic to detect pipelines before delete model



* check pipeline before deleting



* apply spotless



* remove useless file



* rename functions



* fix failure test



* add UT



* apply spotless



* renam



* refactor to parallel check



* concate error message



* move logic after user access check



* change agent model searcher map to set



* rename and remove useless method



* fix bug to fetch all pipelines



* apply spotless



* apply spotless



* remove and add comment



* rename and add more UTs



* use correct key



* simplify function



* change to a better class



* apply spotless



* change compareAndSet to set



* apply comment



* change name and reformat logic



* change name



* remove useless line



* change to a better method



* change name



* apply spotless



* add java doc for function



* add another interface



* apply java spotless



* change interface to with model



* apply spot less



* add settings



* apply spot less



* add test for cluster setting



* apply spotless



* recover useless change



* change default value of cluster setting



* rename setting and add comment



* apply spot



* remove logic for hidden model



* reorder code



* reorder code



* reorder code



* apply spot



* add UT



* add more UT



* remove search for hidden agent



* fix logic and apply spot



* add exist for UT



* change dsl to query index



* change query logic



* remove useless ut



* rebert



* apply spot



* rechange code



* apply spot



* remove useless should



* apply spot



* fix final dsl logic and ut



---------


(cherry picked from commit 570edaf)

Signed-off-by: xinyual <xinyual@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants