-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split source file into multople parts
- Loading branch information
1 parent
f2fd810
commit 8d45694
Showing
3 changed files
with
81 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#' Check of the required environment symbols | ||
#' | ||
#' @details the environment symbols from the analysis context should be | ||
#' set via the ``set_config`` function. | ||
#' | ||
const check_dependency.context_env = function(requires, context) { | ||
const env = context$configs; | ||
const map = { | ||
'any': "any", | ||
'numeric': "num", | ||
'integer': "int", | ||
'character': "chr", | ||
'logical': "logi", | ||
'function': "function" | ||
}; | ||
const env_symbols = names(env); | ||
const err = list( | ||
"environment_symbols(all)" = `[${paste(env_symbols, sep = ", ")}]` | ||
); | ||
|
||
for(name in names(requires)) { | ||
const mark = requires[[name]]; | ||
const missing = !(name in env); | ||
|
||
if (missing) { | ||
err[[name]] = "missing"; | ||
} else if (mark != "any") { | ||
if (map[[mark]] != typeof(env[[name]])) { | ||
err[[name]] = "mis-matched"; | ||
} | ||
} | ||
} | ||
|
||
if (length(err) <= 1) { | ||
NULL; | ||
} else { | ||
return(err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' Check for the upstream file dependency | ||
#' | ||
#' @param requires the required temp work files, should be a tuple list | ||
#' object that contains the app reference and the related temp workfile, | ||
#' example data format of this tuple list would be: | ||
#' | ||
#' list(app1 = [file1, file2, ...], app2 = file3, ...) | ||
#' | ||
#' @details the workfile path in the ``requires`` tuple file list should be | ||
#' a relative file path which is relative to the app workdir | ||
#' | ||
const check_dependency.localfiles = function(requires, context) { | ||
const err = list(); | ||
const verbose = as.logical(getOption("verbose")); | ||
|
||
if (verbose) { | ||
print("checks for the required app dependency modules:"); | ||
print(names(requires)); | ||
|
||
str(requires); | ||
} | ||
|
||
for(appName in names(requires)) { | ||
# the required file in the requires list is a relative file | ||
# path which is relative to the app workspace | ||
# the full path will be combine in this for loop and then | ||
# test for work file is exists or not. | ||
const workdir = WorkflowRender::workspace(appName); | ||
const file_rels = requires[[appName]]; | ||
const checks = `${workdir}/${file_rels}` |> which(filename -> !file.exists(filename)); | ||
|
||
if (length(checks) > 0) { | ||
err[[appName]] = checks; | ||
} | ||
} | ||
|
||
if (length(err) == 0) { | ||
NULL; | ||
} else { | ||
return(err); | ||
} | ||
} |