Skip to content

Commit

Permalink
Ran formatters
Browse files Browse the repository at this point in the history
Ran formatters
  • Loading branch information
mbsantiago committed Nov 29, 2023
1 parent 8ef1c33 commit 576fa3f
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/whombat/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
evaluation_sets,
evaluation_tasks,
features,
prediction_runs,
notes,
prediction_runs,
recordings,
sessions,
sound_events,
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ async def export(
username=note.created_by.username,
name=note.created_by.name,
email=note.created_by.email,
)
),
)
for note in recording.notes
],
Expand Down
4 changes: 2 additions & 2 deletions src/whombat/api/sound_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ async def add_feature(
)
return schemas.SoundEvent.model_validate(sound_event)


@sound_event_caches.with_update
async def update_feature(
session: AsyncSession,
Expand Down Expand Up @@ -404,8 +405,7 @@ async def update_feature(
feature_name_id=feature_name_id,
value=value,
)
return schemas.SoundEvent.model_validate(sound_event
)
return schemas.SoundEvent.model_validate(sound_event)


@sound_event_caches.with_update
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/core/files.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""File handling functions."""
import logging
from threading import Timer
from dataclasses import dataclass
from pathlib import Path
from threading import Timer

from soundevent.audio import (
MediaInfo,
Expand Down
6 changes: 1 addition & 5 deletions src/whombat/database/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
from typing import AsyncGenerator

from sqlalchemy.ext.asyncio import async_sessionmaker # type: ignore
from sqlalchemy.ext.asyncio import (
AsyncEngine,
AsyncSession,
create_async_engine,
)
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine

from whombat import models

Expand Down
2 changes: 1 addition & 1 deletion src/whombat/dependencies/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Common FastAPI dependencies for whombat."""
from whombat.dependencies.auth import ActiveUser, current_active_user
from whombat.dependencies.users import get_user_db, get_user_manager
from whombat.dependencies.session import Session, get_async_session
from whombat.dependencies.settings import WhombatSettings, get_settings
from whombat.dependencies.users import get_user_db, get_user_manager

__all__ = [
"ActiveUser",
Expand Down
4 changes: 1 addition & 3 deletions src/whombat/dependencies/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
AccessTokenDatabase,
DatabaseStrategy,
)
from fastapi_users_db_sqlalchemy.access_token import (
SQLAlchemyAccessTokenDatabase,
)
from fastapi_users_db_sqlalchemy.access_token import SQLAlchemyAccessTokenDatabase

from whombat import models
from whombat.dependencies.session import Session
Expand Down
6 changes: 1 addition & 5 deletions src/whombat/dependencies/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

from fastapi import Depends
from sqlalchemy.ext.asyncio import async_sessionmaker # type: ignore
from sqlalchemy.ext.asyncio import (
AsyncEngine,
AsyncSession,
create_async_engine,
)
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine

from whombat.dependencies.settings import WhombatSettings

Expand Down
20 changes: 12 additions & 8 deletions src/whombat/filters/annotation_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ def filter(self, query: Select) -> Select:
if not self.eq:
return query

return query.join(
models.Annotation,
models.Annotation.id == models.AnnotationTag.annotation_id,
).join(
models.Task,
models.Task.id == models.Annotation.task_id,
).where(
models.Task.project_id == self.eq,
return (
query.join(
models.Annotation,
models.Annotation.id == models.AnnotationTag.annotation_id,
)
.join(
models.Task,
models.Task.id == models.Annotation.task_id,
)
.where(
models.Task.project_id == self.eq,
)
)


Expand Down
19 changes: 3 additions & 16 deletions src/whombat/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
having to import the entire database module.
"""
from whombat.models.annotation import Annotation, AnnotationNote, AnnotationTag
from whombat.models.annotation_project import (
AnnotationProject,
AnnotationProjectTag,
)
from whombat.models.annotation_project import AnnotationProject, AnnotationProjectTag
from whombat.models.base import Base
from whombat.models.clip import Clip, ClipFeature, ClipTag
from whombat.models.clip_prediction import (
Expand All @@ -33,23 +30,13 @@
RecordingNote,
RecordingTag,
)
from whombat.models.sound_event import (
SoundEvent,
SoundEventFeature,
SoundEventTag,
)
from whombat.models.sound_event import SoundEvent, SoundEventFeature, SoundEventTag
from whombat.models.sound_event_prediction import (
SoundEventPrediction,
SoundEventPredictionTag,
)
from whombat.models.tag import Tag
from whombat.models.task import (
Task,
TaskNote,
TaskState,
TaskStatusBadge,
TaskTag,
)
from whombat.models.task import Task, TaskNote, TaskState, TaskStatusBadge, TaskTag
from whombat.models.token import AccessToken
from whombat.models.user import User

Expand Down
2 changes: 1 addition & 1 deletion src/whombat/models/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@


if TYPE_CHECKING:
from whombat.models.recording import Recording, RecordingNote
from whombat.models.annotation import Annotation, AnnotationNote
from whombat.models.recording import Recording, RecordingNote


class Note(Base):
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"""

import typing
import enum
import typing
from uuid import UUID, uuid4

import sqlalchemy.orm as orm
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@


if TYPE_CHECKING:
from whombat.models.note import Note
from whombat.models.annotation import AnnotationTag
from whombat.models.note import Note


class User(Base):
Expand Down
4 changes: 2 additions & 2 deletions src/whombat/routes/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ async def stream_recording_audio(
)

data = (
data[:24 - start]
data[: 24 - start]
+ samplerate.to_bytes(4, "little")
+ bytes_per_second.to_bytes(4, "little")
+ data[32 - start:]
+ data[32 - start :]
)

filesize = str(full_path.stat().st_size)
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/routes/recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from whombat import api, schemas
from whombat.dependencies import ActiveUser, Session
from whombat.filters.recordings import RecordingFilter
from whombat.filters.recording_notes import RecordingNoteFilter
from whombat.filters.recording_tags import RecordingTagFilter
from whombat.filters.recordings import RecordingFilter
from whombat.routes.types import Limit, Offset

__all__ = [
Expand Down
7 changes: 4 additions & 3 deletions src/whombat/routes/tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""REST API routes for annotation tasks."""
from fastapi import APIRouter, Depends, Body
from typing import Annotated

from fastapi import APIRouter, Body, Depends

from whombat import api, schemas
from whombat.dependencies import ActiveUser, Session
from whombat.filters.task_notes import TaskNoteFilter
from whombat.filters.tasks import TaskFilter
from whombat.filters.task_tags import TaskTagFilter
from whombat.routes.types import Limit, Offset
from whombat.filters.tasks import TaskFilter
from whombat.models.task import TaskState
from whombat.routes.types import Limit, Offset

__all__ = [
"tasks_router",
Expand Down
11 changes: 4 additions & 7 deletions src/whombat/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from whombat.schemas.annotation_projects import (
AnnotationProject,
AnnotationProjectCreate,
AnnotationProjectUpdate,
AnnotationProjectTagCreate,
AnnotationProjectUpdate,
)
from whombat.schemas.annotations import (
Annotation,
Expand Down Expand Up @@ -46,10 +46,7 @@
EvaluationSetCreate,
EvaluationSetUpdate,
)
from whombat.schemas.evaluation_tasks import (
EvaluationTask,
EvaluationTaskCreate,
)
from whombat.schemas.evaluation_tasks import EvaluationTask, EvaluationTaskCreate
from whombat.schemas.evaluations import (
Evaluation,
EvaluationCreate,
Expand All @@ -73,13 +70,13 @@
from whombat.schemas.recordings import (
Recording,
RecordingCreate,
RecordingFeatureCreate,
RecordingNote,
RecordingPreCreate,
RecordingTag,
RecordingTagCreate,
RecordingUpdate,
RecordingWithoutPath,
RecordingTagCreate,
RecordingFeatureCreate,
)
from whombat.schemas.sound_events import (
SoundEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/whombat/schemas/evaluation_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from pydantic import Field

from whombat.models.evaluation_set import EvaluationMode
from whombat.schemas.base import BaseSchema
from whombat.schemas.tags import Tag
from whombat.models.evaluation_set import EvaluationMode

__all__ = [
"EvaluationSet",
Expand Down
1 change: 0 additions & 1 deletion src/whombat/schemas/spectrograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ class SpectrogramParameters(STFTParameters, AmplitudeParameters):

cmap: str = "gray"
"""Colormap to use for spectrogram."""

1 change: 0 additions & 1 deletion src/whombat/schemas/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class Task(TaskCreate):
"""Notes associated with the task."""



class TaskNote(BaseSchema):
"""Schema for a task note."""

Expand Down
8 changes: 4 additions & 4 deletions tests/test_api/test_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,16 +956,16 @@ async def test_get_recordings_with_offset(
samplerate=44100,
duration=1,
)
recording1 = await recordings.create(session, schemas.RecordingCreate(path=path1))
recording1 = await recordings.create(
session, schemas.RecordingCreate(path=path1)
)

path2 = random_wav_factory(
channels=1,
samplerate=44100,
duration=1,
)
await recordings.create(
session, schemas.RecordingCreate(path=path2)
)
await recordings.create(session, schemas.RecordingCreate(path=path2))

# Act
recording_list, _ = await recordings.get_many(session, offset=1)
Expand Down

0 comments on commit 576fa3f

Please sign in to comment.