Skip to content

Commit

Permalink
add --generate_config flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasu Jaganath committed Aug 23, 2024
1 parent a03bde6 commit 42ecf04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/sophios/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,33 @@
__version__ = _version.get_versions()['version']

parser = argparse.ArgumentParser(prog='main', description='Convert a high-level yaml workflow file to CWL.')
parser.add_argument('--yaml', type=str, required=('--generate_schemas' not in sys.argv),

parser.add_argument('--yaml', type=str,
required=(not ('--generate_config' in sys.argv or '--generate_schemas' in sys.argv)),
help='Yaml workflow file')
group_gen = parser.add_mutually_exclusive_group()
group_gen.add_argument('--generate_schemas', default=False, action="store_true",
help='Generate schemas for the files in config.json (search_paths_wic and search_paths_cwl)')
group_gen.add_argument('--generate_config', default=False, action="store_true",
help='''Generate default config in wic/global_config.json
with default search_paths_wic and search_paths_cwl''')
parser.add_argument('--inputs_file', type=str, required=False, default='',
help='Additional inputs Yaml file')
parser.add_argument('--config_file', type=str, required=False, default=str(Path().home()/'wic'/'global_config.json'),
help='User provided (JSON) config file')
# version action exits the parser Ref : https://github.com/python/cpython/blob/1f515e8a109204f7399d85b7fd806135166422d9/Lib/argparse.py#L1167
# version action exits the parser
# Ref : https://github.com/python/cpython/blob/1f515e8a109204f7399d85b7fd806135166422d9/Lib/argparse.py#L1167
parser.add_argument('--version', action='version', version=__version__,
default='==SUPPRESS==', help='Current version of the Workflow Inference Compiler')
parser.add_argument('--generate_schemas', default=False, action="store_true",
help='Generate schemas for the files in config.json (search_paths_wic and search_paths_cwl)')
parser.add_argument('--homedir', type=str, required=False, default=str(Path().home()),
help='The users home directory. This is necessary because CWL clears environment variables (e.g. HOME)')
help='''The users home directory.
This is necessary because CWL clears environment variables (e.g. HOME)''')
parser.add_argument('--insert_steps_automatically', default=False, action="store_true",
help='''Attempt to fix inference failures by speculatively
inserting workflow steps from a curated whitelist.''')
parser.add_argument('--no_provenance', default=False, action="store_true",
help='Do not use the --provenance feature of CWL. (You should only disable provenance if absolutely necessary.)')
help='''Do not use the --provenance feature of CWL.
(You should only disable provenance if absolutely necessary.)''')
parser.add_argument('--copy_output_files', default=False, action="store_true",
help='Copies output files from the cachedir to outdir/ (automatically enabled with --run_local)')
parser.add_argument('--inline_cwl_runtag', default=False, action="store_true",
Expand Down
9 changes: 9 additions & 0 deletions src/sophios/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ def main() -> None:

# User may specify a different homedir
default_config_file = Path(args.homedir)/'wic'/'global_config.json'
if args.generate_config:
if default_config_file.exists():
print(f'Config already exists. To overwrite delete {default_config_file.parent} directory. Exiting')
else:
basic_config = io.get_basic_config()
io.write_config_to_disk(basic_config, default_config_file)
io.move_adapters_and_examples(basic_config)
print('Finished generating config. Exiting.')
sys.exit(0)
global_config: Json = io.get_config(Path(args.config_file), default_config_file)

tools_cwl = plugins.get_tools_cwl(global_config,
Expand Down

0 comments on commit 42ecf04

Please sign in to comment.