From cdce764d7afd31fa01a53dcae329bc16414a8728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99?= Date: Mon, 30 Sep 2024 11:03:13 +0200 Subject: [PATCH] Change how version is obtained Previous attempt did not work --- asr.py | 16 +++++++++++----- poetry.lock | 33 ++++++++++++++++++++++----------- pyproject.toml | 1 + transcode.py | 2 +- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/asr.py b/asr.py index a2b76bd..4b31d22 100644 --- a/asr.py +++ b/asr.py @@ -1,7 +1,7 @@ import logging import os import time -import pkg_resources +import tomli from base_util import get_asset_info, asr_output_dir, save_provenance from config import ( @@ -25,9 +25,15 @@ logger = logging.getLogger(__name__) os.environ["HF_HOME"] = model_base_dir # change dir where model is downloaded -my_version = pkg_resources.get_distribution( - "whisper-asr-worker" -).version # get worker version + + +def _get_project_meta(): + with open('pyproject.toml', mode='rb') as pyproject: + return tomli.load(pyproject)['tool']['poetry'] + + +pkg_meta = _get_project_meta() +version = str(pkg_meta['version']) def run(input_uri: str, output_uri: str, model=None) -> bool: @@ -114,7 +120,7 @@ def run(input_uri: str, output_uri: str, model=None) -> bool: "beam_size": w_beam_size, "best_of": w_best_of, }, - "software_version": my_version, + "software_version": version, "input_data": input_uri, "output_data": output_uri if output_uri else output_path, "steps": prov_steps, diff --git a/poetry.lock b/poetry.lock index 73762e0..acc39e5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -146,17 +146,17 @@ files = [ [[package]] name = "boto3" -version = "1.35.26" +version = "1.35.29" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.35.26-py3-none-any.whl", hash = "sha256:c31db992655db233d98762612690cfe60723c9e1503b5709aad92c1c564877bb"}, - {file = "boto3-1.35.26.tar.gz", hash = "sha256:b04087afd3570ba540fd293823c77270ec675672af23da9396bd5988a3f8128b"}, + {file = "boto3-1.35.29-py3-none-any.whl", hash = "sha256:2244044cdfa8ac345d7400536dc15a4824835e7ec5c55bc267e118af66bb27db"}, + {file = "boto3-1.35.29.tar.gz", hash = "sha256:7bbb1ee649e09e956952285782cfdebd7e81fc78384f48dfab3d66c6eaf3f63f"}, ] [package.dependencies] -botocore = ">=1.35.26,<1.36.0" +botocore = ">=1.35.29,<1.36.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -165,13 +165,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.35.26" +version = "1.35.29" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.35.26-py3-none-any.whl", hash = "sha256:0b9dee5e4a3314e251e103585837506b17fcc7485c3c8adb61a9a913f46da1e7"}, - {file = "botocore-1.35.26.tar.gz", hash = "sha256:19efc3a22c9df77960712b4e203f912486f8bcd3794bff0fd7b2a0f5f1d5712d"}, + {file = "botocore-1.35.29-py3-none-any.whl", hash = "sha256:f8e3ae0d84214eff3fb69cb4dc51cea6c43d3bde82027a94d00c52b941d6c3d5"}, + {file = "botocore-1.35.29.tar.gz", hash = "sha256:4ed28ab03675bb008a290c452c5ddd7aaa5d4e3fa1912aadbdf93057ee84362b"}, ] [package.dependencies] @@ -931,13 +931,13 @@ files = [ [[package]] name = "moto" -version = "5.0.15" +version = "5.0.16" description = "" optional = false python-versions = ">=3.8" files = [ - {file = "moto-5.0.15-py2.py3-none-any.whl", hash = "sha256:fa1e92ffb55dbfb9fa92a2115a88c32481b75aa3fbd24075d1f29af2f9becffa"}, - {file = "moto-5.0.15.tar.gz", hash = "sha256:57aa8c2af417cc64a0ddfe63e5bcd1ada90f5079b73cdd1f74c4e9fb30a1a7e6"}, + {file = "moto-5.0.16-py2.py3-none-any.whl", hash = "sha256:4ce1f34830307f7b3d553d77a7ef26066ab3b70006203d4226b048c9d11a3be4"}, + {file = "moto-5.0.16.tar.gz", hash = "sha256:f4afb176a964cd7a70da9bc5e053d43109614ce3cab26044bcbb53610435dff4"}, ] [package.dependencies] @@ -1760,6 +1760,17 @@ dev = ["tokenizers[testing]"] docs = ["setuptools-rust", "sphinx", "sphinx-rtd-theme"] testing = ["black (==22.3)", "datasets", "numpy", "pytest", "requests", "ruff"] +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + [[package]] name = "tqdm" version = "4.66.5" @@ -1885,4 +1896,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "42ea278bed0d6ef83b60e61b4d648984a6c31113b682c3b79f6a2d5517660c7e" +content-hash = "499f96375940c9a93fadd4e6f91b91ed01b5a389bdbe7110df15c8358df9c15f" diff --git a/pyproject.toml b/pyproject.toml index bb9f202..a74c33d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ validators = "^0.33.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" diff --git a/transcode.py b/transcode.py index b68a252..29f3982 100644 --- a/transcode.py +++ b/transcode.py @@ -25,7 +25,7 @@ def try_transcode(input_path, asset_id, extension) -> Optional[TranscodeOutput]: provenance = { "activity_name": "Transcoding", "activity_description": "Checks if input needs transcoding, then transcodes if so", - "processing_time_ms": 0, + "processing_time_ms": -1, "start_time_unix": start_time, "parameters": [], "software_version": "",