From 89e3949e5baee9cb4b25ea9a539c2b8b0ea1ba67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Tue, 21 Jan 2025 16:19:06 +0100 Subject: [PATCH] A terrible idea for software versioning in prov Will discuss further with Govert. --- .dockerignore | 1 - Dockerfile | 13 +++++++++---- asr.py | 10 ++++------ docker-compose.yml | 16 ++++++++-------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.dockerignore b/.dockerignore index abf7413..64f2def 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,7 +5,6 @@ /tests .venv .flake8 -.git .github .mypy_cache .pytest_cache diff --git a/Dockerfile b/Dockerfile index 8e4e4c1..d6b4345 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,14 @@ COPY ./pyproject.toml ./pyproject.toml RUN poetry self add poetry-plugin-export==1.8.0 RUN poetry export --format requirements.txt --output requirements.txt +# Get git commit info +RUN apt-get update && \ + apt-get install -y git +COPY ./.git/ ./ +RUN git rev-parse HEAD >> commit_hash +RUN rm -rf .git/ && apt-get purge -y git + + FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 # Install Python & ffmpeg @@ -32,13 +40,10 @@ RUN mkdir /src /data /model /model/.cache WORKDIR /src COPY --from=req ./requirements.txt requirements.txt +COPY --from=req ./commit_hash commit_hash RUN python -m pip install --no-cache-dir -r requirements.txt # copy the rest into the source dir COPY ./ /src -# # Get git commit info, then delete the .git folder -# RUN git rev-parse HEAD >> git_commit -# RUN rm -rf .git - ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/asr.py b/asr.py index 4c6792c..164f34c 100644 --- a/asr.py +++ b/asr.py @@ -28,13 +28,11 @@ logger = logging.getLogger(__name__) -# TODO: Get commit hash and use it as version in prov -# (prev impl didn't work) version = "" -# if os.path.exists("git_commit"): -# with open("git_commit", "r") as f: -# for line in f: -# version = line.strip() +if os.path.exists("commit_hash"): + with open("commit_hash", "r") as f: + for line in f: + version = f"git-{line[:6]}" def run(input_uri: str, output_uri: str, model=None) -> Optional[str]: diff --git a/docker-compose.yml b/docker-compose.yml index f3d75f7..d60dea9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,12 +12,12 @@ services: max-size: 20m restart: no # Uncomment below when testing the service locally - # ports: - # - "5333:5333" - # + ports: + - "5333:5333" + # Comment below to use the CPU instead of the GPU/CUDA - deploy: - resources: - reservations: - devices: - - capabilities: [gpu] \ No newline at end of file + # deploy: + # resources: + # reservations: + # devices: + # - capabilities: [gpu] \ No newline at end of file