Skip to content

Resolve "Packaging: Support directory structure"

What does this MR do and why?

Enables creating package files with files that belong to a directory, saving the directory as a URL encoded version of the file name. Changes the endpoints from /packages/ml_models/model_name/model_version to /packages/ml_models/model_version_id to simplify route matching.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable the Feature flag

    Feature.enable(:model_registry)
  2. In rails console, create a model and a few model versions

    p = Project.find_by(id: 1)
    Ml::FindOrCreateModelService.new(p, "model_1").execute
    Ml::FindOrCreateModelVersionService.new(p, { model_name: "model_1", version: "1.0.0" })
  3. Upload a file using the API (this can be called from gitlab root, needs token with api scope)

    curl  --header "Authorization: Bearer $GLAB_TOKEN" --upload-file ./README.md "http://localhost:3000/api/v4/projects/1/packages/ml_models/1/files/path/to/file.md"
  4. Navigate to <gdk>/<project>/-/ml/models select the model. The file should show in the UI as in the screenshot image

  5. Download the file in the UI or using the API

    curl  --header "Authorization:Bearer $GLAB_TOKEN" "http://localhost:3000/api/v4/projects/1/packages/ml_models/1/files/path/to/file.md"

Related to #417437 (closed)

Edited by Eduardo Bonet

Merge request reports