Skip to content

Commit

Permalink
Update how dashboard handles missing validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
afwillia committed Feb 21, 2024
1 parent 3e28afb commit 25d9056
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions functions/dashboardFuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ validate_metadata <- function(metadata, project.scope, schematic_api, schema_url
access_token = access_token,
file_name = manifest$Path)
)
if (!inherits(validation_res, "try-error")) {
# clean validation res from schematicpy
if (!length(validation_res) == 2) {
validation_res <- list(list(
Expand All @@ -204,21 +203,21 @@ validate_metadata <- function(metadata, project.scope, schematic_api, schema_url
Result = clean_res$result,
# change wrong schema to out-of-date type
ErrorType = if_else(clean_res$error_type == "Wrong Schema", "Out of Date", clean_res$error_type),
errorMsg = if_else(is.null(clean_res$error_msg[1]), "Valid", paste(clean_res$error_msg[1], collapse="; ")),
WarnMsg = if_else(is.null(clean_res$warning_msg[1]), "Valid", paste(clean_res$warning_msg[1], collapse = "; "))
errorMsg = if_else(is.na(clean_res$error_msg[1]), "Valid", paste(clean_res$error_msg[1], collapse="; ")),
WarnMsg = if_else(is.na(clean_res$warning_msg[1]), "Valid", paste(clean_res$warning_msg[1], collapse = "; "))
)
} else {
data.frame(
Result = "Fail",
# change wrong schema to out-of-date type
ErrorType = "Unknown Error",
errorMsg = "Server Error",
WarnMsg = " "
)
}
#} else {
# data.frame(
# Result = "Fail",
# # change wrong schema to out-of-date type
# ErrorType = "Unknown Error",
# errorMsg = "Server Error",
# WarnMsg = " "
# )
#}

}
}, mc.cores = ncores)
}, mc.cores = 1)
m2 <- bind_rows(m2)
cbind(metadata, m2) # expand metadata with validation results
}
Expand All @@ -241,7 +240,6 @@ get_schema_nodes <- function(schema, schematic_api, url, schema_url) {
return(list())
}
)
if ("status" %in% names(requirement)) return(schema=as.character(schema))
if (length(requirement) == 0) {
# return data type itself without name
return(schema=as.character(schema))
Expand All @@ -261,8 +259,8 @@ get_metadata_nodes <- function(metadata, ncores = 1, schematic_api,
if (nrow(metadata) == 0) {
return(data.frame(from = NA, to = NA, folder = NA, folderSynId = NA, nMiss = NA))
} else {
mn <- parallel::mclapply(1:nrow(metadata), function(i) {
manifest <- metadata[i, ]
mn <- parallel::mclapply(1:nrow(metadata), function(n) {
manifest <- metadata[n, ]
# get all required data types
nodes <- tryCatch(
switch(schematic_api,
Expand All @@ -275,11 +273,9 @@ get_metadata_nodes <- function(metadata, ncores = 1, schematic_api,
),
error = function(e) {
warning("'get_metadata_nodes' failed: ", sQuote(manifest$Component), ":\n", e$message)
cat(paste0("'get_metadata_nodes' failed: ", sQuote(manifest$Component), ":\n", e$message))
return(list())
}
)
if ("status" %in% names(nodes)) nodes <- list()
nodes <- list2Vector(nodes)
source <- as.character(nodes)
target <- names(nodes)
Expand Down

0 comments on commit 25d9056

Please sign in to comment.