quartzbio.cli.main module¶
- class quartzbio.cli.main.KeyValueDictAppendAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)¶
Bases:
Actionargparse action to split an argument into KEY=VALUE form on the first = and append to a dictionary.
- class quartzbio.cli.main.QuartzBioArgumentParser(*args, **kwargs)¶
Bases:
ArgumentParserMain parser for the QuartzBio command line client.
- api_host_url(value)¶
- parse_quartzbio_args(args=None, namespace=None)¶
Try to parse the args first, and then add the subparsers. We want to do this so that we can check to see if there are any unknown args. We can assume that if, by this point, there are no unknown args, we can append shell to the unknown args as a default. However, to do this, we have to suppress stdout/stderr during the initial parsing, in case the user calls the help method (in which case we want to add the additional arguments and then call the help method. This is a hack to get around the fact that argparse doesn’t allow default subcommands.
- subcommands = {'create-dataset': {'arguments': [{'action': 'store_true', 'flags': '--create-vault', 'help': "Create the vault if it doesn't exist"}, {'flags': '--template-id', 'help': 'The template ID used when creating a new dataset (via --create-dataset)'}, {'flags': '--template-file', 'help': 'A local template file to be used when creating a new dataset (via --create-dataset)'}, {'default': 'small', 'flags': '--capacity', 'help': 'Specifies the capacity of the dataset: small (default, <100M records), medium (<500M), large (>=500M)'}, {'action': 'append', 'help': 'A tag to be added. Tags are case insensitive strings. Example tags: --tag GRCh38 --tag Tissue --tag "Foundation Medicine"', 'name': '--tag'}, {'action': <class 'quartzbio.cli.main.KeyValueDictAppendAction'>, 'help': 'Dataset metadata in the format KEY=VALUE ', 'metavar': 'KEY=VALUE', 'name': '--metadata', 'nargs': 1}, {'help': 'Metadata key value pairs in JSON format', 'name': '--metadata-json-file'}, {'action': 'store_true', 'flags': '--dry-run', 'help': 'Dry run mode will not create the dataset'}, {'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'help': 'The full path to the dataset in the format: "domain:vault:/path/dataset". Defaults to your personal vault if no vault is provided. Defaults to the vault root if no path is provided.', 'name': 'full_path'}], 'func': <function create_dataset>, 'help': 'Create a QuartzBio dataset'}, 'download': {'arguments': [{'action': 'store_true', 'flags': '--dry-run', 'help': 'Dry run mode will not download any files or create any folders. Use this mode before using the --delete flag.'}, {'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'flags': 'full_path', 'help': 'The full path to the files on QuartzBio. Supports Unix style globs in order to download multiple files. Note: Downloads are not recursive unless --recursive flag is used.'}, {'help': 'The path to the local directory where to download files.', 'name': 'local_path'}, {'action': 'store_true', 'flags': '--recursive', 'help': 'Downloads files recursively. Note that empty folders will be ignored.'}, {'action': 'append', 'flags': '--exclude', 'help': 'Pattern to match against local full paths of files to be excluded from downloading. This pattern is only used when --recursive is used. Unix shell-style wildcards are supported. Exclude patterns will always be superseded by include patterns.'}, {'action': 'append', 'flags': '--include', 'help': 'Pattern to match against full paths of files to be included for downloading. This pattern is only used when --recursive is used. Unix shell-style wildcards are supported. Include patterns will always supersede exclude patterns.'}, {'action': 'store_true', 'flags': '--delete', 'help': 'Deletes local files not found in remote full path. Warning, this is dangerous and will delete any files found in local path. Do not use a top-level local path such as "/" and always use the --dry-run mode to evaluate any changes. Empty folders will be deleted.'}, {'action': 'store_true', 'flags': '--follow-shortcuts', 'help': 'Resolves shortcuts when downloading. If a shortcut to a file is found the target file will be downloaded under the shortcut name.'}, {'default': None, 'flags': '--num-processes', 'help': "Number of downloads to process in parallel. If not specified downloads won't be executed in parallel.If a number less than 1 is set defaults to the number of system CPUs.", 'type': <class 'int'>}], 'func': <function download>, 'help': 'Download one or more files from a QuartzBio Vault.'}, 'import': {'arguments': [{'action': 'store_true', 'flags': '--create-vault', 'help': "Create the vault if it doesn't exist"}, {'action': 'store_true', 'flags': '--create-dataset', 'help': "Create the dataset if it doesn't exist"}, {'default': 'small', 'flags': '--capacity', 'help': 'Specifies the capacity of the created dataset: small (default, <100M records), medium (<500M), large (>=500M)'}, {'action': 'append', 'help': 'A tag to be added. Tags are case insensitive strings. Example tags: --tag GRCh38 --tag Tissue --tag "Foundation Medicine"', 'name': '--tag'}, {'action': <class 'quartzbio.cli.main.KeyValueDictAppendAction'>, 'help': 'Dataset metadata in the format KEY=VALUE ', 'metavar': 'KEY=VALUE', 'name': '--metadata', 'nargs': 1}, {'help': 'Metadata key value pairs in JSON format', 'name': '--metadata-json-file'}, {'flags': '--template-id', 'help': 'The template ID used when creating a new dataset (via --create-dataset)'}, {'flags': '--template-file', 'help': 'A local template file to be used when creating a new dataset (via --create-dataset)'}, {'action': 'store_true', 'default': False, 'flags': '--follow', 'help': "Follow the import's progress until it completes"}, {'default': 'append', 'flags': '--commit-mode', 'help': 'Commit mode to use when importing data. Options are "append" (default), "overwrite","upsert", or "delete"'}, {'action': 'store_true', 'default': False, 'flags': '--remote-source', 'help': 'File paths are remote globs or full paths on the QuartzBio file system.'}, {'action': 'store_true', 'flags': '--dry-run', 'help': 'Dry run mode will not create any datasets or import any files.'}, {'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'help': 'The full path to the dataset in the format: "domain:vault:/path/dataset". ', 'name': 'full_path'}, {'help': 'One or more files to import. Can be local files, folders, globs or remote URLs. Pass --remote-source in order to list remote full_paths or path globs on the QuartzBio file system.', 'name': 'file', 'nargs': '+'}], 'func': <function import_file>, 'help': 'Import a local file into a QuartzBio dataset'}, 'login': {'arguments': [{'action': 'store_true', 'default': False, 'flags': '--debug', 'help': 'Shows the source of the user credentials'}], 'func': <function login_and_save_credentials>, 'help': 'Login and save credentials'}, 'logout': {'func': <function logout>, 'help': 'Logout and delete saved credentials'}, 'ls': {'arguments': [{'action': 'store_true', 'flags': '--recursive', 'help': 'Recursively list the contents of subdirectories.'}, {'action': 'store_true', 'flags': '--follow-shortcuts', 'help': 'Resolves shortcuts when listing.'}, {'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'default': '~/', 'help': 'The full path where the files and folders should be listed from, defaults to the root of your personal vault', 'name': 'full_path'}], 'func': <function ls>, 'help': 'List files and directories in a QuartzBio Vault'}, 'queue': {'func': <function show_queue>, 'help': 'Shows the current job queue, grouped by User'}, 'shell': {'func': <function launch_ipython_shell>, 'help': 'Open the QuartzBio Python shell'}, 'tag': {'arguments': [{'flags': 'full_path', 'help': 'The full path of the files, folders or datasets to apply the tag updates. Unix shell-style wildcards are supported. ', 'nargs': '+'}, {'action': 'append', 'help': 'A tag to be added/removed. Files, folders and datasets can be tagged. Tags are case insensitive strings. Example tags: --tag GRCh38 --tag Tissue --tag "Foundation Medicine"', 'name': '--tag', 'required': True}, {'action': 'store_true', 'flags': '--remove', 'help': 'Will remove tags instead of adding them.'}, {'action': 'append', 'flags': '--exclude', 'help': 'Paths to files or folder to be excluded from tagging. Unix shell-style wildcards are supported.'}, {'action': 'store_true', 'flags': '--tag-folders-only', 'help': 'Will only apply tags to folders (tags all objects by default). '}, {'action': 'store_true', 'flags': '--tag-files-only', 'help': 'Will only apply tags to files (tags all objects by default). '}, {'action': 'store_true', 'flags': '--tag-datasets-only', 'help': 'Will only apply tags to datasets (tags all objects by default). '}, {'action': 'store_true', 'flags': '--dry-run', 'help': 'Dry run mode will not save tags.'}, {'action': 'store_true', 'flags': '--no-input', 'help': 'Automatically accept changes (overrides user prompt)'}], 'func': <function tag>, 'help': 'Apply tags or remove tags on objects'}, 'tutorial': {'func': <function print_tutorial>, 'help': 'Show the QuartzBio Python Tutorial'}, 'upload': {'arguments': [{'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'default': '~/', 'flags': '--full-path', 'help': 'The full path where the files and folders should be created, defaults to the root of your personal vault'}, {'default': 1, 'flags': '--num-processes', 'help': 'Number of uploads to process in parallel. Defaults to 1, but can be set much higher than CPU count since the upload process is IO bound, not CPU bound.', 'type': <class 'int'>}, {'action': 'store_true', 'flags': '--create-full-path', 'help': 'Creates --full-path location if it does not exist. NOTE: This will not create new vaults.'}, {'action': 'append', 'flags': '--exclude', 'help': 'Paths to files or folder to be excluded from upload. Unix shell-style wildcards are supported.'}, {'action': 'store_true', 'flags': '--dry-run', 'help': 'Dry run mode will not upload any files or create any folders.'}, {'action': <class 'quartzbio.cli.main.TildeFixStoreAction'>, 'flags': '--archive-folder', 'help': 'Path to archive files that already exist. If a folder is supplied, instead of overwriting or creating an incremented filename, the original remote file will be moved to this archive folder with a timestamp.'}, {'action': 'store_true', 'flags': '--follow-shortcuts', 'help': 'Resolves shortcuts when Uploading.'}, {'default': 3, 'flags': '--max-retries', 'help': 'Maximum number of retries per upload part for multipart uploads. Defaults to 3.', 'type': <class 'int'>}, {'help': 'The path to the local file or directory to upload', 'name': 'local_path', 'nargs': '+'}], 'func': <function upload>, 'help': 'Upload a file or directory to a QuartzBio Vault'}, 'whoami': {'func': <function whoami>, 'help': 'Show your QuartzBio email address'}}¶
- class quartzbio.cli.main.TildeFixStoreAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None, deprecated=False)¶
Bases:
_StoreActionA special “store” action for argparse that replaces any detected home directory with a tilde. (reverses bash’s built-in ~ expansion).
- quartzbio.cli.main.main()¶
Main entry point for QuartzBio CLI