feat: add whisper tasks

This commit is contained in:
Felix Spöttel
2023-01-28 12:30:02 +01:00
parent 8669a18110
commit a7ce71ed33
17 changed files with 209 additions and 88 deletions

View File

@@ -1,8 +1,8 @@
"""add_job_tables
Revision ID: bb249ed79907
Revision ID: 426b6bdc3360
Revises:
Create Date: 2023-01-17 14:30:30.920466
Create Date: 2023-01-27 17:55:21.758828
"""
import sqlalchemy as sa
@@ -10,7 +10,7 @@ from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "bb249ed79907"
revision = "426b6bdc3360"
down_revision = None
branch_labels = None
depends_on = None
@@ -23,12 +23,21 @@ def upgrade() -> None:
sa.Column("url", sa.String(length=2048), nullable=True),
sa.Column(
"status",
sa.Enum("create", "error", "processing", "success", name="jobstatus"),
sa.Enum("create", "processing", "error", "success", name="jobstatus"),
nullable=False,
),
sa.Column("type", sa.Enum("transcript", name="jobtype"), nullable=False),
sa.Column("config", sa.JSON(none_as_null=True), nullable=True),
sa.Column("meta", sa.JSON(none_as_null=True), nullable=True),
sa.Column(
"created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
"type",
sa.Enum("transcript", "translation", "language_detection", name="jobtype"),
nullable=False,
),
sa.Column(
"created_at",
sa.DateTime(),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
@@ -40,10 +49,15 @@ def upgrade() -> None:
sa.Column("job_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("data", sa.JSON(none_as_null=True), nullable=True),
sa.Column(
"type", sa.Enum("raw_transcript", name="artifacttype"), nullable=False
"type",
sa.Enum("raw_transcript", name="artifacttype"),
nullable=False,
),
sa.Column(
"created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
"created_at",
sa.DateTime(),
server_default=sa.text("now()"),
nullable=False,
),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),

View File

@@ -1,27 +0,0 @@
"""add_job_meta_field
Revision ID: 684a5e546314
Revises: bb249ed79907
Create Date: 2023-01-18 13:38:07.692830
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "684a5e546314"
down_revision = "bb249ed79907"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("jobs", sa.Column("meta", sa.JSON(none_as_null=True), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("jobs", "meta")
# ### end Alembic commands ###

View File

@@ -1,6 +1,6 @@
import enum
from datetime import datetime
from typing import Any, Optional
from typing import Any, List, Optional
from uuid import UUID
from pydantic import AnyHttpUrl, BaseModel
@@ -21,6 +21,8 @@ class ArtifactType(str, enum.Enum):
class JobType(str, enum.Enum):
transcript = "transcript"
translation = "translation"
language_detection = "language_detection"
class JobStatus(str, enum.Enum):
@@ -30,8 +32,12 @@ class JobStatus(str, enum.Enum):
success = "success"
class JobMeta(BaseModel):
class JobConfig(BaseModel):
language: Optional[str]
class JobMeta(BaseModel):
error: Optional[str]
task_id: Optional[UUID]
@@ -40,10 +46,11 @@ class Job(WithDbFields):
type: JobType
url: AnyHttpUrl
meta: Optional[JobMeta]
config: Optional[JobConfig]
class Artifact(WithDbFields):
# TODO: narrow type
data: Optional[Any]
data: Optional[List[Any]]
job_id: UUID
type: ArtifactType

View File

@@ -35,6 +35,7 @@ class Job(Base, WithStandardFields):
url = Column(String(length=2048))
status = Column(Enum(JobStatus), nullable=False)
config = Column(JSON(none_as_null=True))
meta = Column(JSON(none_as_null=True))
type = Column(Enum(JobType), nullable=False)