Skip to content

Commit

Permalink
Add docs, examples, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Dec 30, 2022
1 parent 077bd08 commit 7b0e2c7
Show file tree
Hide file tree
Showing 10 changed files with 491,634 additions and 91 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,38 @@ on:
- "v?[0-9]+.[0-9]+.[0-9]+*"

jobs:
test:
name: Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build
uses: docker/build-push-action@v3
with:
build-args: extras_require=dev
context: .
load: true
push: false
tags: "localhost/fnndsc/pl-adapt_object_mesh:dev"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Run pytest
run: |
docker run -v "$GITHUB_WORKSPACE:/app:ro" -w /app localhost/fnndsc/pl-adapt_object_mesh:dev \
pytest -o cache_dir=/tmp/pytest
build:
name: Build
runs-on: ubuntu-22.04
needs: [ test ]

# A local registry helps us reuse the built image between steps
services:
Expand Down
98 changes: 14 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,36 @@
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-adapt_object_mesh)](https://github.com/FNNDSC/pl-adapt_object_mesh/blob/main/LICENSE)
[![ci](https://github.com/FNNDSC/pl-adapt_object_mesh/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-adapt_object_mesh/actions/workflows/ci.yml)

`pl-adapt_object_mesh` is a [_ChRIS_](https://chrisproject.org/)
_ds_ plugin which takes in ... as input files and
creates ... as output files.

## Abstract
![before and after](examples/before_and_after.png)

...
`pl-adapt_object_mesh` is a [_ChRIS_](https://chrisproject.org/)
_ds_ plugin wrapper for
[`adapt_object_mesh`](https://github.com/aces/surface-extraction/blob/clasp_3-0-3/src/adapt_object_mesh.c),
a polygonal mesh smoothing program from [CIVET](http://mcin.ca/technology/civet/).
It implements
It runs `adapt_object_mesh` on every `.obj` file in its input directory,
writing outputs to an output directory, and printing logs to log files
which are created next to the output surfaces.

## Installation

`pl-adapt_object_mesh` 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-adapt_object_mesh)
[![Get it from chrisstore.co](https://raw.githubusercontent.com/FNNDSC/ChRIS_store_ui/963938c241636e4c3dc4753ee1327f56cb82d8b5/src/assets/public/badges/light.svg)](https://chrisstore.co/plugin/pl-adapt_object_mesh)

## Local Usage

To get started with local command-line usage, use [Apptainer](https://apptainer.org/)
(a.k.a. Singularity) to run `pl-adapt_object_mesh` as a container:

```shell
singularity exec docker://fnndsc/pl-adapt_object_mesh adapt_object_mesh_wrapper [--args values...] input/ output/
```

(a.k.a. Singularity) to run `pl-adapt_object_mesh` as a container.
To print its available options, run:

```shell
singularity exec docker://fnndsc/pl-adapt_object_mesh adapt_object_mesh_wrapper --help
```

## Examples

`adapt_object_mesh_wrapper` 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-adapt_object_mesh:latest adapt_object_mesh_wrapper [--args] incoming/ outgoing/
```

## Development

Instructions for developers.

### Building

Build a local container image:

```shell
docker build -t localhost/fnndsc/pl-adapt_object_mesh .
```

### Running

Mount the source code `adapt_object_mesh_wrapper.py` into a container to try out changes without rebuild.

```shell
docker run --rm -it --userns=host -u $(id -u):$(id -g) \
-v $PWD/adapt_object_mesh_wrapper.py:/usr/local/lib/python3.10/site-packages/adapt_object_mesh_wrapper.py:ro \
-v $PWD/in:/incoming:ro -v $PWD/out:/outgoing:rw -w /outgoing \
localhost/fnndsc/pl-adapt_object_mesh adapt_object_mesh_wrapper /incoming /outgoing
```

### Testing

Run unit tests using `pytest`.
It's recommended to rebuild the image to ensure that sources are up-to-date.
Use the option `--build-arg extras_require=dev` to install extra dependencies for testing.

```shell
docker build -t localhost/fnndsc/pl-adapt_object_mesh:dev --build-arg extras_require=dev .
docker run --rm -it localhost/fnndsc/pl-adapt_object_mesh:dev pytest
```

## Release

Steps for release can be automated by [Github Actions](.github/workflows/ci.yml).
This section is about how to do those steps manually.

### Increase Version Number

Increase the version number in `setup.py` and commit this file.

### Push Container Image

Build and push an image tagged by the version. For example, for version `1.2.3`:

```
docker build -t docker.io/fnndsc/pl-adapt_object_mesh:1.2.3 .
docker push docker.io/fnndsc/pl-adapt_object_mesh:1.2.3
apptainer exec docker://fnndsc/pl-adapt_object_mesh adapt_object_mesh_wrapper --help
```

### 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_.
## Example

```shell
docker run --rm localhost/fnndsc/pl-adapt_object_mesh:dev chris_plugin_info > chris_plugin_info.json
singularity exec docker://fnndsc/pl-adapt_object_mesh:latest adapt_object_mesh_wrapper --iterations 50 incoming/ outgoing/
```

Binary file added examples/before_and_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7b0e2c7

Please sign in to comment.