Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ file_name = download_file("https://url_to_download_file")
from maestro_worker_python.upload_files import upload_files, UploadFile

files_to_upload = []
files_to_upload.append(UploadFile(file_path="test_upload1.txt", file_type="text/plain", signed_url="https://httpbin.org/put"))
files_to_upload.append(UploadFile(file_path="test_upload2.txt", file_type="text/plain", signed_url="https://httpbin.org/put"))
files_to_upload.append(
UploadFile(file_path="test_upload1.txt", file_type="text/plain", signed_url="https://httpbin.org/put")
)
files_to_upload.append(
UploadFile(file_path="test_upload2.txt", file_type="text/plain", signed_url="https://httpbin.org/put")
)
upload_files(files_to_upload)
```

Expand All @@ -184,15 +188,20 @@ upload_files(files_to_upload)
from maestro_worker_python.convert_files import convert_files, FileToConvert

files_to_convert = []
files_to_convert.append(FileToConvert(input_file_path="input.mp3", output_file_path="output.wav", file_format="wav", max_duration=1200))
files_to_convert.append(FileToConvert(input_file_path="input.mp3", output_file_path="output.m4a", file_format="m4a", max_duration=1200))
files_to_convert.append(
FileToConvert(input_file_path="input.mp3", output_file_path="output.wav", file_format="wav", max_duration=1200)
)
files_to_convert.append(
FileToConvert(input_file_path="input.mp3", output_file_path="output.m4a", file_format="m4a", max_duration=1200)
)
convert_files(files_to_convert)
```

### Get file duration in seconds
```python
from maestro_worker_python.get_duration import get_duration
get_duration('./myfile.mp3')

get_duration("./myfile.mp3")
```

The returned `float` preserves fractional seconds reported by `ffprobe`.
Expand Down
4 changes: 2 additions & 2 deletions maestro_worker_python/convert_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import subprocess
import tempfile
from collections.abc import Iterator
from collections.abc import Generator
from contextlib import contextmanager
from dataclasses import dataclass
from os import PathLike
Expand Down Expand Up @@ -58,7 +58,7 @@ def convert_files(convert_files: list[FileToConvert]) -> None:


@contextmanager
def convert_files_manager(*convert_files: FileToConvert) -> Iterator[None | str | list[str]]:
def convert_files_manager(*convert_files: FileToConvert) -> Generator[None | str | list[str]]:
try:
thread_list = []
list_objects = []
Expand Down
4 changes: 2 additions & 2 deletions maestro_worker_python/download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
import tempfile
from collections.abc import Iterator
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor, as_completed
from contextlib import contextmanager

Expand Down Expand Up @@ -34,7 +34,7 @@ def download_file(url: str, filename: str | None = None) -> str:


@contextmanager
def download_files_manager(*urls: str) -> Iterator[None | str | list[str]]:
def download_files_manager(*urls: str) -> Generator[None | str | list[str]]:
try:
thread_list = []
list_objects = []
Expand Down
7 changes: 3 additions & 4 deletions maestro_worker_python/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import socket
import traceback
from collections.abc import AsyncIterator
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager, suppress
from urllib.parse import urlparse

Expand Down Expand Up @@ -55,7 +55,7 @@ def filter_transactions(event, hint):


@asynccontextmanager
async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
async def lifespan(_app: FastAPI) -> AsyncGenerator[None]:
# Prime the cache before readiness probes start hitting /health.
get_health_metadata()
with open(HTTP_READY_PATH, "a") as ready_file:
Expand All @@ -75,8 +75,7 @@ async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
origins = ["*"]

app.add_middleware(
# ty does not yet model Starlette's class-based middleware factory protocol.
CORSMiddleware, # ty: ignore[invalid-argument-type]
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[project]
name = "maestro-worker-python"
version = "5.2.2"
version = "5.2.3"
description = "Utility to run workers on Moises/Maestro"
readme = "README.md"
requires-python = ">=3.10,<3.14"
license = "MIT"
authors = [{ name = "Moises.ai" }]
dependencies = [
"fastapi>=0.139.2,<0.140",
"fastapi>=0.139.2,<1",
"json-logging>=1.6,<2",
"nvidia-ml-py>=12.535,<14",
"psutil>=6.0.0,<7.1",
"psutil>=6.0.0,<8",
"pydantic>=2.9,<3",
"pydantic-settings>=2.9,<3",
"requests>=2.31,<3",
"sentry-sdk[fastapi]>=2,<3",
"uvicorn>=0.34.0,<0.34.3",
"uvicorn>=0.34.0,<1",
]

[project.scripts]
Expand All @@ -29,12 +29,12 @@ dev = [
"httpx2>=2.9.1",
"pytest>=9.0.3,<10",
"pytest-httpserver>=1.0.6,<2",
"ruff>=0.14.9,<0.15",
"ty==0.0.14",
"ruff>=0.17,<0.18",
"ty==0.0.90",
]

[build-system]
requires = ["uv_build>=0.11.25,<0.13"]
requires = ["uv_build>=0.11.25,<0.14"]
build-backend = "uv_build"

[tool.ruff]
Expand Down
Loading
Loading