From 8bb60957fa57750ee7e0de3af1e6e88efab3d42b Mon Sep 17 00:00:00 2001 From: Alexander Harvey Nitz Date: Tue, 5 Dec 2023 20:22:23 -0500 Subject: [PATCH] demonstrate another part --- examples/workflow/quickstart/option_exe | 4 +++- examples/workflow/quickstart/simple.py | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/workflow/quickstart/option_exe b/examples/workflow/quickstart/option_exe index 5240088794e..388e0da6720 100755 --- a/examples/workflow/quickstart/option_exe +++ b/examples/workflow/quickstart/option_exe @@ -4,6 +4,7 @@ import argparse, shutil parser = argparse.ArgumentParser() parser.add_argument('--input-file') parser.add_argument('--output-file') +parser.add_argument("--append-count", type=int, default=1) parser.add_argument('--append-text', help='append this text to output file') args = parser.parse_args() @@ -11,4 +12,5 @@ shutil.copyfile(args.input_file, args.output_file) if args.append_text: with open(args.output_file, 'a') as f: - f.write(args.append_text) + for i in range(args.append_count): + f.write(args.append_text) diff --git a/examples/workflow/quickstart/simple.py b/examples/workflow/quickstart/simple.py index 76106493245..1dfa38e4fb5 100644 --- a/examples/workflow/quickstart/simple.py +++ b/examples/workflow/quickstart/simple.py @@ -9,7 +9,7 @@ # override parameters, or to choose if to plan or directly submit # the workflow parser = argparse.ArgumentParser(description=__doc__[1:]) -parser.add_argument('--verbose') +parser.add_argument('--verbose', action='count') wf.add_workflow_command_line_group(parser) wf.add_workflow_settings_cli(parser) args = parser.parse_args() @@ -48,7 +48,8 @@ # Create a file handle for the future *output* of this job. Every file in # a workflow must have a unique name. This also demonstrates making -# explicit file names. +# explicit file names and an explicit output folder. Typically, +# you may want to let the workflow decide these locations / names out1 = wf.File.from_path(os.path.abspath("test_output.txt")) # add the output file as the second argument of the executable @@ -70,6 +71,9 @@ # job in the workflow. This will automatically have the previous job # run first and then pass the file it creates along to the later job. node2.add_input_opt('--input-file', out1) + + # add an option with value + node2.add_opt('--append-count', str(i)) # add the output file as the second argument of the executable # The filename must be unique and is built from the executable name