Skip to content

Commit

Permalink
Fix several bugs:
Browse files Browse the repository at this point in the history
- handling relative pipeline interfaces
- handling null metadata attributes
  • Loading branch information
nsheff committed Jun 18, 2018
1 parent 9978f4e commit 958f3c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions R/constants.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
kOldPipelinesSection = "pipelines_dir"
kRelativeMetadataSections = c("output_dir", kOldPipelinesSection,
"pipeline_interfaces", "results_subdir", "submission_subdir")
kRelativeToOutputDirMetadataSections = c("results_subdir", "submission_subdir")

kRelativeToConfigSections = c("metadata", "pipeline_config")

4 changes: 2 additions & 2 deletions R/loadConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ makeMetadataSectionAbsolute = function(config, parent) {
for (metadataAttribute in names(config$metadata)) {
value = config$metadata[[metadataAttribute]]

if (metadataAttribute %in% kRelativeMetadataSections) {
if (metadataAttribute %in% kRelativeToOutputDirMetadataSections) {
if (metadataAttribute == kOldPipelinesSection) {
warning(sprintf(
"Config contains old pipeline location specification section: '%s'",
Expand All @@ -194,7 +194,7 @@ makeMetadataSectionAbsolute = function(config, parent) {
else { value = absViaParent(value) } # No special handling

# Check for and warn about nonexistent path before setting value.
if (!(file.exists(value) | dir.exists(value))) {
if (!(!.isDefined(value) || file.exists(value) || dir.exists(value))) {
warning(sprintf("Value for '%s' doesn't exist: '%s'", metadataAttribute, value))
}
absoluteMetadata[[metadataAttribute]] = value
Expand Down
6 changes: 5 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
#' @return Target itself if already absolute, else target nested within parent.
.makeAbsPath = function(perhapsRelative, parent) {
if (!.isDefined(perhapsRelative)) { return(perhapsRelative)}
perhapsRelative = expandPath(perhapsRelative)
if (.isAbsolute(perhapsRelative)) {
abspath = perhapsRelative
} else {
Expand All @@ -19,7 +21,9 @@
return(abspath)
}

.isDefined = function(var) { ! (is.na(var) | is.null(var)) }
# Must test for is.null first, since is.na(NULL) returns a logical(0) which is
# not a boolean
.isDefined = function(var) { ! (is.null(var) || is.na(var)) }

# Filesystem utilities

Expand Down

0 comments on commit 958f3c6

Please sign in to comment.