Skip to content

Commit

Permalink
Merge pull request #116 from jjjermiah/main
Browse files Browse the repository at this point in the history
merge w main
  • Loading branch information
jjjermiah committed Feb 19, 2024
2 parents 7cf41c4 + f053d10 commit 4f79f98
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 45 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:

Build-Documentation:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/docs'
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -362,33 +361,3 @@ jobs:
# No changes
echo "No changes found. Nothing to commit or push."
fi
# # git add README.md

# # git commit -m "Update README with latest version"
# # git push


# #!/bin/bash

# # Check for changes
# if [[ $(git status --porcelain) ]]; then
# # Changes are present
# echo "Changes found. Committing and pushing..."

# # Add all changes
# git add .

# # Commit with a timestamp
# git commit -m "Auto commit: $(date)"

# # Push changes to the remote repository
# git push origin <your-branch-name>

# echo "Changes committed and pushed successfully."
# else
# # No changes
# echo "No changes found. Nothing to commit or push."
# fi
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ LABEL license="MIT"
LABEL usage="docker run -it --rm <image_name> NBIAToolkit --help"
LABEL org.opencontainers.image.source="github.com/jjjermiah/nbiatoolkit"

# install the dependencies
# copy current directory to /nbiatoolkit
COPY . /nbiatoolkit

# set working directory
WORKDIR /nbiatoolkit

# install nbiatoolkit
RUN pip install --upgrade pip
RUN python -m pip install nbiatoolkit
RUN pip install .

RUN NBIAToolkit --help

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ For quick access to the NBIA, the toolkit also provides a command line interface

