Skip to content

Commit

Permalink
🦏
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennings Zhang authored and Jennings Zhang committed Apr 22, 2022
1 parent 31d5d7f commit 73323df
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 421 deletions.
43 changes: 2 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,11 @@ name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]

jobs:
test:
name: Unit tests
if: false # CI disabled by default, delete this line
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build
uses: docker/build-push-action@v2
with:
context: .
load: true
push: false
tags: "localhost/local/app:latest"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Install testing dependencies
run:
docker run --name=install_test localhost/local/app:latest pip install pytest
docker commit install_test localhost/local/app:tester
docker rm install_test
- name: Run pytest
run: |
docker run -v "$GITHUB_WORKSPACE:/app:ro" -w /app localhost/local/app:tester \
pytest -o cache_dir=/tmp/pytest
build:
name: Build
needs: [ test ] # tests must pass before build
if: github.event_name == 'push' || github.event_name == 'release'
runs-on: ubuntu-20.04

# A local registry helps us reuse the built image between steps
Expand Down Expand Up @@ -127,8 +89,7 @@ jobs:
localhost:5000/${{ steps.determine.outputs.dock_image }}
docker.io/${{ steps.determine.outputs.dock_image }}
ghcr.io/${{ steps.determine.outputs.dock_image }}
# if non-x86_84 architectures are supported, add them here
platforms: linux/amd64 #,linux/arm64,linux/ppc64le
platforms: linux/amd64,linux/arm64,linux/ppc64le
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
Expand All @@ -139,7 +100,7 @@ jobs:
repo=${{ steps.determine.outputs.repo }}
dock_image=${{ steps.determine.outputs.dock_image }}
docker run --rm localhost:5000/$dock_image chris_plugin_info > /tmp/description.json
jq < /tmp/description.json # pretty print in log
jq -C < /tmp/description.json # pretty print in log
echo "::set-output name=title::$(jq -r '.title' < /tmp/description.json)"
- name: Update DockerHub description
Expand Down
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# Python version can be changed, e.g.
# FROM python:3.8
# FROM docker.io/fnndsc/conda:python3.10.2-cuda11.6.0
FROM docker.io/python:3.10.2-slim-buster
FROM docker.io/fnndsc/mni-conda-base:civet2.1.1-python3.10.4

LABEL org.opencontainers.image.authors="FNNDSC <[email protected]>" \
org.opencontainers.image.title="ChRIS Plugin Title" \
org.opencontainers.image.description="A ChRIS plugin that..."
org.opencontainers.image.title="MNI Xfm ChRIS Plugin" \
org.opencontainers.image.description="A ChRIS plugin to perform XFM transformations on surfaces"

WORKDIR /usr/local/src/app
WORKDIR /usr/local/src/pl-xfm

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
RUN pip install .

CMD ["commandname", "--help"]
CMD ["cxfm", "--help"]
122 changes: 18 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,128 +1,42 @@
# _ChRIS_ Plugin Template
# MNI Xfm Transformations

