Skip to content

Commit

Permalink
fix docs functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Aug 21, 2024
1 parent bcf045c commit bc8e9ad
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/r/openproblems.docs/R/read_component_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ read_component_spec <- function(path) {

tryCatch(
{
validate_object(spec_yaml, obj_source = file, what = "api_component_spec")
validate_object(spec_yaml, obj_source = path, what = "api_component_spec")
},
error = function(e) {
cli::cli_warn(paste0("Component spec validation failed: ", e$message))
Expand Down
4 changes: 2 additions & 2 deletions packages/r/openproblems.docs/R/read_file_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' This function reads a file format spec from a yaml file.
#'
#' @param path Path to a file format yaml, usually in `src/api/file_*.yaml`
#' @return A list with file format info and slots/columns
#' @return A list with file format info and expected_format
#'
#' @export
#' @examples
Expand All @@ -18,7 +18,7 @@ read_file_format <- function(path) {

tryCatch(
{
validate_object(spec, obj_source = file, what = "api_file_format")
validate_object(spec, obj_source = path, what = "api_file_format")
},
error = function(e) {
cli::cli_warn(paste0("File format validation failed: ", e$message))
Expand Down
12 changes: 6 additions & 6 deletions packages/r/openproblems.docs/R/read_task_config.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#' Read project config
#'
#' @param file Path to a project config file
#' @param path Path to a project config file
#'
#' @importFrom cli cli_inform
#' @importFrom openproblems.utils validate_object
#'
#' @export
#'
#' @examples
#' file <- system.file(
#' path <- system.file(
#' "extdata", "example_project", "_viash.yaml",
#' package = "openproblems.docs"
#' )
#'
#' read_task_config(file)
read_task_config <- function(file) {
proj_conf <- openproblems::read_nested_yaml(file)
#' read_task_config(path)
read_task_config <- function(path) {
proj_conf <- openproblems::read_nested_yaml(path)

tryCatch(
{
validate_object(proj_conf, obj_source = file, what = "task_config")
validate_object(proj_conf, obj_source = path, what = "task_config")
},
error = function(e) {
cli::cli_warn(paste0("Project config validation failed: ", e$message))
Expand Down
12 changes: 4 additions & 8 deletions packages/r/openproblems.docs/R/read_task_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,17 @@ read_task_metadata <- function(path) {
proj_conf <- read_task_config(proj_conf_file)

cli::cli_inform("Reading component yamls")
comp_yamls <- list.files(path, pattern = "comp_.*\\.ya?ml", full.names = TRUE)
comp_yamls <- list.files(path, pattern = "comp_[a-zA-Z0-9_\\-]*\\.ya?ml", full.names = TRUE, recursive = TRUE)
comps <- map(comp_yamls, read_component_spec)
comp_info <- map_dfr(comps, "info")
comp_args <- map_dfr(comps, "args")
names(comps) <- comp_info$file_name

cli::cli_inform("Reading file yamls")
file_yamls <- openproblems:::resolve_path(
path = na.omit(unique(comp_args$`__merge__`)),
project_path = project_path,
parent_path = path
)
file_yamls <- list.files(path, pattern = "file_[a-zA-Z0-9_\\-]*\\.ya?ml", full.names = TRUE, recursive = TRUE)
files <- map(file_yamls, read_file_format)
file_info <- map_dfr(files, "info")
file_slots <- map_dfr(files, "slots")
file_expected_format <- map_dfr(files, "expected_format")
names(files) <- file_info$file_name

cli::cli_inform("Generating task graph")
Expand All @@ -58,7 +54,7 @@ read_task_metadata <- function(path) {
proj_conf = proj_conf,
files = files,
file_info = file_info,
file_slots = file_slots,
file_expected_format = file_expected_format,
comps = comps,
comp_info = comp_info,
comp_args = comp_args,
Expand Down
2 changes: 1 addition & 1 deletion packages/r/openproblems.docs/man/read_file_format.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/r/openproblems.docs/man/read_task_config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/r/openproblems.utils/R/validate_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ validate_object <- function(
"task_metric"
),
obj_source = NULL,
engine = c("imjv", "ajv"),
engine = c("ajv", "imjv"),
error = TRUE) {
what <- match.arg(what)
engine <- match.arg(engine)
Expand Down
2 changes: 1 addition & 1 deletion packages/r/openproblems.utils/man/validate_object.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc8e9ad

Please sign in to comment.