-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from CBICA/publish-and-docker
Dockerfile recipe and PyPI publication workflow
- Loading branch information
Showing
3 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Upload Python Package | ||
|
||
on: workflow_dispatch | ||
|
||
permissions: | ||
contents: read | ||
id-token: write # Allow GitHub to mint tokens | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest # Can use macos-latest if needed | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install setuptools | ||
pip install twine | ||
pip install wheel | ||
sudo apt-get install jq | ||
- name: Clean previous builds | ||
run: rm -rf dist | ||
|
||
- name: Build package | ||
run: python setup.py sdist bdist_wheel | ||
|
||
- name: Publish package to PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: twine upload --repository-url https://upload.pypi.org/legacy/ dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
## Suggested pull command (run from anywhere): | ||
## CUDA_VERSION=11.8 docker pull cbica/nichart_dlmuse:1.0.1-cuda${CUDA_VERSION} | ||
## OR | ||
## docker pull cbica/nichart_dlmuse:1.0.1 | ||
|
||
## Suggested automatic inference run time command | ||
## Place input in /path/to/input/on/host. | ||
## Replace -d cuda with -d mps or -d cpu as needed, or don't pass at all to automatically use CUDA. | ||
## Each "/path/to/.../on/host" is a placeholder, use your actual paths! | ||
## docker run -it --name DLMUSE_inference --rm | ||
## --mount type=bind,source=/path/to/input/on/host,target=/input,readonly | ||
## --mount type=bind,source=/path/to/output/on/host,target=/output | ||
## --gpus all cbica/nichart_dlmuse:1.0.1 -d cuda | ||
|
||
## Suggested build command (run from the top-level repo directory): | ||
## CUDA_VERSION=11.8 docker build --build-arg CUDA_VERSION=${CUDA_VERSION} | ||
## -t cbica/nichart_dlmuse:1.0.1-cuda${CUDA_VERSION} . | ||
## OR | ||
## docker build -t cbica/nichart_dlmuse:1.0.1 . | ||
|
||
ARG NICHART_DLMUSE_VERSION="1.0.1" | ||
ARG CUDA_VERSION="11.8" | ||
ARG TORCH_VERSION="2.4.1" | ||
ARG CUDNN_VERSION="9" | ||
|
||
## This base image is generally the smallest with all prereqs. | ||
FROM pytorch/pytorch:${TORCH_VERSION}-cuda${CUDA_VERSION}-cudnn${CUDNN_VERSION}-runtime | ||
|
||
WORKDIR /app | ||
COPY . /app/ | ||
|
||
RUN pip install . | ||
RUN mkdir /dummyinput && mkdir /dummyoutput | ||
## Cache DLMUSE and DLICV models with an empty job so no download is needed later | ||
RUN DLMUSE -i /dummyinput -o /dummyoutput && DLICV -i /dummyinput -o /dummyoutput | ||
ENTRYPOINT ["NiChart_DLMUSE", "-i", "/input", "-o", "/output"] | ||
CMD ["-d", "cuda"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters