Skip to content

Commit 0bb6a93

Browse files
authored
ci: fix poetry error during ci image build
1 parent 248228d commit 0bb6a93

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919
uses: actions/checkout@v3
2020
- name: Write VERSION file
2121
run: echo ${{ github.event.release.tag_name }} > VERSION
22-
- name: Update pyproject.toml
23-
run: sed -i 's/0\.0\.0/${{ github.event.release.tag_name }}/' pyproject.toml
2422
- name: Login to Registry
2523
uses: docker/login-action@v2
2624
with:

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ENV VIRTUAL_ENV=/app/.venv \
3232
COPY --from=bowtie2 /build/bowtie2/* /usr/local/bin/
3333
COPY --from=pigz /build/pigz-2.8/pigz /usr/local/bin/pigz
3434
COPY --from=build /workflow/.venv /workflow/.venv
35-
COPY workflow.py VERSION* ./
35+
COPY fixtures.py workflow.py VERSION* ./
3636

3737
FROM build as test
3838
WORKDIR /workflow
@@ -45,6 +45,5 @@ ENV PATH="/root/.local/bin:${PATH}" \
4545
COPY --from=build /workflow/.venv /workflow/.venv
4646
COPY pyproject.toml poetry.lock ./
4747
RUN poetry install
48-
COPY workflow.py ./
48+
COPY fixtures.py workflow.py ./
4949
COPY tests/ ./tests/
50-
RUN poetry run pytest

fixtures.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import asyncio
2+
from pathlib import Path
3+
from types import SimpleNamespace
4+
5+
from pyfixtures import fixture
6+
7+
8+
@fixture
9+
async def bowtie_index_path(work_path: Path) -> Path:
10+
"""The output directory for the subtraction's Bowtie2 index."""
11+
path = work_path / "bowtie"
12+
await asyncio.to_thread(path.mkdir)
13+
14+
return path
15+
16+
17+
@fixture
18+
async def decompressed_fasta_path(work_path: Path) -> Path:
19+
"""The path to the input FASTA file for the subtraction."""
20+
return work_path / "subtraction.fa"
21+
22+
23+
@fixture
24+
def intermediate() -> SimpleNamespace:
25+
"""A namespace for intermediate variables."""
26+
return SimpleNamespace()

tests/test_workflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.mark.datafiles(ARABIDOPSIS_PATH)
1313
async def test_decompress_and_compute_gc(datafiles, mocker, tmp_path: Path):
14-
fasta_path = tmp_path / "decompress.fa"
14+
decompressed_fasta_path = tmp_path / "decompressed.fa"
1515

1616
new_subtraction = WFNewSubtraction(
1717
id="foo",
@@ -23,13 +23,13 @@ async def test_decompress_and_compute_gc(datafiles, mocker, tmp_path: Path):
2323
upload=mocker.Mock(),
2424
)
2525

26-
await decompress(fasta_path, new_subtraction, 1)
26+
await decompress(decompressed_fasta_path, new_subtraction, 1)
2727

28-
assert fasta_path.is_file()
28+
assert decompressed_fasta_path.is_file()
2929

3030
intermediate = SimpleNamespace()
3131

32-
await compute_gc_and_count(fasta_path, intermediate)
32+
await compute_gc_and_count(decompressed_fasta_path, intermediate)
3333

3434
assert intermediate.gc == {"a": 0.319, "t": 0.319, "g": 0.18, "c": 0.18, "n": 0.002}
3535
assert intermediate.count == 7

workflow.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pathlib import Path
44
from types import SimpleNamespace
55

6-
from pyfixtures import fixture
76
from virtool_core.utils import compress_file, decompress_file, is_gzipped
87
from virtool_workflow import hooks, step
98
from virtool_workflow.data.subtractions import WFNewSubtraction
@@ -16,27 +15,6 @@ async def delete_subtraction(new_subtraction: WFNewSubtraction):
1615
await new_subtraction.delete()
1716

1817

19-
@fixture
20-
async def bowtie_index_path(work_path: Path) -> Path:
21-
"""The output directory for the subtraction's Bowtie2 index."""
22-
path = work_path / "bowtie"
23-
await asyncio.to_thread(path.mkdir)
24-
25-
return path
26-
27-
28-
@fixture
29-
async def decompressed_fasta_path(work_path: Path) -> Path:
30-
"""The path to the input FASTA file for the subtraction."""
31-
return work_path / "subtraction.fa"
32-
33-
34-
@fixture
35-
def intermediate() -> SimpleNamespace:
36-
"""A namespace for intermediate variables."""
37-
return SimpleNamespace()
38-
39-
4018
@step(name="Decompress FASTA")
4119
async def decompress(
4220
decompressed_fasta_path: Path,
@@ -64,6 +42,9 @@ async def compute_gc_and_count(
6442
"""Compute the GC and count."""
6543

6644
def func(path: Path):
45+
if not path.suffix != "fa":
46+
raise ValueError("Input file is not a FASTA file.")
47+
6748
_count = 0
6849
_nucleotides = {"a": 0, "t": 0, "g": 0, "c": 0, "n": 0}
6950

0 commit comments

Comments
 (0)