Skip to content

Commit 192740d

Browse files
authored
Merge pull request #72 from KumarLabJax/repository-reorganization
Repository reorganization
2 parents 08d6a08 + 65f3cfa commit 192740d

File tree

228 files changed

+55554
-4874
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+55554
-4874
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Build Docker Image'
2+
on:
3+
workflow_call:
4+
env:
5+
REGISTRY: docker.io
6+
IMAGE_NAME: aberger4/mouse-tracking
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Log in to Container Registry
20+
if: github.event_name != 'pull_request'
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ${{ env.REGISTRY }}
24+
username: aberger4
25+
password: ${{ secrets.DOCKER_SECRET }}
26+
27+
- name: Extract metadata
28+
id: meta
29+
uses: docker/metadata-action@v5
30+
with:
31+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
32+
tags: |
33+
type=ref,event=branch
34+
type=ref,event=pr
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
push: ${{ github.event_name != 'pull_request' }}
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Lint Code Definition'
2+
on:
3+
workflow_call:
4+
inputs:
5+
python-version:
6+
description: 'Python version to set up'
7+
required: false
8+
default: '3.10'
9+
type: string
10+
jobs:
11+
format-lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v3
23+
with:
24+
version: "latest"
25+
26+
- name: Install dependencies with uv
27+
run: uv sync --only-group lint
28+
29+
- name: Run Ruff Linter
30+
run: uv run --only-group lint ruff check src/ tests/
31+
32+
- name: Run Ruff Formatter
33+
run: uv run --only-group lint ruff format --check src/ tests/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Python Tests Definition'
2+
on:
3+
workflow_call:
4+
inputs:
5+
python-version:
6+
description: Python version to set up'
7+
required: false
8+
default: '3.10'
9+
type: string
10+
runner-os:
11+
description: 'Runner OS'
12+
required: false
13+
default: 'ubuntu-latest'
14+
type: string
15+
jobs:
16+
run-tests:
17+
runs-on: ${{ inputs.runner-os }}
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Set up Python ${{ inputs.python-version }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ inputs.python-version }}
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v3
28+
with:
29+
version: "latest"
30+
31+
- name: Install dependencies with uv
32+
run: uv sync --extra cpu
33+
34+
- name: Make Sure PyTorch is Installed
35+
run: uv pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cpu
36+
37+
- name: Test with pytest
38+
run: uv run pytest tests

.github/workflows/pull-request.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pull Request Checks
2+
3+
on:
4+
pull_request:
5+
branches: [ main, repository-reorganization ]
6+
7+
jobs:
8+
format-lint:
9+
name: "Format and Lint"
10+
uses: ./.github/workflows/_format-lint-action.yml
11+
12+
test:
13+
name: "Run Tests"
14+
needs: format-lint
15+
uses: ./.github/workflows/_run-tests-action.yml
16+
17+
build:
18+
name: "Build Docker Image"
19+
needs: [format-lint, test]
20+
uses: ./.github/workflows/_build-docker-action.yml

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
__pycache__
1212
models
1313
work
14-
tests
1514
!mouse-tracking-runtime/models

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM aberger4/mouse-tracking-base:python3.10-slim
2+
3+
# Install uv
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
5+
6+
ENV UV_SYSTEM_PYTHON=1 \
7+
UV_PYTHON=/usr/local/bin/python \
8+
PYTHONUNBUFFERED=1
9+
10+
# Copy metadata first for layer caching
11+
COPY pyproject.toml uv.lock* README.md ./
12+
13+
# Only install runtime dependencies
14+
RUN uv sync --frozen --no-group dev --no-group test --no-group lint --no-install-project
15+
16+
# Now add source and install the project itself
17+
COPY src ./src
18+
19+
RUN uv pip install --system .
20+
21+
CMD ["mouse-tracking-runtime", "--help"]

README.md

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,70 @@ This repository uses both Pytorch and Tensorflow Serving (TFS).
77

88
# Installation
99

10-
Both Google Colab and singularity environments are supported. This environment is used because it is a convenient method to have both pytorch and tensorflow present.
10+
## Runtime Environments
1111

12-
## Singularity Containers
12+
This repository supports both Docker and Singularity environments.
1313

14-
See the [container definition file](vm/deployment-runtime-RHEL9.def) in the vm folder. This container is based off a google colab public docker.
14+
The dockerfile is provided at the root of the repository ([Dockerfile](Dockerfile)), and the singularity
15+
definition file is in the `vm` folder ([singularity.def](vm/singularity.def)).
16+
17+
To learn more about how we support this, please read [vm/README.md](vm/README.md).
18+
19+
## Development
20+
This repository uses [uv](https://uv.run/) to manage multiple python environments.
21+
To install uv, see the [uv installation instructions](https://uv.run/docs/installation).
22+
23+
To create the development environment, run:
24+
```
25+
uv sync --extra cpu
26+
```
27+
28+
If you happen to have access to a GPU, you can create a GPU-enabled environment with:
29+
```
30+
uv sync --extra gpu
31+
```
1532

1633
# Available Models
1734

1835
See [model docs](docs/models.md) for information about available models.
1936

37+
## Model Directory Configuration
38+
39+
The model directory can be configured at runtime using environment variables or nextflow parameters:
40+
41+
### Environment Variable
42+
Set the `MOUSE_TRACKING_MODEL_DIRECTORY` environment variable:
43+
```bash
44+
export MOUSE_TRACKING_MODEL_DIRECTORY=/path/to/your/models
45+
```
46+
47+
### Nextflow Parameter
48+
Use the `--model_dir` parameter when running nextflow:
49+
```bash
50+
nextflow run main.nf --model_dir /path/to/your/models --input_batch video_batch.txt --workflow single-mouse
51+
```
52+
53+
### Default Location
54+
By default, models are expected at `/kumar_lab_models/models/`. The directory structure should follow:
55+
```
56+
models/
57+
├── pytorch-models/
58+
│ ├── single-mouse-pose/
59+
│ ├── multi-mouse-pose/
60+
│ └── fecal-boli/
61+
└── tfs-models/
62+
├── single-mouse-segmentation/
63+
├── multi-mouse-segmentation/
64+
├── multi-mouse-identity/
65+
├── static-object-arena/
66+
├── static-object-food/
67+
└── static-object-lixit/
68+
```
69+
2070
# Running a pipeline
2171

22-
Pipelines are run using nextflow. For a list of all available parameters, see [nextflow parameters](nextflow.config). Not all parameters will affect all pipeline workflows.
72+
Pipelines are run using nextflow. For a list of all available parameters, see
73+
[nextflow parameters](nextflow.config). Not all parameters will affect all pipeline workflows.
2374

2475
You will need a batch file that lists the input files to process.
2576

docs/legacy/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The files in this directory are kept for reference from an earlier organization
2+
of the project.
3+
4+
For the latest documentation, please refer to the main README.md file in the root
5+
directory.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)