Maps addition Ml:: graphql types
What does this MR do and why?
Maps addition Ml:: graphql types
- Adds CandidateParamType, CandidateMetricType, CandidateMetadataType
- Adds params, metrics and fields to CandidateType
- Adds packageId field to ModelVersionType
These are necessary to move the Model registry data fetching to graphql !149260 (merged)
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
Numbered steps to set up and validate the change are strongly suggested.
-
In rails console enable the experiment fully
Feature.enable(:model_registry)
-
Create a model and model_version:
p = Project.find_by(id: 1) model = Ml::FindOrCreateModelService.new(p, "gitlab_amazing_model").execute model_version = Ml::FindOrCreateModelVersionService.new(p, { model_name: "gitlab_amazing_model", version: "1.0.0" }).execute candidate = model_version.candidate Ml::CandidateParam.create!(candidate: candidate, name: 'param1', value: 'value1') Ml::CandidateMetadata.create!(candidate: candidate, name: 'metadata1', value: 'metadataValue1') Ml::CandidateMetric.create!(candidate: candidate, name: 'metric1', value: 0.6, step: 1)
-
Open
http://localhost:3000/-/graphql-explorer
and run the following query (change model id for the model created):query { mlModel(id: "gid://gitlab/Ml::Model/1") { id latestVersion { packageId candidate { id name iid eid status params { nodes { id name value } } metadata { nodes { id name value } } metrics { nodes { id name value step } } } } } }
It should return something like:
{ "data": { "mlModel": { "id": "gid://gitlab/Ml::Model/1", "latestVersion": { "packageId": "gid://gitlab/Packages::Package/5025", "candidate": { "id": "gid://gitlab/Ml::Candidate/5000", "name": "hare-zebra-cobra-9745", "iid": 5000, "eid": "e9a71521-45c6-4b0a-b0c3-21f0b4528a5c", "status": "running", "params": { "nodes": [ { "id": "gid://gitlab/Ml::CandidateParam/318", "name": "param1", "value": "value1" } ] }, "metadata": { "nodes": [ { "id": "gid://gitlab/Ml::CandidateMetadata/226", "name": "metadata1", "value": "metadataValue1" } ] }, "metrics": { "nodes": [ { "id": "gid://gitlab/Ml::CandidateMetric/46", "name": "metric1", "value": 0.6, "step": 1 }, ] } } } } } }
Edited by Eduardo Bonet