Skip to content

Commit

Permalink
fixed up datatype option for stage
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Oct 1, 2024
1 parent 522819b commit 9bd2c84
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
50 changes: 25 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
exclude: ^(arcana/_version\.py|versioneer\.py)$
args:
- -l 88
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
exclude: ^(xnat_checks/_version\.py|versioneer\.py)$
args:
- --ignore-words=.codespell-ignorewords
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
exclude: ^(arcana/_version\.py|versioneer\.py)$
args:
- -l 88
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
exclude: ^(xnat_checks/_version\.py|versioneer\.py)$
args:
- --ignore-words=.codespell-ignorewords
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
23 changes: 23 additions & 0 deletions scripts/get_pet_tst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import tempfile
from pathlib import Path
from fileformats.medimage import DicomSeries
from medimages4tests.dummy.dicom.pet.wholebody.siemens.biograph_vision.vr20b import ( # type: ignore[import-untyped]
get_image as get_pet_image,
)


tmp_path = Path(tempfile.mkdtemp())

series = DicomSeries(
get_pet_image(
tmp_path,
first_name="first",
last_name="last",
StudyInstanceUID="StudyInstanceUID",
PatientID="PatientID",
AccessionNumber="AccessionNumber",
StudyID="xnat_project",
).iterdir()
)

print(series.metadata["StudyID"])
2 changes: 1 addition & 1 deletion xnat_ingest/cli/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def stage(
additional_loggers=additional_loggers,
)
datatypes: list[ty.Type[FileSet]]
if datatype is None:
if not datatype:
datatypes = [DicomSeries]
else:
datatypes = [FileSet.from_mime(dt) for dt in datatype] # type: ignore[misc]

Check warning on line 293 in xnat_ingest/cli/stage.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/cli/stage.py#L293

Added line #L293 was not covered by tests
Expand Down
5 changes: 3 additions & 2 deletions xnat_ingest/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ def get_id(field_type: str, field_name: str) -> str:
)
else:
raise ImagingSessionParseError(

Check warning on line 359 in xnat_ingest/session.py

View check run for this annotation

Codecov / codecov/patch

xnat_ingest/session.py#L359

Added line #L359 was not covered by tests
f"Did not find '{field_name}' field in {resource}, "
"cannot uniquely identify the resource"
f"Did not find '{field_name}' field in {resource!r}, "
"cannot uniquely identify the resource, found:\n"
+ "\n".join(resource.metadata)
)
if index is not None:
value = value[index]
Expand Down

0 comments on commit 9bd2c84

Please sign in to comment.