From 167545b61daea3485a64b951b520dfa8e78f1d9c Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 8 Jul 2024 15:50:57 +1000 Subject: [PATCH 1/3] added 'method' option to upload script to pass through to XNATPy. can be used to avoid compressing directory uploads if uploading from a FS local to the XNAT instance --- xnat_ingest/cli/upload.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xnat_ingest/cli/upload.py b/xnat_ingest/cli/upload.py index b689191..a7e3d3a 100644 --- a/xnat_ingest/cli/upload.py +++ b/xnat_ingest/cli/upload.py @@ -181,6 +181,17 @@ "cluster and targeting the XNAT Tomcat directly" ), ) +@click.option( + "--method", + type=click.Choice(["per_file", "tar_memory", "tgz_memory", "tar_file", "tgz_file"]), + default="tgz_file", + envvar="XNAT_INGEST_UPLOAD_METHOD", + help=( + "The method to use to upload the files to XNAT. Passed through to XNATPy and controls " + "whether directories are tarred and/or gzipped before they are uploaded, by default " + "'tgz_file' is used" + ), +) def upload( staged: str, server: str, @@ -199,6 +210,7 @@ def upload( clean_up_older_than: int, verify_ssl: bool, use_curl_jsession: bool, + method: str, ): set_logger_handling( @@ -476,7 +488,7 @@ def iter_staged_sessions(): for fspath in scan.fspaths: xresource.upload(str(fspath), fspath.name) else: - xresource.upload_dir(scan.parent) + xresource.upload_dir(scan.parent, method=method) logger.debug("retrieving checksums for %s", xresource) remote_checksums = get_checksums(xresource) logger.debug("calculating checksums for %s", xresource) From 52b4cfe5c035cccce60fd942826a7526223c1106 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 8 Jul 2024 15:53:25 +1000 Subject: [PATCH 2/3] added 'tar_file' method to test_cli test --- xnat_ingest/tests/test_cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xnat_ingest/tests/test_cli.py b/xnat_ingest/tests/test_cli.py index 05b2d69..6aa6aac 100644 --- a/xnat_ingest/tests/test_cli.py +++ b/xnat_ingest/tests/test_cli.py @@ -202,6 +202,8 @@ def test_stage_and_upload( "--add-logger", "xnat", "--raise-errors", + "--method", + "tar_file", "--delete", "--xnat-login", "http://localhost:8080", From 36ede27c96fd69a71ff1baec4988f951f5d25242 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 8 Jul 2024 16:00:40 +1000 Subject: [PATCH 3/3] fixed test methods --- xnat_ingest/tests/test_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xnat_ingest/tests/test_cli.py b/xnat_ingest/tests/test_cli.py index 6aa6aac..ca717d5 100644 --- a/xnat_ingest/tests/test_cli.py +++ b/xnat_ingest/tests/test_cli.py @@ -202,8 +202,6 @@ def test_stage_and_upload( "--add-logger", "xnat", "--raise-errors", - "--method", - "tar_file", "--delete", "--xnat-login", "http://localhost:8080", @@ -226,6 +224,8 @@ def test_stage_and_upload( "--always-include", "medimage/dicom-series", "--raise-errors", + "--method", + "tar_file", "--use-curl-jsession", ], env={