Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workflow/create_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def input_args():
'-y', '--yaml', help='full path to yaml file describing the experiment configuration', type=Path, required=True)
parser.add_argument(
'-o', '--overwrite', help='overwrite previously created experiment', action="store_true", required=False)
parser.add_argument('--force', help='raise warnings instead of errors when possible',
action='store_true', dest="force")

return parser.parse_args()

Expand Down Expand Up @@ -103,6 +105,9 @@ def input_args():

setup_xml_args = [str(experiment_dir)]

if user_inputs.force:
setup_xml_args.append("--force")

logger.info(f"Call: setup_xml.main()")
logger.debug(f"setup_xml.py {' '.join(setup_xml_args)}")
setup_xml.main(setup_xml_args)
12 changes: 7 additions & 5 deletions workflow/setup_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def input_args(*argv):
default=25, required=False)
parser.add_argument('--verbosity', help='verbosity level of Rocoto', type=int,
default=10, required=False)
parser.add_argument('--force', help='raise warnings instead of errors when possible',
action='store_true', dest="force")

return parser.parse_args(argv[0][0] if len(argv[0]) else None)

Expand All @@ -54,15 +56,12 @@ def check_dir_writable(dirPath):
if os.access(dirPath, os.W_OK):
return True
else:
print(f"{dirPath} is unwritable.")
return False
elif os.path.isfile(dirPath):
print(f'{dirPath} is not a directory')
return False
else: # Find the nearest parent directory that already exists
test_parent = os.path.dirname(dirPath)
if len(test_parent) == 0:
print(f'{dirPath} is an invalid directory')
return False
while test_parent:
if os.path.exists(test_parent):
Expand All @@ -72,7 +71,6 @@ def check_dir_writable(dirPath):
if len(test_parent) == 0:
break
if len(test_parent) == 0:
print(f'{dirPath} is not a valid directory')
return False


Expand All @@ -95,7 +93,11 @@ def main(*argv):
for dk in dirKeys:
check_dir_writable(base[dk])
if not check_dir_writable(base[dk]):
raise PermissionError(f'The {dk} path {base[dk]} cannot be written to! Please correct this path and try again')
msg = f'The {dk} path {base[dk]} cannot be written to! Please correct this path and try again.'
if user_inputs.force:
print(f"WARNING {msg}")
else:
raise PermissionError(f'{msg}')

net = base['NET']
mode = base['MODE']
Expand Down