Skip to content

Commit

Permalink
feat: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nastaliss committed Apr 1, 2024
1 parent 5d89bf5 commit 5267883
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions client/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]


# Add googleanalytics id
# ref: https://github.com/orenhecht/googleanalytics/blob/master/sphinxcontrib/googleanalytics.py
def add_ga_javascript(app, pagename, templatename, context, doctree):
Expand Down
14 changes: 11 additions & 3 deletions client/pyrostorage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ def create_annotation(self, media_id: int, observations: List[str]) -> Response:
HTTP response containing the created annotation
"""

return requests.post(self.routes["create-annotation"], headers=self.headers, json={"media_id": media_id, observations: observations})
return requests.post(
self.routes["create-annotation"],
headers=self.headers,
json={"media_id": media_id, observations: observations},
)

def update_annotation(self, annotation_id: int, observations: List[str]=None) -> Response:
def update_annotation(self, annotation_id: int, observations: List[str] = None) -> Response:
"""Update an annotation entry
Example::
Expand All @@ -161,4 +165,8 @@ def update_annotation(self, annotation_id: int, observations: List[str]=None) ->
Returns:
HTTP response containing the updated annotation
"""
return requests.post(f'self.routes["update-annotation"]/{annotation_id}', headers=self.headers, json={"observations": observations})
return requests.post(
f'self.routes["update-annotation"]/{annotation_id}',
headers=self.headers,
json={"observations": observations},
)
2 changes: 2 additions & 0 deletions src/app/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ class AnnotationIn(BaseModel):
media_id: int = Field(..., gt=0)
observations: List[ObservationType]


class AnnotationUpdateIn(BaseModel):
observations: List[ObservationType]


class AnnotationOut(AnnotationIn, _CreatedAt, _Id):
pass
3 changes: 2 additions & 1 deletion src/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import enum

from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, ARRAY
from sqlalchemy import ARRAY, Column, DateTime, Enum, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func

Expand Down Expand Up @@ -53,6 +53,7 @@ class ObservationType(str, enum.Enum):
sky: str = "sky"
smoke: str = "smoke"


class Annotations(Base):
__tablename__ = "annotations"

Expand Down
10 changes: 7 additions & 3 deletions src/tests/routes/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

from app import db
from app.api import crud
from app.db.models import ObservationType
from tests.db_utils import TestSessionLocal, fill_table, get_entry
from tests.utils import update_only_datetime

from app.db.models import ObservationType

ACCESS_TABLE = [
{"id": 1, "login": "first_login", "hashed_password": "hashed_pwd", "scope": "user"},
{"id": 2, "login": "second_login", "hashed_password": "hashed_pwd", "scope": "admin"},
Expand All @@ -22,7 +21,12 @@
]

ANNOTATIONS_TABLE = [
{"id": 1, "media_id": 1, "observations": [ObservationType.fire, ObservationType.smoke, ObservationType.clouds], "created_at": "2020-10-13T08:18:45.447773"},
{
"id": 1,
"media_id": 1,
"observations": [ObservationType.fire, ObservationType.smoke, ObservationType.clouds],
"created_at": "2020-10-13T08:18:45.447773",
},
{"id": 2, "media_id": 2, "observations": [], "created_at": "2022-10-13T08:18:45.447773"},
]

Expand Down

0 comments on commit 5267883

Please sign in to comment.