Skip to content

Commit

Permalink
added prefixes to all env vars used in different cli tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 15, 2024
1 parent 424f822 commit 786fc3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
24 changes: 12 additions & 12 deletions xnat_ingest/cli/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
),
Expand All @@ -65,7 +65,7 @@
type=AssociatedFiles.cli_type,
nargs=2,
default=None,
envvar="XNAT_INGEST_ASSOCIATED",
envvar="XNAT_INGEST_STAGE_ASSOCIATED",
metavar="<glob> <id-pattern>",
help=(
'The "glob" arg is a glob pattern by which to detect associated files to be '
Expand All @@ -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(
Expand All @@ -103,7 +103,7 @@
type=LogFile.cli_type,
nargs=2,
metavar="<path> <loglevel>",
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"
Expand All @@ -116,7 +116,7 @@
nargs=3,
metavar="<address> <loglevel> <subject-preamble>",
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 ';'"
Expand All @@ -128,7 +128,7 @@
nargs=4,
metavar="<host> <sender-email> <user> <password>",
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 ';'"
Expand All @@ -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(
Expand Down
18 changes: 9 additions & 9 deletions xnat_ingest/cli/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="<access-key> <secret-key>",
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)",
Expand All @@ -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(
Expand All @@ -54,7 +54,7 @@
type=LogFile.cli_type,
nargs=2,
metavar="<path> <loglevel>",
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"
Expand All @@ -67,7 +67,7 @@
nargs=3,
metavar="<address> <loglevel> <subject-preamble>",
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 ';'"
Expand All @@ -78,7 +78,7 @@
type=MailServer.cli_type,
metavar="<host> <sender-email> <user> <password>",
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 ';'"
Expand All @@ -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(
Expand All @@ -103,7 +103,7 @@
default=None,
metavar="<host> <user> <password>",
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,
Expand Down
27 changes: 14 additions & 13 deletions xnat_ingest/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -66,7 +66,7 @@
type=LogFile.cli_type,
nargs=2,
metavar="<path> <loglevel>",
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"
Expand All @@ -79,7 +79,7 @@
nargs=3,
metavar="<address> <loglevel> <subject-preamble>",
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 ';'"
Expand All @@ -90,7 +90,7 @@
type=MailServer.cli_type,
metavar="<host> <sender-email> <user> <password>",
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 ';'"
Expand All @@ -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 "
Expand All @@ -121,7 +121,7 @@
"--store-credentials",
type=str,
metavar="<access-key> <secret-key>",
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)",
Expand All @@ -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"
Expand All @@ -147,6 +147,7 @@
"--clean-up-older-than",
type=int,
metavar="<days>",
envvar="XNAT_INGEST_UPLOAD_CLEANUP_OLDER_THAN",
default=0,
help="The number of days to keep files in the remote store for",
)
Expand Down

0 comments on commit 786fc3a

Please sign in to comment.