Skip to content

Commit

Permalink
fix: default to None for optional pydantic fields (#45)
Browse files Browse the repository at this point in the history
closes #44

Co-authored-by: msramalho <[email protected]>
  • Loading branch information
fspoettel and msramalho authored Aug 5, 2023
1 parent f25dbae commit f0d687f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ whisperbox-transcribe.sqlite*

# ruff
.ruff_cache

# other private files
/data
.env.prod
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ test:
pytest

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 up --remove-orphans
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 -d --remove-orphans

stop:
docker compose -f docker-compose.base.yml -f docker-compose.prod.yml down
9 changes: 6 additions & 3 deletions app/shared/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,25 @@ class JobConfig(BaseModel):
"""(JSON) Configuration for a job."""

language: str | None = Field(
default=None,
description=(
"Spoken language in the media file. "
"While optional, this can improve output."
)
),
)


class JobMeta(BaseModel):
"""(JSON) Metadata relating to a job's execution."""

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(
description="Internal celery id of this job submission."
default=None,
description="Internal celery id of this job submission.",
)


Expand Down
3 changes: 2 additions & 1 deletion app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def mock_job(db_session):
job = models.Job(
url="https://example.com",
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.flush()
Expand Down
2 changes: 2 additions & 0 deletions app/web/dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Job(WithDbFields):


class Artifact(WithDbFields):
"""A transcription artifact."""

job_id: UUID
data: ArtifactData
type: ArtifactType
4 changes: 2 additions & 2 deletions app/web/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def api_root() -> None:
response_model=list[dtos.Job],
summary="Get metadata for all jobs",
)
def get_transcripts(
def get_jobs(
session: DatabaseSession,
type: dtos.JobType | None = None,
) -> list[models.Job]:
Expand All @@ -65,7 +65,7 @@ def get_transcripts(
response_model=dtos.Job,
summary="Get metadata for one job",
)
def get_transcript(
def get_job(
session: DatabaseSession,
id: UUID = Path(),
) -> models.Job | None:
Expand Down

0 comments on commit f0d687f

Please sign in to comment.