diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/helpers/projects | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/helpers/projects')
-rw-r--r-- | app/helpers/projects/ml/experiments_helper.rb | 40 | ||||
-rw-r--r-- | app/helpers/projects/pipeline_helper.rb | 1 |
2 files changed, 40 insertions, 1 deletions
diff --git a/app/helpers/projects/ml/experiments_helper.rb b/app/helpers/projects/ml/experiments_helper.rb index 29bd879859e..a67484e3d2f 100644 --- a/app/helpers/projects/ml/experiments_helper.rb +++ b/app/helpers/projects/ml/experiments_helper.rb @@ -9,7 +9,9 @@ module Projects items = candidates.map do |candidate| { **candidate.params.to_h { |p| [p.name, p.value] }, - **candidate.latest_metrics.to_h { |m| [m.name, number_with_precision(m.value, precision: 4)] } + **candidate.latest_metrics.to_h { |m| [m.name, number_with_precision(m.value, precision: 4)] }, + artifact: link_to_artifact(candidate), + details: link_to_details(candidate) } end @@ -19,6 +21,42 @@ module Projects def unique_logged_names(candidates, &selector) Gitlab::Json.generate(candidates.flat_map(&selector).map(&:name).uniq) end + + def candidate_as_data(candidate) + data = { + params: candidate.params, + metrics: candidate.latest_metrics, + info: { + iid: candidate.iid, + path_to_artifact: link_to_artifact(candidate), + experiment_name: candidate.experiment.name, + path_to_experiment: link_to_experiment(candidate), + status: candidate.status + } + } + + Gitlab::Json.generate(data) + end + + private + + def link_to_artifact(candidate) + artifact = candidate.artifact + + return unless artifact.present? + + project_package_path(candidate.experiment.project, artifact) + end + + def link_to_details(candidate) + project_ml_candidate_path(candidate.experiment.project, candidate.iid) + end + + def link_to_experiment(candidate) + experiment = candidate.experiment + + project_ml_experiment_path(experiment.project, experiment.iid) + end end end end diff --git a/app/helpers/projects/pipeline_helper.rb b/app/helpers/projects/pipeline_helper.rb index edbdb9d4adf..5c62920cd89 100644 --- a/app/helpers/projects/pipeline_helper.rb +++ b/app/helpers/projects/pipeline_helper.rb @@ -12,6 +12,7 @@ module Projects graphql_resource_etag: graphql_etag_pipeline_path(pipeline), metrics_path: namespace_project_ci_prometheus_metrics_histograms_path(namespace_id: project.namespace, project_id: project, format: :json), pipeline_iid: pipeline.iid, + pipeline_path: pipeline_path(pipeline), pipeline_project_path: project.full_path, total_job_count: pipeline.total_size, summary_endpoint: summary_project_pipeline_tests_path(project, pipeline, format: :json), |