Skip to content

Adds additional graphql fields for Ml::Model

What does this MR do and why?

Adds additional graphql fields for Ml::Model

Fields required to use graphql to show a list of models.

How to set up and validate locally

  1. Enable the feature flag and create a few models

    Feature.enable(:model_registry)
    
    p = Project.find_by(id: 1)
    Ml::FindOrCreateModelService.new(p, "model_1").execute
    Ml::FindOrCreateModelService.new(p, "model_2").execute
  2. Navigate to <gdk>/-/graphql-explorer, and execute the query

{
  project(fullPath: "/root/test_project") {
    mlModels {
      count
      nodes {
        id,
        name,
        versionCount,
        latestVersion {
          version,
          _links {
            showPath,
            packagePath
          }
        },
        _links {
          showPath
        }
      }
      pageInfo {
        hasNextPage
        hasPreviousPage
        endCursor
        startCursor
      }
    }
  }
}
  1. Results should be similar to the below:
{
  "data": {
    "project": {
      "mlModels": {
        "count": 2,
        "nodes": [
          {
            "id": "gid://gitlab/Ml::Model/54",
            "name": "model_2",
            "versionCount": 0,
            "latestVersion": null,
            "_links": {
              "showPath": "/root/test_project_2/-/ml/models/54"
            }
          },
          {
            "id": "gid://gitlab/Ml::Model/53",
            "name": "model_1",
            "versionCount": 0,
            "latestVersion": null,
            "_links": {
              "showPath": "/root/test_project_2/-/ml/models/53"
            }
          }
        ],
        "pageInfo": {
          "hasNextPage": false,
          "hasPreviousPage": false,
          "endCursor": "eyJjcmVhdGVkX2F0IjoiMjAyMy0xMi0xOCAxMjo1NzoyOC44ODc0OTcwMDAgKzAwMDAiLCJpZCI6IjUzIn0",
          "startCursor": "eyJjcmVhdGVkX2F0IjoiMjAyMy0xMi0xOCAxMjo1NzozMS44OTAyNjYwMDAgKzAwMDAiLCJpZCI6IjU0In0"
        }
      }
    }
  }
}

MR acceptance checklist

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

Merge request reports