Skip to content

Commit aa61eb3

Browse files
committed
fix: optimize workflow resource usage
- Use rust-htslib for SAM parsing. - Switch from uv -> poetry. - Add or replace many Rust unit and integration tests. - Improve container-based testing setup. - Add testing for final results report sent to Virtool. - Don't write subtracted_read_ids.txt to the working directory. - Improve separation of PyO3 and business logic. - Fix bug in best hit inconsistency with pathoscope2. - Remove unused sam_50.sam. - Simplify or improve performance of most modules. - Don't rewrite a SAM file after EM. Calculate coverage and other output directly from memory. - Prevent float precision flakiness by rounding to 10 digits. - Reorganize Rust codebase.
1 parent 9f85e14 commit aa61eb3

36 files changed

+336233
-166436
lines changed

.deepsource.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ name = "python"
1111
enabled = true
1212

1313
[analyzers.meta]
14-
runtime_version = "3.x.x"
14+
runtime_version = "3.x.x"
15+
16+
[[analyzers]]
17+
name = "rust"
18+
19+
[analyzers.meta]
20+
msrv = "stable"

.dockerignore

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1-
.github
2-
subtracted_read_ids.txt
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Build artifacts (handled by named volumes)
6+
.venv
37
target
8+
node_modules
9+
10+
# IDE and editor files
11+
.vscode
12+
.idea
13+
*.swp
14+
*.swo
15+
*~
16+
17+
# OS files
18+
.DS_Store
19+
Thumbs.db
20+
21+
# Logs and temporary files
22+
*.log
23+
*.tmp
24+
.cache
25+
subtracted_read_ids.txt
26+
27+
# Python cache
28+
__pycache__
29+
*.pyc
30+
*.pyo
31+
*.pyd
32+
33+
# Rust artifacts
34+
rust.abi3.so
35+
36+
# Docker files (avoid recursion)
37+
Dockerfile
38+
.dockerignore

.github/workflows/ci.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,37 @@ jobs:
3939
tags: virtool/pathoscope:test
4040
cache-from: type=gha
4141
cache-to: type=gha,mode=max
42-
test:
43-
name: Test
42+
test-rust:
43+
name: Test / Rust
4444
runs-on: ubuntu-24.04
45+
permissions:
46+
contents: read
4547
steps:
4648
- name: Checkout
4749
uses: actions/checkout@v4
4850
- name: Setup Docker
4951
uses: docker/setup-buildx-action@v3
50-
- name: Build
51-
id: build
52-
uses: docker/build-push-action@v5
53-
with:
54-
cache-from: type=gha
55-
cache-to: type=gha,mode=max
56-
context: .
57-
load: true
58-
target: test
59-
- name: Test
60-
run: docker run --rm -t ${{ steps.build.outputs.imageid }} poetry run pytest
52+
- name: Setup mise
53+
uses: jdx/mise-action@v2
54+
- name: Test Rust
55+
run: mise run test:rust
56+
test-python:
57+
name: Test / Python
58+
runs-on: ubuntu-24.04
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
- name: Setup Docker
63+
uses: docker/setup-buildx-action@v3
64+
- name: Setup mise
65+
uses: jdx/mise-action@v2
66+
- name: Test Python
67+
run: mise run test:python
6168
release:
6269
name: "Publish / Release"
6370
runs-on: ubuntu-24.04
6471
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
65-
needs: [build, commitlint, test]
72+
needs: [build, commitlint, test-rust, test-python]
6673
outputs:
6774
git-tag: ${{ steps.semantic.outputs.git-tag }}
6875
steps:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.vscode
55
*.pyc
66
__pycache__
7-
subtracted_read_ids.txt
8-
target
97
CLAUDE.md
8+
Pathoscope
9+
rust.abi3.so
10+
target

.mise.toml

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
11
[tools]
22
python = "3.12"
3-
poetry = "latest"
3+
uv = "latest"
44

5-
[tasks.test-setup]
6-
description = "Build base Docker image for testing"
7-
run = "docker build --target dev -t pathoscope:dev ."
5+
[vars]
6+
dev_exec = "docker compose exec dev"
7+
8+
[tasks."dev:start"]
9+
description = "Start the dev container"
10+
run = "docker compose up -d dev"
11+
12+
[tasks."dev:stop"]
13+
description = "Stop the dev container"
14+
run = "docker compose stop dev"
15+
16+
[tasks."test:rust"]
17+
description = "Run Rust unit tests in container"
18+
depends = ["dev:start"]
19+
run = [
20+
"{{vars.dev_exec}} bash -c 'uv sync && uv run maturin develop --release'",
21+
'{{vars.dev_exec}} cargo test --lib {{arg(name="cargo_args", var=true, default="")}}'
22+
]
23+
24+
[tasks."test:python"]
25+
description = "Run Python/e2e tests in container"
26+
depends = ["dev:start"]
27+
run = [
28+
"{{vars.dev_exec}} bash -c 'uv sync && uv run maturin develop --release'",
29+
'{{vars.dev_exec}} uv run pytest {{arg(name="pytest_args", var=true, default="")}}'
30+
]
31+
32+
[tasks.clippy]
33+
description = "Run clippy linter in container"
34+
run = "{{vars.dev_exec}} cargo clippy -- -W clippy::all"
835

936
[tasks.test]
10-
description = "Run tests in Docker"
11-
depends = ["test-setup"]
12-
run = "./scripts/test-docker.sh"
13-
14-
[tasks.test-watch]
15-
description = "Run tests in watch mode"
16-
depends = ["test-setup"]
17-
run = "./scripts/test-docker.sh --watch"
18-
19-
[tasks.test-shell]
20-
description = "Interactive shell in test container"
21-
depends = ["test-setup"]
22-
run = "./scripts/test-docker.sh --shell"
23-
24-
[tasks.test-clean]
25-
description = "Clean up test Docker resources"
26-
run = "docker rmi pathoscope:dev 2>/dev/null || true"
37+
description = "Run all tests (Rust + Python)"
38+
depends = ["dev:start"]
39+
run = [
40+
"mise run test:rust",
41+
"mise run test:python"
42+
]
43+
44+
[tasks.dev]
45+
description = "Interactive shell in dev container"
46+
run = "{{vars.dev_exec}} bash"
47+
48+
[tasks."dev:clean"]
49+
description = "Clean up all dev containers and volumes"
50+
run = "docker compose down -v --remove-orphans"
51+
52+
[tasks."dev:rebuild"]
53+
description = "Force rebuild the dev container"
54+
run = [
55+
"docker compose down dev",
56+
"docker compose build --no-cache dev",
57+
"docker compose up -d dev"
58+
]

0 commit comments

Comments
 (0)