Skip to content

Commit

Permalink
fixes #219
Browse files Browse the repository at this point in the history
  • Loading branch information
o-smirnov committed Feb 4, 2024
1 parent 7887d37 commit 1c5c78c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scabha/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class Parameter(object):
# list of aliases for this parameter (i.e. references to other parameters whose schemas/values this parameter shares)
aliases: Optional[List[str]] = ()

# if true, treat parameter as a path, and ensure that the parent directories it refers to exist
mkdir: bool = False
# if true, create parent directories of file-type outputs if needed
mkdir: bool = True

# if True, and parameter is a path, access to its parent directory is required
access_parent_dir: bool = False
Expand Down
16 changes: 12 additions & 4 deletions scabha/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,18 @@ def validate_parameters(params: Dict[str, Any], schemas: Dict[str, Any],
# check for mkdir directives
if create_dirs:
for name, value in validated.items():
if schemas[name].mkdir and isinstance(value, str):
dirname = os.path.dirname(value)
if dirname and not os.path.exists(dirname):
os.makedirs(dirname, exist_ok=True)
schema = schemas[name]
if schema.is_output and schema.mkdir:
if schema.is_file_type:
files = [value]
elif schema.is_filelist_type:
files = value
else:
continue
for path in files:
dirname = os.path.dirname(path)
if dirname and not os.path.exists(dirname):
os.makedirs(dirname, exist_ok=True)

# add in unresolved values
validated.update(**unresolved)
Expand Down

0 comments on commit 1c5c78c

Please sign in to comment.