From c0eedb39365a7d3fdd646f967922b67acc948cae Mon Sep 17 00:00:00 2001 From: Tom Close Date: Tue, 6 Aug 2024 18:58:25 +1000 Subject: [PATCH 1/4] added dynamic available datasets to add-data help string --- xnat4tests/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xnat4tests/cli.py b/xnat4tests/cli.py index 5081a8d..2364285 100644 --- a/xnat4tests/cli.py +++ b/xnat4tests/cli.py @@ -139,9 +139,9 @@ def restart_cli(ctx, loglevel): @cli.command( name="add-data", - help="""Adds sample data to the XNAT instance + help=f"""Adds sample data to the XNAT instance -DATASET is the name of the dataset to add (out of ['dummydicom'])""", +DATASET is the name of the dataset to add (out of {AVAILABLE_DATASETS})""", ) @click.argument("dataset", type=click.Choice(AVAILABLE_DATASETS)) @click.option( From 7d8f43074feb36a39a660decd644f9bb0d5768a2 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 10 Oct 2024 23:21:44 +1100 Subject: [PATCH 2/4] lazily import medimages4tests to speed up cases where it isn't required --- xnat4tests/data.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/xnat4tests/data.py b/xnat4tests/data.py index 7c0a7bd..9306bfd 100644 --- a/xnat4tests/data.py +++ b/xnat4tests/data.py @@ -6,16 +6,6 @@ from contextlib import contextmanager from pathlib import Path from xnat.exceptions import XNATResponseError -from medimages4tests.dummy.dicom.mri.t1w.siemens.skyra.syngo_d13c import ( - get_image as t1w_syngo, -) -from medimages4tests.dummy.dicom.mri.dwi.siemens.skyra.syngo_d13c import ( - get_image as dwi_syngo, -) -from medimages4tests.dummy.dicom.mri.fmap.siemens.skyra.syngo_d13c import ( - get_image as fmap_syngo, -) -from medimages4tests.mri.neuro.t1w import get_image as openneuro_t1w from .base import connect from .config import Config from .utils import logger @@ -64,6 +54,15 @@ def add_data(dataset: str, config_name: str or dict = "default"): ) if dataset == "dummydicom": + from medimages4tests.dummy.dicom.mri.t1w.siemens.skyra.syngo_d13c import ( + get_image as t1w_syngo, + ) + from medimages4tests.dummy.dicom.mri.dwi.siemens.skyra.syngo_d13c import ( + get_image as dwi_syngo, + ) + from medimages4tests.dummy.dicom.mri.fmap.siemens.skyra.syngo_d13c import ( + get_image as fmap_syngo, + ) _upload_dicom_data( [t1w_syngo(), dwi_syngo(), fmap_syngo()], @@ -74,6 +73,7 @@ def add_data(dataset: str, config_name: str or dict = "default"): ) elif dataset == "openneuro-t1w": + from medimages4tests.mri.neuro.t1w import get_image as openneuro_t1w _upload_directly( {"t1w": openneuro_t1w()}, @@ -119,6 +119,9 @@ def add_data(dataset: str, config_name: str or dict = "default"): ) elif dataset == "user-training": + from medimages4tests.dummy.dicom.mri.fmap.siemens.skyra.syngo_d13c import ( + get_image as fmap_syngo, + ) _upload_dicom_data( [t1w_syngo(), fmap_syngo()], From 5b2c11a1960f1f2ef0f718be8c103d3cd2b7eee6 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Wed, 16 Oct 2024 14:19:09 +1100 Subject: [PATCH 3/4] added type annotations --- xnat4tests/registry.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xnat4tests/registry.py b/xnat4tests/registry.py index 4148542..a72ce5d 100644 --- a/xnat4tests/registry.py +++ b/xnat4tests/registry.py @@ -1,10 +1,10 @@ -import docker +import docker.models.containers from .utils import logger from .config import Config from .base import docker_network, connect -def start_registry(config_name="default"): +def start_registry(config_name: str = "default") -> docker.models.containers.Container: config = Config.load(config_name) @@ -38,7 +38,7 @@ def start_registry(config_name="default"): return container -def stop_registry(config_name="default"): +def stop_registry(config_name: str = "default") -> None: config = Config.load(config_name) From f533e44a0e6191b07abb1287d283b26d4b5f5520 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 17 Oct 2024 09:17:48 +1100 Subject: [PATCH 4/4] formatting --- tests/test_base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_base.py b/tests/test_base.py index e84a3d4..ac7c84f 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -14,7 +14,9 @@ def test_launch(config, launched_xnat): login.put(f"/data/archive/projects/{PROJECT}") # Create subject - xsubject = login.classes.SubjectData(label=SUBJECT, parent=login.projects[PROJECT]) + xsubject = login.classes.SubjectData( + label=SUBJECT, parent=login.projects[PROJECT] + ) # Create session xsession = login.classes.MrSessionData(label=SESSION, parent=xsubject)