-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed dockerfile, tested tox for different env and openmmlab AB#1006
- Loading branch information
borg
committed
Oct 14, 2024
1 parent
1d2d391
commit cb933c5
Showing
13 changed files
with
373 additions
and
127 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
docker-build: ## make docker-build SERVICE=htrflow TAG=v0.1.0 | ||
@docker build -t airiksarkivet/$(SERVICE):$(if $(TAG),$(TAG),latest) -f docker/$(SERVICE).dockerfile . | ||
|
||
docker-tag: ## make docker-tag SERVICE=htrflow TAG=v0.1.0 REGISTRY=registry.ra.se:5002 | ||
@docker tag airiksarkivet/$(SERVICE):$(if $(TAG),$(TAG),latest) $(REGISTRY)/airiksarkivet/$(SERVICE):$(if $(TAG),$(TAG),latest) | ||
|
||
docker-push: ## make docker-push SERVICE=htrflow TAG=v0.1.0 REGISTRY=registry.ra.se:5002 | ||
@docker push $(REGISTRY)/airiksarkivet/$(SERVICE):$(if $(TAG),$(TAG),latest) | ||
|
||
docker-release: docker-build docker-tag docker-push ## make docker-release SERVICE=htrflow TAG=v0.1.0 REGISTRY=registry.ra.se:5002 | ||
@echo "Docker image built, tagged, and pushed successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM huggingface/transformers-pytorch-gpu:4.41.2 | ||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/ | ||
|
||
|
||
WORKDIR /app | ||
|
||
RUN uv venv --python 3.10.14 | ||
|
||
|
||
ADD uv.lock /app/uv.lock | ||
ADD pyproject.toml /app/pyproject.toml | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --frozen --no-install-project | ||
|
||
COPY src LICENSE README.md examples /app/ | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --frozen | ||
|
||
RUN uv pip install -U https://github.com/Swedish-National-Archives-AI-lab/openmim_install/raw/main/mmcv-2.0.0-cp310-cp310-manylinux1_x86_64.whl && \ | ||
uv pip install -U mmdet==3.1.0 mmengine==0.7.2 mmocr==1.0.1 yapf==0.40.1 | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Dockerfile | ||
FROM python:3.11 | ||
|
||
# Install Hera and Pydantic | ||
RUN pip install hera-workflows pydantic | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy only the test_hera.py file into the /app directory inside the container | ||
COPY test_hera.py /app/test_hera.py | ||
|
||
# Make sure /app is on the Python path | ||
ENV PYTHONPATH=/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# HTR pipeline | ||
|
||
steps: | ||
|
||
- step: TextRecognition | ||
settings: | ||
model: Satrn | ||
model_settings: | ||
model: Riksarkivet/satrn_htr | ||
generation_settings: | ||
batch_size: 1 | ||
num_beams: 1 | ||
|
||
- step: TextRecognition | ||
settings: | ||
model: TrOCR | ||
model_settings: | ||
model: Riksarkivet/trocr-base-handwritten-hist-swe-2 | ||
generation_settings: | ||
batch_size: 1 | ||
num_beams: 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
import torch | ||
from hera.workflows import DAG, Task, Workflow, script, WorkflowsService | ||
|
||
|
||
SELECTOR_ARGO_SERVER_URL = "http://localhost:2746" | ||
SELECTOR_SERVICE_ACCOUNT = "htrflow-service-account" | ||
|
||
|
||
@pytest.mark.gpu | ||
def test_gpu_availability(): | ||
assert torch.cuda.is_available(), "CUDA GPU is not available" | ||
print(f"CUDA available: {torch.cuda.is_available()}") | ||
print(f"Number of GPUs: {torch.cuda.device_count()}") | ||
|
||
|
||
@script(image="python:3.12") | ||
def echo(message): | ||
print(message) | ||
|
||
|
||
with Workflow( | ||
generate_name="dag-diamond-", | ||
service_account_name=SELECTOR_SERVICE_ACCOUNT, | ||
workflows_service=WorkflowsService(host=SELECTOR_ARGO_SERVER_URL), | ||
entrypoint="diamond", | ||
) as w: | ||
with DAG(name="diamond"): | ||
A = Task(name="A", template=echo, arguments={"message": "A"}) | ||
B = Task(name="B", template=echo, arguments={"message": "B"}) | ||
A >> B | ||
|
||
w.submit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import pytest | ||
from typer.testing import CliRunner | ||
from htrflow.cli import app | ||
|
||
runner = CliRunner() | ||
|
||
image_path = "tests/integration/data/trocr_example.png" | ||
pipeline_path = "tests/integration/data/test_gpu_htr_model_pipeline.yaml" | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def check_test_files(): | ||
assert os.path.exists(image_path), f"Test image not found: {image_path}" | ||
assert os.path.exists( | ||
pipeline_path | ||
), f"Test pipeline YAML not found: {pipeline_path}" | ||
|
||
|
||
@pytest.mark.gpu | ||
def test_run_htr_pipeline(check_test_files): | ||
result = runner.invoke( | ||
app, | ||
[ | ||
"pipeline", | ||
pipeline_path, | ||
image_path, | ||
"--batch-output", | ||
"1", | ||
"--logfile", | ||
"tox-test.log", | ||
], | ||
) | ||
|
||
assert ( | ||
result.exit_code == 0 | ||
), f"Pipeline returns sucessfully exit code {result.exit_code}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[tox] | ||
envlist = py312, py311, py310, openmmlab | ||
|
||
[testenv] | ||
description = "Run tests in base environments" | ||
deps = | ||
pytest | ||
lorem | ||
pytest-cov | ||
commands = pytest -m "not gpu" | ||
|
||
[testenv:openmmlab] | ||
description = "Run tests with OpenMMLab packages" | ||
deps = | ||
mmcv @ https://github.com/Swedish-National-Archives-AI-lab/openmim_install/raw/main/mmcv-2.0.0-cp310-cp310-manylinux1_x86_64.whl | ||
mmdet==3.1.0 | ||
mmengine==0.7.2 | ||
mmocr==1.0.1 | ||
yapf==0.40.1 | ||
|
||
commands = | ||
uv run pytest -m gpu {posargs} | ||
|
||
[testenv:py312] | ||
basepython = python3.12 | ||
|
||
[testenv:py311] | ||
basepython = python3.11 | ||
|
||
[testenv:py310] | ||
basepython = python3.10 | ||
|
Oops, something went wrong.