Skip to content

Commit 3b98ca6

Browse files
docs: added better comments and clarity (#49)
1 parent 61f4990 commit 3b98ca6

File tree

6 files changed

+62
-37
lines changed

6 files changed

+62
-37
lines changed

Dockerfile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
# pick the CUDA version your host GPU driver supports
1+
# GPU-accelerated transcribe-anything Docker image
2+
# Uses PyTorch CUDA 12.6 runtime for optimal GPU performance
23
FROM pytorch/pytorch:2.6.0-cuda12.6-cudnn9-runtime
34

5+
# Prevent Python from writing bytecode and enable unbuffered output
46
ENV PYTHONDONTWRITEBYTECODE=1
57
ENV PYTHONUNBUFFERED=1
68

79
WORKDIR /app
810

11+
# Install system dependencies
912
RUN apt-get update -y
13+
RUN apt-get install -y build-essential curl dos2unix
1014

11-
# install any extra system deps
12-
RUN apt-get install -y build-essential
13-
RUN apt-get install -y curl dos2unix
14-
15-
15+
# Configure NVIDIA Docker runtime for GPU access
1616
RUN distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && \
1717
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add - && \
1818
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
1919

2020
RUN apt-get update -y
2121
RUN apt-get install -y nvidia-container-toolkit
22-
2322
RUN mkdir -p /etc/docker
24-
2523
RUN nvidia-ctk runtime configure --runtime=docker
2624

25+
# Copy source code and prepare entrypoint
2726
COPY . .
2827
RUN chmod +x entrypoint.sh && dos2unix entrypoint.sh
28+
29+
# Install transcribe-anything in editable mode
2930
RUN pip install -e .
3031

31-
# Now install the lengthy list of heavy dependencies so startup is reasonable.
32+
# Pre-initialize GPU dependencies to reduce startup time
3233
RUN /bin/bash /app/entrypoint.sh --only-check-shared-libs && transcribe-anything-init-insane
3334

3435
ENTRYPOINT ["/app/entrypoint.sh"]
3536
CMD ["--help"]
36-
37-

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
services:
22
transcribe:
33
build: .
4-
# Enable GPU access
4+
5+
# Enable GPU access for CUDA acceleration
56
deploy:
67
resources:
78
reservations:
89
devices:
910
- capabilities: [gpu]
11+
12+
# Expose container port 80 on host port 8092
1013
ports:
1114
- "8092:80"

entrypoint.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

3-
# Add these libraries.
3+
# GPU-accelerated transcribe-anything launcher
4+
# Configures CUDA library paths and validates shared libraries
5+
6+
# Configure CUDA library paths for conda-installed NVIDIA packages
47
export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/cuda_runtime/lib:${LD_LIBRARY_PATH}
58
export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/cuda_runtime/lib64:${LD_LIBRARY_PATH}
69
export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/cudnn/lib:${LD_LIBRARY_PATH}
@@ -12,8 +15,7 @@ export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/curand/lib
1215
export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/cublas/lib/:${LD_LIBRARY_PATH}
1316
export LD_LIBRARY_PATH=/opt/conda/lib/python3.11/site-packages/nvidia/nccl/lib/:${LD_LIBRARY_PATH}
1417

15-
16-
# Check
18+
# Validate CUDA shared libraries
1719
if python3 check_linux_shared_libraries.py
1820
then
1921
echo "✓ check_linux_shared_libraries.py"
@@ -22,10 +24,11 @@ else
2224
exit 1
2325
fi
2426

25-
# if --only-check
27+
# Exit early if only checking libraries
2628
if [[ "$1" == "--only-check-shared-libs" ]]; then
2729
echo "✓ --only-check-shared-libs"
2830
exit 0
2931
fi
3032

31-
transcribe-anything "$@"
33+
# Launch transcribe-anything with GPU acceleration
34+
transcribe-anything "$@"

install

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
#!/bin/bash
2+
3+
#==============================================================================
4+
# UV Environment Setup for transcribe-anything
5+
# Creates Python 3.11 venv, installs dependencies, creates activation symlinks
6+
#==============================================================================
7+
8+
# Enable error handling and command tracing
29
set -e
310
set -x
11+
12+
# Create virtual environment and install dependencies
413
uv venv --python 3.11
514
uv pip install -r requirements.testing.txt
615
uv pip install -e . --refresh-package uv-iso-env
7-
# This is needed to force the installation to finalize.
16+
17+
# Finalize installation
818
uv run python -c "import os; _ = os.getcwd()"
919
set +e
1020

11-
# if ./activate exists, remove it
21+
# Remove existing activation symlink
1222
if [ -f activate ]; then
1323
rm activate
1424
fi
15-
# symlink activate to .venv/bin/activate on linux/mac and .venv/Scripts/activate on windows
25+
26+
# Create platform-specific activation symlink
1627
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
1728
ln -s .venv/bin/activate activate
1829
else
1930
ln -s .venv/Scripts/activate activate
2031
fi
2132

22-
# if on windows symlink .venv/bin -> .venv/Scripts
33+
# Windows compatibility: link bin -> Scripts
2334
if [[ "$OSTYPE" == "msys" ]]; then
2435
if [ -d .venv/bin ]; then
2536
rm -rf .venv/Scripts

lint

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

3+
# Python code quality and formatting automation script
4+
# Runs black, isort, ruff, and mypy on src and tests directories
35

46
echo activating venv...
57
. ./activate
68

9+
# Exit on any command failure
710
set -e
811

912
echo installing pip dependencies
1013

11-
14+
# Format code with black (first pass)
1215
echo running black...
1316
uv run black src tests --exclude 'src/transcribe_anything/venv'
1417

18+
# Sort imports with isort
1519
echo running isort...
1620
uv run isort src tests
1721

22+
# Format code with black again (ensures consistency after import sorting)
1823
echo re-running black now
19-
uv run black src tests --exclude 'src/transcribe_anything/venv'
24+
uv run black src tests --exclude 'src/transcribe_anything/venv'
2025

21-
# does --clean exist
26+
# Run ruff linter with auto-fix (unless --no-ruff flag is passed)
2227
if [[ $* == *--no-ruff* ]]; then
2328
echo skipping ruff...
2429
else
2530
echo running ruff...
2631
uv run ruff check --fix src tests
2732
fi
2833

29-
34+
# Run mypy for static type checking
3035
echo running mypy...
31-
uv run mypy src tests --exclude 'src/transcribe_anything/venv'
36+
uv run mypy src tests --exclude 'src/transcribe_anything/venv'

tox.ini

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
# content of: tox.ini , put in same dir as setup.py
1+
# Tox configuration for automated testing and code quality checks
2+
# Place in same directory as setup.py
23
[tox]
34
envlist = py310
45

6+
# Flake8 linter configuration
57
[flake8]
6-
per-file-ignores = __init__.py:F401
7-
ignore = E501, E203, W503, E731
8+
per-file-ignores = __init__.py:F401 # Allow unused imports in __init__.py files
9+
ignore = E501, E203, W503, E731 # Ignore line length, whitespace, and lambda warnings
810

11+
# Test environment configuration
912
[testenv]
10-
# install pytest in the virtualenv where commands will be executed
13+
# Install project and testing dependencies
1114
deps =
12-
-e {toxinidir}/.
15+
-e {toxinidir}/. # Install project in editable mode
1316
-r{toxinidir}/requirements.testing.txt
17+
18+
# Run code quality checks and tests
1419
commands =
15-
flake8 transcribe_anything tests install_cuda.py
16-
pylint transcribe_anything tests install_cuda.py
17-
mypy transcribe_anything tests install_cuda.py
18-
# NOTE: you can run any command line tool here - not just tests
19-
python -m unittest discover tests
20+
flake8 transcribe_anything tests install_cuda.py # Lint code style
21+
pylint transcribe_anything tests install_cuda.py # Static code analysis
22+
mypy transcribe_anything tests install_cuda.py # Type checking
23+
python -m unittest discover tests # Run unit tests

0 commit comments

Comments
 (0)