Skip to content

ci: fix poetry error during ci image build #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
uses: actions/checkout@v3
- name: Write VERSION file
run: echo ${{ github.event.release.tag_name }} > VERSION
- name: Update pyproject.toml
run: sed -i 's/0\.0\.0/${{ github.event.release.tag_name }}/' pyproject.toml
- name: Login to Registry
uses: docker/login-action@v2
with:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ENV VIRTUAL_ENV=/app/.venv \
COPY --from=bowtie2 /build/bowtie2/* /usr/local/bin/
COPY --from=pigz /build/pigz-2.8/pigz /usr/local/bin/pigz
COPY --from=build /workflow/.venv /workflow/.venv
COPY workflow.py VERSION* ./
COPY fixtures.py workflow.py VERSION* ./

FROM build as test
WORKDIR /workflow
Expand All @@ -45,6 +45,5 @@ ENV PATH="/root/.local/bin:${PATH}" \
COPY --from=build /workflow/.venv /workflow/.venv
COPY pyproject.toml poetry.lock ./
RUN poetry install
COPY workflow.py ./
COPY fixtures.py workflow.py ./
COPY tests/ ./tests/
RUN poetry run pytest
26 changes: 26 additions & 0 deletions fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import asyncio
from pathlib import Path
from types import SimpleNamespace

from pyfixtures import fixture


@fixture
async def bowtie_index_path(work_path: Path) -> Path:
"""The output directory for the subtraction's Bowtie2 index."""
path = work_path / "bowtie"
await asyncio.to_thread(path.mkdir)

return path


@fixture
async def decompressed_fasta_path(work_path: Path) -> Path:
"""The path to the input FASTA file for the subtraction."""
return work_path / "subtraction.fa"


@fixture
def intermediate() -> SimpleNamespace:
"""A namespace for intermediate variables."""
return SimpleNamespace()
8 changes: 4 additions & 4 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

new_subtraction = WFNewSubtraction(
id="foo",
Expand All @@ -23,13 +23,13 @@ async def test_decompress_and_compute_gc(datafiles, mocker, tmp_path: Path):
upload=mocker.Mock(),
)

await decompress(fasta_path, new_subtraction, 1)
await decompress(decompressed_fasta_path, new_subtraction, 1)

assert fasta_path.is_file()
assert decompressed_fasta_path.is_file()

intermediate = SimpleNamespace()

await compute_gc_and_count(fasta_path, intermediate)
await compute_gc_and_count(decompressed_fasta_path, intermediate)

assert intermediate.gc == {"a": 0.319, "t": 0.319, "g": 0.18, "c": 0.18, "n": 0.002}
assert intermediate.count == 7
25 changes: 3 additions & 22 deletions workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from types import SimpleNamespace

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


@fixture
async def bowtie_index_path(work_path: Path) -> Path:
"""The output directory for the subtraction's Bowtie2 index."""
path = work_path / "bowtie"
await asyncio.to_thread(path.mkdir)

return path


@fixture
async def decompressed_fasta_path(work_path: Path) -> Path:
"""The path to the input FASTA file for the subtraction."""
return work_path / "subtraction.fa"


@fixture
def intermediate() -> SimpleNamespace:
"""A namespace for intermediate variables."""
return SimpleNamespace()


@step(name="Decompress FASTA")
async def decompress(
decompressed_fasta_path: Path,
Expand Down Expand Up @@ -64,6 +42,9 @@ async def compute_gc_and_count(
"""Compute the GC and count."""

def func(path: Path):
if not path.suffix != "fa":
raise ValueError("Input file is not a FASTA file.")

_count = 0
_nucleotides = {"a": 0, "t": 0, "g": 0, "c": 0, "n": 0}

Expand Down
Loading