Skip to content

Adds download endpoint to MlModel Registry

What does this MR do and why?

Adds GET /api/v4/projects/:id/packages/ml_models/:package_name/:package_version/:file_name. Uses the same authentication table as rubygems endpoint.

How to set up and validate locally

  1. Enable the feature flag

    echo "Feature.enable(:model_registry)" | bundle exec rails c
  2. Create an access token, and choose a project. Create a simple file:

    echo 'blah' > blah.txt
  3. Upload a file to ml_models. It should return {"message":"201 Created"} with feature flag enabled, 404 if feature flag disabled.

    curl  --header "Authorization:$GLAB_TOKEN" --upload-file blah.txt "http://localhost:3000/api/v4/projects/$PROJECT_ID/packages/ml_models/blah2/1.1.0/blah.txt"
  4. Download the file:

    curl  --header "Authorization:$GLAB_TOKEN" "http://localhost:3000/api/v4/projects/19/packages/ml_models/blah2/1.1.0/blah.txt"

Database

Query:

SELECT
    "packages_packages".*
FROM
    "packages_packages"
WHERE
    "packages_packages"."project_id" = 1
    AND "packages_packages"."status" IN (0, 1)
    AND "packages_packages"."package_type" = 14
    AND "packages_packages"."name" = 'abc'
    AND "packages_packages"."version" = '123'
LIMIT 1

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19756/commands/64661

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #385043 (closed)

Edited by Eduardo Bonet

Merge request reports

Loading