From f52c8c4ace3696767da9aec211fc6e24f9f246c0 Mon Sep 17 00:00:00 2001 From: Kai Waldrant Date: Tue, 26 Nov 2024 15:01:34 +0100 Subject: [PATCH] Update reporting components to include all links (#915) * update get_method_info * update get_task_info * update get_metric_info * simplify gsub code * fix implementation url * fix typo * update touch url * add name to image * change image order * update task info output * add code version * update changelog * fix image url * Add image link for nextflow method * flatten references * update references output * fix method references output --------- Co-authored-by: Robrecht Cannoodt --- CHANGELOG.md | 4 ++ src/reporting/get_method_info/script.R | 52 ++++++++++++++++++++++---- src/reporting/get_metric_info/script.R | 29 +++++++++++--- src/reporting/get_task_info/script.R | 9 ++++- 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3213323e2..66cf69ec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,10 +28,14 @@ - Update `dataset_id` for `tenx_visium`, `zenodo_spatial`, `zenodo_spatial_slidetags` datasets and use `mouse_brain_coronal` as a test resource in the `spatially_variable_genes` task (PR #908). +- Update `get_task_info`, `get_method_info` and `get_metrics_info` reporting components with more info and extend output (PR #915). + ## Bug fixes - Fix extracting metadata from anndata files in the `extract_metadata` component (PR #914). +- Fix path in `touch` cmd in `reporting/process_task_results/run_test.sh` (PR #915). + # openproblems v2.0.0 A major update to the OpenProblems framework, switching from a Python-based framework to a Viash + Nextflow-based framework. This update features the same concepts as the previous version, but with a new implementation that is more flexible, scalable, and maintainable. diff --git a/src/reporting/get_method_info/script.R b/src/reporting/get_method_info/script.R index 2d20cbf0c..0623d89fd 100644 --- a/src/reporting/get_method_info/script.R +++ b/src/reporting/get_method_info/script.R @@ -5,7 +5,7 @@ library(rlang, warn.conflicts = FALSE) ## VIASH START par <- list( - input = "resources_test/openproblems/task_results_v3/raw/method_configs.yaml", + input = "method_configs.yaml", output = "resources_test/openproblems/task_results_v3/processed/method_info.json" ) ## VIASH END @@ -27,7 +27,7 @@ outputs <- map(configs, function(config) { info <- config$info # add extra info - info$config_path <- gsub(".*/src/", "src/", build_info$config) + info$comp_path <- gsub(".*/src/", "src/", build_info$config) %>% gsub("/config.vsh.yaml", "", .) info$task_id <- gsub("/.*", "", config$namespace) info$id <- config$name info$namespace <- config$namespace @@ -35,14 +35,49 @@ outputs <- map(configs, function(config) { info$summary <- config$summary %||% info$summary info$description <- config$description %||% info$description info$commit_sha <- build_info$git_commit %||% "missing-sha" - info$code_version <- "missing-version" + info$code_version <- config$version + info$code_url <- config$links$repository + info$documentation_url <- config$links$documentation + # Check if the method has a docker container to create an image url. If it does not have a docker it will be a nextflow component consisting of different components that will have a docker image. + engines <- config$engines + has_docker <- any(map_lgl(engines, ~ .x$type == "docker")) + if (has_docker) { + info$image <- paste0( + "https://", + config$links$docker_registry, "/", + config$package_config$organization, "/", + config$package_config$name, "/", + gsub("src/", "", info$comp_path), + ":", + info$code_version + ) + } else { + info$image <- paste0( + "https://github.com/orgs/openproblems-bio/packages?repo_name=", + config$package_config$name, + "&q=", + gsub("src/", "", info$comp_path) + ) + } info$implementation_url <- paste0( build_info$git_remote, "/blob/", build_info$git_commit, "/", - info$config_path + info$comp_path ) info$type_info <- NULL + # Flatten references + if (!is.null(config$references) && config$references != "") { + info <- imap(config$references, function(value, key) { + info[[paste0("references_", key)]] <- value + return(info) + })[[1]] + } + info$references <- NULL + + print(info) + + # ↑ this could be used as the new format # construct v1 format @@ -53,10 +88,13 @@ outputs <- map(configs, function(config) { method_summary = info$summary, method_description = info$description, is_baseline = grepl("control", info$type), - paper_reference = info$reference %||% NA_character_, - code_url = info$repository_url %||% NA_character_, + references_doi = info$references_doi %||% NA_character_, + references_bibtex = info$references_bibtex %||% NA_character_, + code_url = info$code_url %||% NA_character_, + documentation_url = info$documentation_url %||% NA_character_, + image = info$image %||% NA_character_, implementation_url = info$implementation_url %||% NA_character_, - code_version = NA_character_, + code_version = info$code_version %||% NA_character_, commit_sha = info$commit_sha ) diff --git a/src/reporting/get_metric_info/script.R b/src/reporting/get_metric_info/script.R index a13e55de7..0f046bd90 100644 --- a/src/reporting/get_metric_info/script.R +++ b/src/reporting/get_metric_info/script.R @@ -28,19 +28,36 @@ outputs <- map(configs, function(config) { config$info$metrics, function(info) { # add extra info - info$config_path <- gsub(".*/src/", "src/", build_info$config) + info$comp_path <- gsub(".*/src/", "src/", build_info$config) %>% gsub("/config.vsh.yaml", "", .) info$task_id <- gsub("/.*", "", config$namespace) info$id <- info$name info$name <- NULL info$component_name <- config$name info$namespace <- config$namespace info$commit_sha <- build_info$git_commit %||% "missing-sha" - info$code_version <- "missing-version" + info$code_version <- config$version %||% "missing-version" + info$image_url <- paste0( + "https://", + config$links$docker_registry, "/", + config$package_config$organization, "/", + config$package_config$name, "/", + gsub("src/", "", info$comp_path), + ":", + info$code_version + ) info$implementation_url <- paste0( build_info$git_remote, "/blob/", build_info$git_commit, "/", - info$config_path + info$comp_path ) + # Flatten references + if (!is.null(info$references) && info$references != "") { + info <- imap(info$references, function(value, key) { + info[[paste0("references_", key)]] <- value + return(info) + })[[1]] + } + info$references <- NULL # ↑ this could be used as the new format @@ -52,9 +69,11 @@ outputs <- map(configs, function(config) { metric_name = info$label, metric_summary = info$summary, metric_description = info$description, - paper_reference = info$reference %||% NA_character_, + references_doi = info$references_doi %||% NA_character_, + references_bibtex = info$references_bibtex %||% NA_character_, implementation_url = info$implementation_url %||% NA_character_, - code_version = NA_character_, + image = info$image_url %||% NA_character_, + code_version = info$code_version %||% NA_character_, commit_sha = info$commit_sha, maximize = info$maximize ) diff --git a/src/reporting/get_task_info/script.R b/src/reporting/get_task_info/script.R index d6096aae8..5e22fe485 100644 --- a/src/reporting/get_task_info/script.R +++ b/src/reporting/get_task_info/script.R @@ -15,7 +15,9 @@ info <- yaml::yaml.load_file(par$input) # construct v1 format repo <- - if ("name" %in% names(info) && "organization" %in% names(info)) { + if ("links" %in% names(info) && "repository" %in% names(info$links)) { + info$links$repository + } else if ("name" %in% names(info) && "organization" %in% names(info)) { paste0(info$organization, "/", info$name) } else { "openproblems-bio/openproblems" @@ -33,7 +35,10 @@ out <- list( task_summary = info$summary, task_description = description, repo = repo, - authors = info$authors + issue_tracker = info$links$issue_tracker %||% NA_character_, + authors = info$authors, + version = info$version, + license = info$license %||% NA_character_ ) # show warning when certain data is missing and return null?