``` bash NBIAToolkit-Output
> NBIAToolkit --version
_ ______ _______ ______ ____ _ __
_ ______ _______ ______ ____ _ __
/ | / / __ )/ _/ |/_ __/___ ____ / / /__(_) /_
/ |/ / __ |/ // /| | / / / __ \/ __ \/ / //_/ / __/
/ /| / /_/ // // ___ |/ / / /_/ / /_/ / / ,< / / /_
/_/ |_/_____/___/_/ |_/_/ \____/\____/_/_/|_/_/\__/
/ /| / /_/ // // ___ |/ / / /_/ / /_/ / / ,< / / /_
/_/ |_/_____/___/_/ |_/_/ \____/\____/_/_/|_/_/\__/


Version: 0.32.0

Version: 0.29.2

Available CLI tools:
Available CLI tools:

getCollections [-h] [-u USERNAME] [-pw PASSWORD] [-p PREFIX]
[-o OUTPUTFILE] [--version]
Expand Down
55 changes: 55 additions & 0 deletions docs/markdowns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,65 @@



## v0.32.0 (2024-02-18)

### Chore

* chore: Update README: 0.31.0 ([`799667e`](https://github.com/jjjermiah/nbia-toolkit/commit/799667ed8eaad93dafe751ab170a2f4f96a4dc36))

### Feature

* feat: Refactor workflows and update test case ([`e111fb2`](https://github.com/jjjermiah/nbia-toolkit/commit/e111fb28e35084891f5551f264e0ab707441fd88))

* feat: refactor return_type test ([`f2058e8`](https://github.com/jjjermiah/nbia-toolkit/commit/f2058e8f259ed5e2250f20ca08b556883449f399))


## v0.31.0 (2024-02-18)

### Build

* build: docker build ([`fc6fd28`](https://github.com/jjjermiah/nbia-toolkit/commit/fc6fd28ad815b904648dbcd7ddc8bba4cc15e4eb))

### Chore

* chore(sem-ver): 0.31.0 ([`f8b2253`](https://github.com/jjjermiah/nbia-toolkit/commit/f8b2253d948a9bdc4f42a94e38b7751ba37d4b5d))

* chore: Update README: 0.30.1 ([`ec7c9d3`](https://github.com/jjjermiah/nbia-toolkit/commit/ec7c9d38eeb602353c83c54664b0e60baef55d22))

### Feature

* feat: Update version to 0.31.1 and upgrade pip ([`12c5018`](https://github.com/jjjermiah/nbia-toolkit/commit/12c501883b91a2ef26b12866c75a6047c53e2103))

### Fix

* fix: ci ([`2f52670`](https://github.com/jjjermiah/nbia-toolkit/commit/2f526705a2814f26fb73f38f80cdf76e8838c28f))


## v0.30.1 (2024-02-18)

### Chore

* chore(sem-ver): 0.30.1 ([`b4ef0c7`](https://github.com/jjjermiah/nbia-toolkit/commit/b4ef0c7b096fb1953cd683381fa490a5fdf6cba3))

### Fix

* fix: Fix import statements in nbia.py and nbia_cli.py ([`14816f1`](https://github.com/jjjermiah/nbia-toolkit/commit/14816f162ba309de82daacb2c0a765d6fb753c99))

### Unknown

* Merge pull request #111 from jjjermiah/development

fix cli ([`b044404`](https://github.com/jjjermiah/nbia-toolkit/commit/b04440409480749f45522f57274baf4cd0da6205))

* Merge remote-tracking branch &#39;origin&#39; into development ([`7cf41c4`](https://github.com/jjjermiah/nbia-toolkit/commit/7cf41c4d41fedf3cd5d37e9e5ef952a80bbe9e36))


## v0.30.0 (2024-02-18)

### Chore

* chore(sem-ver): 0.30.0 ([`aae2d61`](https://github.com/jjjermiah/nbia-toolkit/commit/aae2d6197b1f6e7ded7413814788a4bd109584f1))

* chore: Update README: 0.29.2 ([`c7d69ec`](https://github.com/jjjermiah/nbia-toolkit/commit/c7d69ec58df0faf15b8645a74d6332848c2356f5))

### Ci
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nbiatoolkit"
version = "0.30.0"
version = "0.32.0"
description = "A python package to query the National Biomedical Imaging Archive (NBIA) database."
authors = ["Jermiah Joseph"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions src/nbiatoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
"NBIA_ENDPOINTS",
"version",
"__version__",
"downloadSingleSeries",
]
1 change: 1 addition & 0 deletions src/nbiatoolkit/dicomsort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# "setup_logger",
# "NBIA_ENDPOINTS",
# "validateMD5"

# ]

from .dicomsort import DICOMSorter
Expand Down
2 changes: 1 addition & 1 deletion src/nbiatoolkit/nbia.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from datetime import datetime

# set __version__ variable
__version__ = "0.30.0"
__version__ = "0.32.0"


# function that takes a list of dictionaries and returns either a list or a dataframe
Expand Down
41 changes: 38 additions & 3 deletions tests/test_downloadSeries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from src.nbiatoolkit import NBIAClient
from sqlalchemy import over
from src.nbiatoolkit import NBIAClient, downloadSingleSeries
from tempfile import TemporaryDirectory
import os

Expand All @@ -9,8 +10,13 @@ def nbia_client():
return NBIAClient()


def test_downloadSeries(nbia_client):
seriesList = nbia_client.getSeries(Collection="NSCLC-Radiomics")
@pytest.fixture
def series_list(nbia_client):
return nbia_client.getSeries(Collection="NSCLC-Radiomics")


def test_downloadSeries(nbia_client, series_list):
seriesList = series_list
filePattern = (
"%PatientID/%Modality-%SeriesNumber-%SeriesInstanceUID/%InstanceNumber.dcm"
)
Expand All @@ -32,3 +38,32 @@ def test_downloadSeries(nbia_client):
assert len(modality_dir) == 1
assert modality_dir[0].startswith("CT")
assert os.path.isdir(os.path.join(tempdir, dir[0], modality_dir[0]))


def test_downloadSingleSeries(nbia_client, series_list):
seriesList = series_list
filePattern = (
"%PatientID/%Modality-%SeriesNumber-%SeriesInstanceUID/%InstanceNumber.dcm"
)
# create a temporary directory

with TemporaryDirectory() as tempdir:

downloadSingleSeries(
SeriesInstanceUID=seriesList[0]["SeriesInstanceUID"],
downloadDir=tempdir,
filePattern=filePattern,
overwrite=True,
api_headers=nbia_client.headers,
base_url=nbia_client.base_url,
log=nbia_client.logger,
)
dir = os.listdir(tempdir)

assert len(dir) == 1
assert os.path.isdir(os.path.join(tempdir, dir[0]))

modality_dir = os.listdir(os.path.join(tempdir, dir[0]))
assert len(modality_dir) == 1
assert modality_dir[0].startswith("CT")
assert os.path.isdir(os.path.join(tempdir, dir[0], modality_dir[0]))
17 changes: 16 additions & 1 deletion tests/test_new_query_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from src.nbiatoolkit import NBIAClient
from src.nbiatoolkit.auth import OAuth2
from src.nbiatoolkit.utils import *
from src.nbiatoolkit.logger import setup_logger
import pandas as pd


Expand All @@ -12,6 +13,12 @@ def nbia_client():
return nbia_client


@pytest.fixture(scope="session")
def nbia_client2():
nbia_client = NBIAClient(log_level="DEBUG")
return nbia_client


@pytest.fixture(scope="session")
def tcga_patients(nbia_client):

Expand All @@ -20,7 +27,8 @@ def tcga_patients(nbia_client):
return tcga_patients


def test_nbia_properties(nbia_client):
def test_nbia_properties(nbia_client2):
nbia_client = nbia_client2
assert isinstance(nbia_client.OAuth_client, OAuth2)
assert isinstance(nbia_client.headers, dict)
assert "Authorization" in nbia_client.headers.keys()
Expand All @@ -31,6 +39,13 @@ def test_nbia_properties(nbia_client):

assert nbia_client.logger is not None

nbia_client.logger = setup_logger(
name="NBIAClient", log_level="INFO", console_logging=True, log_file=None
)

assert nbia_client.return_type == "list"
nbia_client.return_type = "dataframe"


def test_tcga_collection_description(nbia_client: NBIAClient):
tcga_collection_description_df = nbia_client.getCollectionDescriptions(
Expand Down

0 comments on commit 4f79f98

Please sign in to comment.