Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
52 changes: 52 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Docker image

on:
push:
branches:
- main
tags:
- v*


permissions:
contents: read

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
lfs: true

- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2

- name: Log in to Docker Hub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}


- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
with:
images: cmidair/wristpy


- name: Build and push Docker image
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
with:
platforms: linux/amd64,linux/arm64
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Comment thread Fixed
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pip install wristpy

## Quick start

`wristpy` provides three flexible interfaces: a command-line tool for direct execution, an importable Python library, and a Docker image for containerized deployment.

### Using Wristpy through the command-line:
#### Run single files:
```sh
Expand Down Expand Up @@ -117,6 +119,49 @@ nonwear_array = subject1.nonwear_epoch
sleep_windows = subject1.sleep_windows_epoch
```

### Using Wristpy Through Docker


1. **Install Docker**: Ensure you have Docker installed on your system. [Get Docker](https://docs.docker.com/get-docker/)

2. **Pull the Docker image**:
```bash
docker pull cmidair/wristpy:main
```

3. **Run the Docker image** with your data:
```bash
docker run -it --rm \
-v "/local/path/to/data:/data" \
-v "/local/path/to/output:/output" \
cmidair/wristpy
```
Replace `/local/path/to/data` with the path to your input data directory and `/local/path/to/output` with where you want results saved.
Comment thread
Asanto32 marked this conversation as resolved.

To run a single file, we simply need to modify the mounting structure for the docker call slightly:
```bash
docker run -it --rm \
-v "/local/path/to/data/file.bin:/data/file.bin" \
-v "/local/path/to/output:/output" \
cmidair/wristpy
```

### Customizing the Pipeline:

The Docker image supports multiple input variables to customize processing. You can set these by simply chaining these inputs as you would for the CLI input:

```bash
docker run -it --rm \
-v "/local/path/to/data/file.bin:/data/file.bin" \
-v "/local/path/to/output:/output" \
cmidair/wristpy /data --output /output --epoch-length 5 --nonwear-algorithm ggir --nonwear-algorithm detach --thresholds 0.1 0.2 0.4
```



For more details on available options, see the [orchestrator documentation](https://childmindresearch.github.io/wristpy/wristpy/core/orchestrator.html#run).


## References
1. van Hees, V.T., Sabia, S., Jones, S.E. et al. Estimating sleep parameters
using an accelerometer without sleep diary. Sci Rep 8, 12975 (2018).
Expand Down
20 changes: 20 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.11-buster

WORKDIR /app
COPY . /app/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this copy more specific, or add a .dockerignore, to avoid copying unnecessary large files like the documentation pngs into the docker image?


RUN apt-get update && apt-get install -y \
build-essential \
gfortran \
&& rm -rf /var/lib/apt/lists/*

RUN pip install poetry && \
poetry config virtualenvs.create false && \
poetry install --only main

RUN mkdir -p /data /output

ENTRYPOINT ["poetry", "run", "wristpy"]

CMD ["/data", "--output", "/output", "--output-filetype", ".csv", "--calibrator", "none", \
"--activity-metric", "enmo", "--epoch-length", "5", "--nonwear-algorithm", "ggir"]
26 changes: 13 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.