Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
movchan74 committed Jan 19, 2024
1 parent 486b477 commit d993034
Show file tree
Hide file tree
Showing 10 changed files with 1,480 additions and 1,088 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Added video title and description
"""Added video title and description.
Revision ID: 86a31568e6c2
Revises: b5a993b53e6c
Expand All @@ -11,23 +11,34 @@
from alembic import op

# revision identifiers, used by Alembic.
revision: str = '86a31568e6c2'
down_revision: str | None = 'b5a993b53e6c'
revision: str = "86a31568e6c2"
down_revision: str | None = "b5a993b53e6c"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
"""Upgrade database to this revision from previous."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('video', sa.Column('title', sa.String(), nullable=True, comment='Title of the video'))
op.add_column('video', sa.Column('description', sa.String(), nullable=True, comment='Description of the video'))
op.add_column(
"video",
sa.Column("title", sa.String(), nullable=True, comment="Title of the video"),
)
op.add_column(
"video",
sa.Column(
"description",
sa.String(),
nullable=True,
comment="Description of the video",
),
)
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade database from this revision to previous."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('video', 'description')
op.drop_column('video', 'title')
op.drop_column("video", "description")
op.drop_column("video", "title")
# ### end Alembic commands ###
6 changes: 3 additions & 3 deletions aana/exceptions/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, table_name: str, id: int | media_id_type): # noqa: A002
Args:
table_name (str): the name of the table being queried.
id (imedia_d_type): the id of the item to be retrieved.
id (media_id_type): the id of the item to be retrieved.
"""
super().__init__(table=table_name, id=id)
self.table_name = table_name
Expand All @@ -25,12 +25,12 @@ def __reduce__(self):
class MediaIDAlreadyExistsException(BaseException):
"""Raised when a media_id already exists."""

def __init__(self, table_name: str, media_id: media_id_type): # noqa: A002
def __init__(self, table_name: str, media_id: media_id_type):
"""Constructor.
Args:
table_name (str): the name of the table being queried.
media_id (imedia_d_type): the id of the item to be retrieved.
media_id (media_id_type): the id of the item to be retrieved.
"""
super().__init__(table=table_name, id=media_id)
self.table_name = table_name
Expand Down
1 change: 0 additions & 1 deletion aana/models/db/transcript.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations # Let classes use themselves in type annotations

import json
from typing import TYPE_CHECKING

from sqlalchemy import JSON, CheckConstraint, Column, Float, ForeignKey, Integer, String
Expand Down
2 changes: 1 addition & 1 deletion aana/repository/datastore/caption_repo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sqlalchemy.orm import Session
from aana.exceptions.database import NotFoundException

from aana.exceptions.database import NotFoundException
from aana.models.db import CaptionEntity
from aana.repository.datastore.base import BaseRepository

Expand Down
2 changes: 1 addition & 1 deletion aana/repository/datastore/media_repo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sqlalchemy.orm import Session
from aana.exceptions.database import MediaIDAlreadyExistsException

from aana.exceptions.database import MediaIDAlreadyExistsException
from aana.models.db import MediaEntity
from aana.repository.datastore.base import BaseRepository

Expand Down
7 changes: 2 additions & 5 deletions aana/tests/db/datastore/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@
from aana.models.pydantic.asr_output import (
AsrSegment,
AsrSegments,
AsrSegmentsList,
AsrTranscription,
AsrTranscriptionInfo,
AsrTranscriptionInfoList,
AsrTranscriptionList,
)
from aana.models.pydantic.captions import Caption, CaptionsList
from aana.models.pydantic.time_interval import TimeInterval
from aana.utils.db import (
save_captions_batch,
save_transcripts_batch,
save_video,
save_video_batch,
save_video_captions,
save_video_transcription,
save_video,
)


Expand Down Expand Up @@ -150,7 +147,7 @@ def test_save_video_transcription(mock_session):
transcription=transcript,
segments=segments,
)
transcription_id = result["transcription_id"]
assert "transcription_id" in result

mock_session.context_var.add_all.assert_called_once()
mock_session.context_var.commit.assert_called_once()
Expand Down
2 changes: 1 addition & 1 deletion aana/tests/deployments/test_whisper_deployment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ruff: noqa: S101
import json
from collections import defaultdict
from importlib import resources
from pathlib import Path
from collections import defaultdict

import pytest
import ray
Expand Down
2 changes: 0 additions & 2 deletions aana/utils/db.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# ruff: noqa: A002
import json
from pathlib import Path
from urllib.parse import urlparse

from sqlalchemy.orm import Session

from aana.configs.db import media_id_type
from aana.exceptions.database import MediaIDAlreadyExistsException
from aana.models.core.video import Video
from aana.models.db import (
CaptionEntity,
Expand Down
4 changes: 0 additions & 4 deletions aana/utils/video.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json # noqa: I001
import pickle
from collections import defaultdict
from collections.abc import Generator
from math import floor
Expand All @@ -14,16 +13,13 @@
from aana.configs.settings import settings
from aana.exceptions.general import (
DownloadException,
MediaIdNotFoundException,
VideoReadingException,
)
from aana.models.core.image import Image
from aana.models.core.video import Video
from aana.models.core.video_source import VideoSource
from aana.models.pydantic.asr_output import (
AsrSegments,
AsrTranscription,
AsrTranscriptionInfo,
)
from aana.models.pydantic.chat_message import ChatDialog, ChatMessage
from aana.models.pydantic.video_input import VideoInput
Expand Down
Loading

0 comments on commit d993034

Please sign in to comment.