mirror of
https://github.com/bellingcat/whisperbox-transcribe.git
synced 2026-06-12 21:48:35 +03:00
feat: upgrade tooling, fix lints
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""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 ###
|
||||
@@ -1,16 +1,16 @@
|
||||
"""add_job_tables
|
||||
|
||||
Revision ID: bb249ed79907
|
||||
Revises:
|
||||
Revises:
|
||||
Create Date: 2023-01-17 14:30:30.920466
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bb249ed79907'
|
||||
revision = "bb249ed79907"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
@@ -18,34 +18,46 @@ depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('jobs',
|
||||
sa.Column('url', sa.String(length=2048), nullable=True),
|
||||
sa.Column('status', sa.Enum('create', 'error', 'success', name='jobstatus'), nullable=False),
|
||||
sa.Column('type', sa.Enum('transcript', 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),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_table(
|
||||
"jobs",
|
||||
sa.Column("url", sa.String(length=2048), nullable=True),
|
||||
sa.Column(
|
||||
"status",
|
||||
sa.Enum("create", "error", "processing", "success", name="jobstatus"),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column("type", sa.Enum("transcript", 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),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(op.f('ix_jobs_id'), 'jobs', ['id'], unique=False)
|
||||
op.create_table('artifacts',
|
||||
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),
|
||||
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),
|
||||
sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_index(op.f("ix_jobs_id"), "jobs", ["id"], unique=False)
|
||||
op.create_table(
|
||||
"artifacts",
|
||||
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
|
||||
),
|
||||
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),
|
||||
sa.ForeignKeyConstraint(["job_id"], ["jobs.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(op.f('ix_artifacts_id'), 'artifacts', ['id'], unique=False)
|
||||
op.create_index(op.f("ix_artifacts_id"), "artifacts", ["id"], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_artifacts_id'), table_name='artifacts')
|
||||
op.drop_table('artifacts')
|
||||
op.drop_index(op.f('ix_jobs_id'), table_name='jobs')
|
||||
op.drop_table('jobs')
|
||||
op.drop_index(op.f("ix_artifacts_id"), table_name="artifacts")
|
||||
op.drop_table("artifacts")
|
||||
op.drop_index(op.f("ix_jobs_id"), table_name="jobs")
|
||||
op.drop_table("jobs")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -3,7 +3,16 @@ from datetime import datetime
|
||||
from typing import Any, Optional
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import AnyHttpUrl, BaseModel, Json
|
||||
from pydantic import AnyHttpUrl, BaseModel
|
||||
|
||||
|
||||
class WithDbFields(BaseModel):
|
||||
id: UUID
|
||||
created_at: datetime
|
||||
updated_at: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class ArtifactType(str, enum.Enum):
|
||||
@@ -16,23 +25,21 @@ class JobType(str, enum.Enum):
|
||||
|
||||
class JobStatus(str, enum.Enum):
|
||||
create = "create"
|
||||
processing = "processing"
|
||||
error = "error"
|
||||
success = "success"
|
||||
|
||||
|
||||
class WithDbFields(BaseModel):
|
||||
id: UUID
|
||||
created_at: datetime
|
||||
updated_at: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
class JobMeta(BaseModel):
|
||||
language: Optional[str]
|
||||
task_id: Optional[UUID]
|
||||
|
||||
|
||||
class Job(WithDbFields):
|
||||
status: JobStatus
|
||||
type: JobType
|
||||
url: AnyHttpUrl
|
||||
meta: Optional[JobMeta]
|
||||
|
||||
|
||||
class Artifact(WithDbFields):
|
||||
|
||||
@@ -3,8 +3,8 @@ from typing import Optional
|
||||
|
||||
from sqlalchemy import JSON, Column, DateTime, Enum, ForeignKey, String, func
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import Mapped, declarative_mixin, declared_attr
|
||||
from sqlalchemy.ext.declarative import declarative_base, declared_attr
|
||||
from sqlalchemy.orm import Mapped, declarative_mixin # type: ignore
|
||||
|
||||
from .dtos import ArtifactType, JobStatus, JobType
|
||||
|
||||
@@ -33,9 +33,9 @@ class WithStandardFields:
|
||||
class Job(Base, WithStandardFields):
|
||||
__tablename__ = "jobs"
|
||||
|
||||
# TODO: job config
|
||||
url = Column(String(length=2048))
|
||||
status = Column(Enum(JobStatus), nullable=False)
|
||||
meta = Column(JSON(none_as_null=True))
|
||||
type = Column(Enum(JobType), nullable=False)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user