From 786fc3a87dd53f19bde941870e8cc72e6c452704 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Fri, 15 Mar 2024 14:08:15 +1100 Subject: [PATCH] added prefixes to all env vars used in different cli tools --- xnat_ingest/cli/stage.py | 24 ++++++++++++------------ xnat_ingest/cli/transfer.py | 18 +++++++++--------- xnat_ingest/cli/upload.py | 27 ++++++++++++++------------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/xnat_ingest/cli/stage.py b/xnat_ingest/cli/stage.py index 33d3242..2540639 100644 --- a/xnat_ingest/cli/stage.py +++ b/xnat_ingest/cli/stage.py @@ -27,29 +27,29 @@ are uploaded to XNAT """, ) -@click.argument("dicoms_path", type=str, envvar="XNAT_INGEST_DICOMS_PATH") +@click.argument("dicoms_path", type=str, envvar="XNAT_INGEST_STAGE_DICOMS_PATH") @click.argument( - "staging_dir", type=click.Path(path_type=Path), envvar="XNAT_INGEST_STAGING_DIR" + "staging_dir", type=click.Path(path_type=Path), envvar="XNAT_INGEST_STAGE_DIR" ) @click.option( "--project-field", type=DicomField, default="StudyID", - envvar="XNAT_INGEST_PROJECT", + envvar="XNAT_INGEST_STAGE_PROJECT", help=("The keyword or tag of the DICOM field to extract the XNAT project ID from "), ) @click.option( "--subject-field", type=DicomField, default="PatientID", - envvar="XNAT_INGEST_SUBJECT", + envvar="XNAT_INGEST_STAGE_SUBJECT", help=("The keyword or tag of the DICOM field to extract the XNAT subject ID from "), ) @click.option( "--visit-field", type=DicomField, default="AccessionNumber", - envvar="XNAT_INGEST_SESSION", + envvar="XNAT_INGEST_STAGE_SESSION", help=( "The keyword or tag of the DICOM field to extract the XNAT imaging session ID from " ), @@ -65,7 +65,7 @@ type=AssociatedFiles.cli_type, nargs=2, default=None, - envvar="XNAT_INGEST_ASSOCIATED", + envvar="XNAT_INGEST_STAGE_ASSOCIATED", metavar=" ", help=( 'The "glob" arg is a glob pattern by which to detect associated files to be ' @@ -87,14 +87,14 @@ @click.option( "--delete/--dont-delete", default=False, - envvar="XNAT_INGEST_DELETE", + envvar="XNAT_INGEST_STAGE_DELETE", help="Whether to delete the session directories after they have been uploaded or not", ) @click.option( "--log-level", default="info", type=str, - envvar="XNAT_INGEST_LOGLEVEL", + envvar="XNAT_INGEST_STAGE_LOGLEVEL", help=("The level of the logging printed to stdout"), ) @click.option( @@ -103,7 +103,7 @@ type=LogFile.cli_type, nargs=2, metavar=" ", - envvar="XNAT_INGEST_LOGFILE", + envvar="XNAT_INGEST_STAGE_LOGFILE", help=( 'Location to write the output logs to, defaults to "upload-logs" in the ' "export directory" @@ -116,7 +116,7 @@ nargs=3, metavar="
", multiple=True, - envvar="XNAT_INGEST_LOGEMAIL", + envvar="XNAT_INGEST_STAGE_LOGEMAIL", help=( "Email(s) to send logs to. When provided in an environment variable, " "mail and log level are delimited by ',' and separate destinations by ';'" @@ -128,7 +128,7 @@ nargs=4, metavar=" ", default=None, - envvar="XNAT_INGEST_MAILSERVER", + envvar="XNAT_INGEST_STAGE_MAILSERVER", help=( "the mail server to send logger emails to. When provided in an environment variable, " "args are delimited by ';'" @@ -144,7 +144,7 @@ "--deidentify/--dont-deidentify", default=False, type=bool, - envvar="XNAT_INGEST_DEIDENTIFY", + envvar="XNAT_INGEST_STAGE_DEIDENTIFY", help="whether to deidentify the file names and DICOM metadata before staging", ) def stage( diff --git a/xnat_ingest/cli/transfer.py b/xnat_ingest/cli/transfer.py index 701e06f..61ea412 100644 --- a/xnat_ingest/cli/transfer.py +++ b/xnat_ingest/cli/transfer.py @@ -30,13 +30,13 @@ an SSH server. """, ) -@click.argument("staging_dir", type=str) -@click.argument("remote_store", type=str, envvar="XNAT_INGEST_REMOTE_STORE") +@click.argument("staging_dir", type=str, envvar="XNAT_INGEST_STAGE_DIR") +@click.argument("remote_store", type=str, envvar="XNAT_INGEST_TRANSFER_REMOTE_STORE") @click.option( "--store-credentials", type=click.Path(path_type=Path), metavar=" ", - envvar="XNAT_INGEST_STORE_CREDENTIALS", + envvar="XNAT_INGEST_TRANSFER_STORE_CREDENTIALS", default=None, nargs=2, help="Credentials to use to access of data stored in remote stores (e.g. AWS S3)", @@ -45,7 +45,7 @@ "--log-level", default="info", type=str, - envvar="XNAT_INGEST_LOGLEVEL", + envvar="XNAT_INGEST_TRANSFER_LOGLEVEL", help=("The level of the logging printed to stdout"), ) @click.option( @@ -54,7 +54,7 @@ type=LogFile.cli_type, nargs=2, metavar=" ", - envvar="XNAT_INGEST_LOGFILE", + envvar="XNAT_INGEST_TRANSFER_LOGFILE", help=( 'Location to write the output logs to, defaults to "upload-logs" in the ' "export directory" @@ -67,7 +67,7 @@ nargs=3, metavar="
", multiple=True, - envvar="XNAT_INGEST_LOGEMAIL", + envvar="XNAT_INGEST_TRANSFER_LOGEMAIL", help=( "Email(s) to send logs to. When provided in an environment variable, " "mail and log level are delimited by ',' and separate destinations by ';'" @@ -78,7 +78,7 @@ type=MailServer.cli_type, metavar=" ", default=None, - envvar="XNAT_INGEST_MAILSERVER", + envvar="XNAT_INGEST_TRANSFER_MAILSERVER", help=( "the mail server to send logger emails to. When provided in an environment variable, " "args are delimited by ';'" @@ -87,7 +87,7 @@ @click.option( "--delete/--dont-delete", default=False, - envvar="XNAT_INGEST_DELETE", + envvar="XNAT_INGEST_TRANSFER_DELETE", help="Whether to delete the session directories after they have been uploaded or not", ) @click.option( @@ -103,7 +103,7 @@ default=None, metavar=" ", help="The XNAT server to upload to plus the user and password to use", - envvar="XNAT_INGEST_XNAT_LOGIN", + envvar="XNAT_INGEST_TRANSFER_XNAT_LOGIN", ) def transfer( staging_dir: Path, diff --git a/xnat_ingest/cli/upload.py b/xnat_ingest/cli/upload.py index b217ce0..428001a 100644 --- a/xnat_ingest/cli/upload.py +++ b/xnat_ingest/cli/upload.py @@ -43,21 +43,21 @@ PASSWORD is the password for the XNAT user, alternatively "XNAT_INGEST_PASS" env. var """, ) -@click.argument("staged", type=str) -@click.argument("server", type=str, envvar="XNAT_INGEST_HOST") -@click.argument("user", type=str, envvar="XNAT_INGEST_USER") -@click.argument("password", type=str, envvar="XNAT_INGEST_PASS") +@click.argument("staged", type=str, envvar="XNAT_INGEST_UPLOAD_STAGED") +@click.argument("server", type=str, envvar="XNAT_INGEST_UPLOAD_HOST") +@click.argument("user", type=str, envvar="XNAT_INGEST_UPLOAD_USER") +@click.argument("password", type=str, envvar="XNAT_INGEST_UPLOAD_PASS") @click.option( "--delete/--dont-delete", default=True, - envvar="XNAT_INGEST_DELETE", + envvar="XNAT_INGEST_UPLOAD_DELETE", help="Whether to delete the session directories after they have been uploaded or not", ) @click.option( "--log-level", default="info", type=str, - envvar="XNAT_INGEST_LOGLEVEL", + envvar="XNAT_INGEST_UPLOAD_LOGLEVEL", help=("The level of the logging printed to stdout"), ) @click.option( @@ -66,7 +66,7 @@ type=LogFile.cli_type, nargs=2, metavar=" ", - envvar="XNAT_INGEST_LOGFILE", + envvar="XNAT_INGEST_UPLOAD_LOGFILE", help=( 'Location to write the output logs to, defaults to "upload-logs" in the ' "export directory" @@ -79,7 +79,7 @@ nargs=3, metavar="
", multiple=True, - envvar="XNAT_INGEST_LOGEMAIL", + envvar="XNAT_INGEST_UPLOAD_LOGEMAIL", help=( "Email(s) to send logs to. When provided in an environment variable, " "mail and log level are delimited by ',' and separate destinations by ';'" @@ -90,7 +90,7 @@ type=MailServer.cli_type, metavar=" ", default=None, - envvar="XNAT_INGEST_MAILSERVER", + envvar="XNAT_INGEST_UPLOAD_MAILSERVER", help=( "the mail server to send logger emails to. When provided in an environment variable, " "args are delimited by ';'" @@ -102,7 +102,7 @@ default=(), type=str, multiple=True, - envvar="XNAT_INGEST_ALWAYSINCLUDE", + envvar="XNAT_INGEST_UPLOAD_ALWAYSINCLUDE", help=( "Scan types to always include in the upload, regardless of whether they are" "specified in a column or not. Specified using the scan types IANA mime-type or " @@ -121,7 +121,7 @@ "--store-credentials", type=str, metavar=" ", - envvar="XNAT_INGEST_STORE_CREDENTIALS", + envvar="XNAT_INGEST_UPLOAD_STORE_CREDENTIALS", default=None, nargs=2, help="Credentials to use to access of data stored in remote stores (e.g. AWS S3)", @@ -130,13 +130,13 @@ "--temp-dir", type=Path, default=None, - envvar="XNAT_INGEST_WORKDIR", + envvar="XNAT_INGEST_UPLOAD_WORKDIR", help="The directory to use for temporary downloads (i.e. from s3)", ) @click.option( "--use-manifest/--dont-use-manifest", default=None, - envvar="XNAT_INGEST_REQUIRE_MANIFEST", + envvar="XNAT_INGEST_UPLOAD_REQUIRE_MANIFEST", help=( "Whether to use the manifest file in the staged sessions to load the " "directory structure. By default it is used if present and ignore if not there" @@ -147,6 +147,7 @@ "--clean-up-older-than", type=int, metavar="", + envvar="XNAT_INGEST_UPLOAD_CLEANUP_OLDER_THAN", default=0, help="The number of days to keep files in the remote store for", )