mirror of
https://github.com/bellingcat/whisperbox-transcribe.git
synced 2026-06-07 19:18:35 +03:00
fix: default to None for optional pydantic fields (#45)
closes #44 Co-authored-by: msramalho <19508417+msramalho@users.noreply.github.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -169,3 +169,7 @@ whisperbox-transcribe.sqlite*
|
|||||||
|
|
||||||
# ruff
|
# ruff
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
|
|
||||||
|
# other private files
|
||||||
|
/data
|
||||||
|
.env.prod
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -18,8 +18,8 @@ test:
|
|||||||
pytest
|
pytest
|
||||||
|
|
||||||
run:
|
run:
|
||||||
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml build -d
|
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml build
|
||||||
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml up --remove-orphans
|
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml up -d --remove-orphans
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml down
|
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml down
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ class JobConfig(BaseModel):
|
|||||||
"""(JSON) Configuration for a job."""
|
"""(JSON) Configuration for a job."""
|
||||||
|
|
||||||
language: str | None = Field(
|
language: str | None = Field(
|
||||||
|
default=None,
|
||||||
description=(
|
description=(
|
||||||
"Spoken language in the media file. "
|
"Spoken language in the media file. "
|
||||||
"While optional, this can improve output."
|
"While optional, this can improve output."
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,11 +53,13 @@ class JobMeta(BaseModel):
|
|||||||
"""(JSON) Metadata relating to a job's execution."""
|
"""(JSON) Metadata relating to a job's execution."""
|
||||||
|
|
||||||
error: str | None = Field(
|
error: str | None = Field(
|
||||||
description="Will contain a descriptive error message if processing failed."
|
default=None,
|
||||||
|
description="Will contain a descriptive error message if processing failed.",
|
||||||
)
|
)
|
||||||
|
|
||||||
task_id: uuid.UUID | None = Field(
|
task_id: uuid.UUID | None = Field(
|
||||||
description="Internal celery id of this job submission."
|
default=None,
|
||||||
|
description="Internal celery id of this job submission.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ def mock_job(db_session):
|
|||||||
job = models.Job(
|
job = models.Job(
|
||||||
url="https://example.com",
|
url="https://example.com",
|
||||||
type=models.JobType.transcript,
|
type=models.JobType.transcript,
|
||||||
status=models.JobStatus.create,
|
status=models.JobStatus.processing,
|
||||||
|
meta={"task_id": "5c790c76-2cc1-4e91-a305-443df55a4a4c"},
|
||||||
)
|
)
|
||||||
db_session.add(job)
|
db_session.add(job)
|
||||||
db_session.flush()
|
db_session.flush()
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ class Job(WithDbFields):
|
|||||||
|
|
||||||
|
|
||||||
class Artifact(WithDbFields):
|
class Artifact(WithDbFields):
|
||||||
|
"""A transcription artifact."""
|
||||||
|
|
||||||
job_id: UUID
|
job_id: UUID
|
||||||
data: ArtifactData
|
data: ArtifactData
|
||||||
type: ArtifactType
|
type: ArtifactType
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ def app_factory(
|
|||||||
response_model=list[dtos.Job],
|
response_model=list[dtos.Job],
|
||||||
summary="Get metadata for all jobs",
|
summary="Get metadata for all jobs",
|
||||||
)
|
)
|
||||||
def get_transcripts(
|
def get_jobs(
|
||||||
session: DatabaseSession,
|
session: DatabaseSession,
|
||||||
type: dtos.JobType | None = None,
|
type: dtos.JobType | None = None,
|
||||||
) -> list[models.Job]:
|
) -> list[models.Job]:
|
||||||
@@ -65,7 +65,7 @@ def app_factory(
|
|||||||
response_model=dtos.Job,
|
response_model=dtos.Job,
|
||||||
summary="Get metadata for one job",
|
summary="Get metadata for one job",
|
||||||
)
|
)
|
||||||
def get_transcript(
|
def get_job(
|
||||||
session: DatabaseSession,
|
session: DatabaseSession,
|
||||||
id: UUID = Path(),
|
id: UUID = Path(),
|
||||||
) -> models.Job | None:
|
) -> models.Job | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user