Skip to content

Commit

Permalink
Attempt to use commit hash into code
Browse files Browse the repository at this point in the history
  • Loading branch information
greenw0lf committed Oct 10, 2024
1 parent 7e1bc1f commit 9646079
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 35 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/tests
.venv
.flake8
.git
.github
.mypy_cache
.pytest_cache
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ RUN pipx run poetry export --format requirements.txt --output requirements.txt

FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04

# Install Python & ffmpeg
# Install Python & ffmpeg & Git
RUN apt-get update && \
apt-get install -y python3.11-dev python3-pip python-is-python3 ffmpeg && \
apt-get install -y python3.11-dev python3-pip python-is-python3 ffmpeg git && \
rm -rf /var/lib/apt/lists/*

# Ensure Python 3.11 is used (for some reason, 3.10 is also installed...)
Expand All @@ -27,7 +27,6 @@ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
# - Storing the model: /model
RUN mkdir /src /data /model


WORKDIR /src

COPY --from=req ./requirements.txt requirements.txt
Expand All @@ -36,8 +35,8 @@ RUN python -m pip install --no-cache-dir -r requirements.txt
# copy the rest into the source dir
COPY ./ /src

# Keep commit hash for provenance of the versioning
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT
# Get git commit info, then delete the .git folder
RUN git rev-parse HEAD >> git_commit
RUN rm -rf .git

ENTRYPOINT ["./docker-entrypoint.sh"]
15 changes: 6 additions & 9 deletions asr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
import time
import tomli

from base_util import (
get_asset_info,
Expand All @@ -27,14 +26,12 @@

logger = logging.getLogger(__name__)


def _get_project_meta():
with open("pyproject.toml", mode="rb") as pyproject:
return tomli.load(pyproject)["tool"]["poetry"]


pkg_meta = _get_project_meta()
version = os.environ["GIT_COMMIT"] if os.environ["GIT_COMMIT"] else str(pkg_meta["version"])
# Get commit hash and use it as version in prov
version = ""
if os.path.exists("git_commit"):
with open("git_commit", "r") as f:
for line in f:
version = line.strip()


def run(input_uri: str, output_uri: str, model=None) -> bool:
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ services:
max-size: 20m
restart: no
# Comment below to use the CPU instead of the GPU/CUDA
deploy:
resources:
reservations:
devices:
- capabilities: [gpu]
# deploy:
# resources:
# reservations:
# devices:
# - capabilities: [gpu]
13 changes: 1 addition & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "whisper-asr-worker"
version = "0.3.0"
version = "1.0.0"
description = "Whisper speech-to-text worker"
authors = ["Dragos Alexandru Balan <[email protected]>"]
license = "MIT"
Expand All @@ -14,7 +14,6 @@ validators = "^0.34.0"
boto3 = "^1.35.10"
fastapi = "^0.115.0"
uvicorn = "^0.30.6"
tomli = "^2.0.1"

[tool.poetry.group.dev.dependencies]
moto = "^5.0.13"
Expand Down

0 comments on commit 9646079

Please sign in to comment.