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

Implements pagination support for GetAll style endpoints #429

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

alexcreasy
Copy link
Contributor

@alexcreasy alexcreasy commented Sep 25, 2024

Description

Implements pagination for the following endpoints:

  • GET /v1/model_registry/{model_registry_id}/registered_models
  • GET /v1/model_registry/{model_registry_id}/registered_models/{registered_model_id}/versions
  • GET /api/v1/model_registry/{model_registry_id}/model_versions/{model_version_id}/artifacts

How Has This Been Tested?

Test Env Setup

  1. Run MR using kind locally and run local BFF with mocked k8s client and live MR client:
make run PORT=4000 MOCK_K8S_CLIENT=true MOCK_MR_CLIENT=false
  1. Seed MR with some test data to work with:
curl -i -X POST "http://localhost:4000/api/v1/model_registry/model-registry/registered_models" \
     -H "Content-Type: application/json" \
     -d '{ "data": {
  "customProperties": {
    "my-label9": {
      "metadataType": "MetadataStringValue",
      "string_value": "val"
    }
  },
  "description": "bella description",
  "externalId": "9927",
  "name": "bella",
  "owner": "eder",
  "state": "LIVE"
}}'
curl -i -X POST "http://localhost:4000/api/v1/model_registry/model-registry/registered_models" \
     -H "Content-Type: application/json" \
     -d '{ "data": {
  "customProperties": {
    "my-label9": {
      "metadataType": "MetadataStringValue",
      "string_value": "val"
    }
  },
  "description": "other description",
  "externalId": "9928",
  "name": "other",
  "owner": "eder",
  "state": "LIVE"
}}'

Test Procedure

  1. Get all registered models
curl -i "http://localhost:4000/api/v1/model_registry/model-registry/registered_models"
  1. Verify there are 2 registered models returned.
  2. Get registered models with pageSize of 1.
curl -i "http://localhost:4000/api/v1/model_registry/model-registry/registered_models?pageSize=1"
  1. Verify one model is returned, pageSize = 1 and size = 1 and that nextPageToken is not empty.
  2. Get registered models with pageSize of 1 and nextPageToken.
curl -i "http://localhost:4000/api/v1/model_registry/model-registry/registered_models?pageSize=1&nextPageToken=CAEQARoCCAE"
  1. Verify the second model is shown on the second page (NOTE: use the nextPageToken from the previous step)
  2. Get registered models ordered by last created time in descending order
curl -i "http://localhost:4000/api/v1/model_registry/model-registry/registered_models?orderBy=LAST_UPDATE_TIME&sortOrder=DESC"
  1. Verify results are ordered correctly.
  2. Repeat stage 7 but change order to ASC and verify they are reversed.

Merge criteria:

  • All the commits have been signed-off (To pass the DCO check)
  • The commits have meaningful messages; the author will squash them after approval or in case of manual merges will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work.
  • Code changes follow the kubeflow contribution guidelines.

If you have UI changes

  • The developer has added tests or explained why testing cannot be added.
  • Included any necessary screenshots or gifs if it was a UI change.
  • Verify that UI/UX changes conform the UX guidelines for Kubeflow.

@alexcreasy alexcreasy force-pushed the pagination branch 2 times, most recently from e578aa8 to c42f302 Compare September 25, 2024 16:10
Copy link
Member

@ederign ederign left a comment

Choose a reason for hiding this comment

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

@alexcreasy thanks for the PR. The code looks OK, but could you please add some samples in our readme of curl calls with pagination for those endpoints?

@Griffin-Sullivan
Copy link
Contributor

@alexcreasy you'll need to rebase so you can run the linter locally for the BFF

```

### Pagination
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied the definitions here off the MR OpenAPI spec.

@alexcreasy
Copy link
Contributor Author

@ederign when you get a chance could you re-review and merge if you're happy? thanks :)

Copy link
Contributor

@Griffin-Sullivan Griffin-Sullivan left a comment

Choose a reason for hiding this comment

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

Tested locally and everything works as expected. Nice work!

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ederign, Griffin-Sullivan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ederign
Copy link
Member

ederign commented Oct 3, 2024

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Oct 3, 2024
@google-oss-prow google-oss-prow bot merged commit 9cc09d9 into kubeflow:main Oct 3, 2024
16 checks passed
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.

3 participants