Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: automated package and publish of MAP #26

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/publish_map.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Workflow to publish TotalSegmentator-AIDE MAP on GHCR

name: Build and package MAP

on:
push:
branches: ['24_publish_map']

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.10' ]

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
pip install -r app/app_requirements.txt

- name: Display installed pip packages
run: |
pip list

- name: Free disk space
run: |
df -h
sudo swapoff -a
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo apt clean
docker rmi $(docker image ls -aq)
df -h

- name: Package MAP & test MAP end-to-end
run: |
monai-deploy package app --base nvcr.io/nvidia/pytorch:22.08-py3 --tag map-init:temp -l DEBUG
docker images
docker build --build-arg INIT_CONTAINER=map-init:temp -t map-final:temp app
docker images
monai-deploy run map tests/data/rtstructwriter/dcm tests/data/output
ls tests/data/output
if test -f "tests/data/output/output-rt-struct.dcm"; then echo "Output RT Struct exists."; fi
4 changes: 3 additions & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ARG INIT_CONTAINER

# Use initial MAP for build
FROM ghcr.io/gstt-csc/totalsegmentator-aide/map-init:0.1.2 AS build
FROM $INIT_CONTAINER AS build

# Add dcm2niix to MAP
WORKDIR /bin
Expand Down
6 changes: 6 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
# Tom Roberts ([email protected] / [email protected])

import logging
from pathlib import Path

import monai.deploy.core as md
from monai.deploy.core import Application, resource

from operators.dcm2nii_operator import Dcm2NiiOperator
from operators.rtstructwriter_operator import RTStructWriterOperator
from operators.totalsegmentator_operator import TotalSegmentatorOperator

requirements_file = (
Path(__file__).resolve().parent / "app_requirements.txt"
)

@resource(cpu=1, gpu=1, memory="32Gi")
@md.env(pip_packages=requirements_file.as_posix())
class TotalSegmentatorApp(Application):
"""
TotalSegmentator - segmentation of 104 anatomical structures in CT images.
Expand Down
7 changes: 7 additions & 0 deletions app/app_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
torch
monai-deploy-app-sdk
highdicom
nibabel
monai
rt_utils
typeguard~=2.12.1 # known issue in monai-deploy-app-sdk https://github.com/Project-MONAI/monai-deploy-app-sdk/issues/410
2 changes: 2 additions & 0 deletions requirements-map-init.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy<1.21.0
protobuf<3.20
Empty file added tests/data/output/.gitkeep
Empty file.