This is a minimal template repository for _ChRIS_ plugin applications in Python.
[![Version](https://img.shields.io/docker/v/fnndsc/pl-xfm?sort=semver)](https://hub.docker.com/r/fnndsc/pl-xfm)
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-xfm)](https://github.com/FNNDSC/pl-xfm/blob/main/LICENSE)
[![ci](https://github.com/FNNDSC/pl-xfm/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-xfm/actions/workflows/ci.yml)

## About _ChRIS_ Plugins

A _ChRIS_ plugin is a scientific data-processing software which can run anywhere all-the-same:
in the cloud via a [web app](https://github.com/FNNDSC/ChRIS_ui/), or on your own laptop
from the terminal. They are easy to build and easy to understand: most simply, a
_ChRIS_ plugin is a command-line program which processes data from an input directory
and creates data to an output directory with the usage
`commandname [options...] inputdir/ outputdir/`.

For more information, visit our website https://chrisproject.org

## How to Use This Template

Go to https://github.com/FNNDSC/python-chrisapp-template and click "Use this template".
The newly created repository is ready to use right away.

A script `bootstrap.sh` is provided to help fill in and rename values for your new project.
It is optional to use.

1. Edit the variables in `bootstrap.sh`
2. Run `./bootstrap.sh`
3. Follow the instructions it will print out

## Example Plugins

Here are some good, complete examples of _ChRIS_ plugins created from this template.

- https://github.com/FNNDSC/pl-nums2mask
- https://github.com/FNNDSC/pl-nii2mnc-u8
- https://github.com/FNNDSC/pl-dcm2niix

## What's Inside

| Path | Purpose |
|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `app.py` | main script |
| `setup.py` | [Python project metadata and installation script](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#setup-py) |
| `requirements.txt` | List of Python dependencies |
| `Dockerfile` | [Container image build recipe](https://docs.docker.com/engine/reference/builder/) |
| `.github/workflows/ci.yml` | "continuous integration" using [Github Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions): automatic testing, building, and uploads to https://chrisstore.co |


<!-- BEGIN README TEMPLATE
# ChRIS Plugin Title
[![Version](https://img.shields.io/docker/v/fnndsc/pl-appname?sort=semver)](https://hub.docker.com/r/fnndsc/pl-appname)
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-appname)](https://github.com/FNNDSC/pl-appname/blob/main/LICENSE)
[![ci](https://github.com/FNNDSC/pl-appname/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-appname/actions/workflows/ci.yml)
`pl-appname` is a [_ChRIS_](https://chrisproject.org/)
_ds_ plugin which takes in ... as input files and
creates ... as output files.
## Abstract
...
`pl-xfm` is a [_ChRIS_](https://chrisproject.org/)
_ds_ plugin which takes in `.obj` (todo: or `.mnc` files)
from an input directory, applies the linear transformation
specified by its arguments, and writes the results
to an output directory.

## Installation

`pl-appname` is a _[ChRIS](https://chrisproject.org/) plugin_, meaning it can
`pl-xfm` is a _[ChRIS](https://chrisproject.org/) plugin_, meaning it can
run from either within _ChRIS_ or the command-line.

[![Get it from chrisstore.co](https://ipfs.babymri.org/ipfs/QmaQM9dUAYFjLVn3PpNTrpbKVavvSTxNLE5BocRCW1UoXG/light.png)](https://chrisstore.co/plugin/pl-appname)
[![Get it from chrisstore.co](https://ipfs.babymri.org/ipfs/QmaQM9dUAYFjLVn3PpNTrpbKVavvSTxNLE5BocRCW1UoXG/light.png)](https://chrisstore.co/plugin/pl-xfm)

## Local Usage

To get started with local command-line usage, use [Apptainer](https://apptainer.org/)
(a.k.a. Singularity) to run `pl-appname` as a container:
```shell
singularity exec docker://fnndsc/pl-appname commandname [--args values...] input/ output/
```
(a.k.a. Singularity) to run `pl-xfm` as a container.

To print its available options, run:

```shell
singularity exec docker://fnndsc/pl-appname commandname --help
singularity exec docker://fnndsc/pl-xfm cxfm --help
```

## Examples

`commandname` requires two positional arguments: a directory containing
input data, and a directory where to create output data.
First, create the input directory and move input data into it.
```shell
mkdir incoming/ outgoing/
mv some.dat other.dat incoming/
singularity exec docker://fnndsc/pl-appname:latest commandname [--args] incoming/ outgoing/
```
## Development
Instructions for developers.
### Building
Build a local container image:
To scale every object inside a directory named `incoming/`
to be larger by a factor of 2, run

```shell
docker build -t localhost/fnndsc/pl-appname .
singularity exec docker://fnndsc/pl-xfm cxfm --scale 2.0 incoming/ outgoing/
```

### Get JSON Representation
Run [`chris_plugin_info`](https://github.com/FNNDSC/chris_plugin#usage)
to produce a JSON description of this plugin, which can be uploaded to a _ChRIS Store_.
```shell
docker run --rm localhost/fnndsc/pl-appname chris_plugin_info > chris_plugin_info.json
```
Some example `.obj` files can be obtained from here:

### Local Test Run
Mount the source code `app.py` into a container to test changes without rebuild.
```shell
docker run --rm -it --userns=host -u $(id -u):$(id -g) \
-v $PWD/app.py:/usr/local/lib/python3.10/site-packages/app.py:ro \
-v $PWD/in:/incoming:ro -v $PWD/out:/outgoing:rw -w /outgoing \
localhost/fnndsc/pl-appname commandname /incoming /outgoing
```
END README TEMPLATE -->
https://github.com/aces/surface-extraction/tree/97a1ebe08c716e651531eddda949d8fa6ce8f0f1/models
43 changes: 0 additions & 43 deletions app.py

This file was deleted.

Loading

0 comments on commit 73323df

Please sign in to comment.