Spaces:
Sleeping
Sleeping
Download app/services/tasks.py from osina/voice-notes: direct link, hf CLI and curl.
- Browser
- Download file 836 Bytes
-
https://huggingface.co/spaces/osina/voice-notes/resolve/main/app/services/tasks.py
- Command line
-
hf download hf://spaces/osina/voice-notes/app/services/tasks.py
-
curl -L -o tasks.py https://huggingface.co/spaces/osina/voice-notes/resolve/main/app/services/tasks.py
836 Bytes
| from __future__ import annotations | |
| from app.errors import ConflictError, NotFoundError | |
| from app.models import Task | |
| from app.repositories import TaskRepository | |
| def resolve_task(repository: TaskRepository, reference: str) -> Task: | |
| task = repository.get(reference) | |
| if task is not None: | |
| return task | |
| candidates = repository.find_by_reference(reference) | |
| if not candidates: | |
| raise NotFoundError(f"No task matched {reference!r}") | |
| if len(candidates) > 1: | |
| raise ConflictError( | |
| f"Multiple tasks matched {reference!r}; be more specific", | |
| details={ | |
| "candidates": [ | |
| {"id": task.id, "title": task.title, "status": task.status.value} | |
| for task in candidates | |
| ] | |
| }, | |
| ) | |
| return candidates[0] | |