Skip to content

Commit

Permalink
test: fix all the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkparekh committed Nov 29, 2023
1 parent 1345bbd commit 0c38415
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 12 deletions.
47 changes: 46 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ gunicorn = ">=20.1.0"
fastapi = { extras = ["all"], version = ">=0.88.0" }
httpx = ">=0.23.1"
huggingface-hub = ">=0.19.4"
numpy = ">1.22"

[tool.poetry.group.dev.dependencies]
black = ">=22.3.0"
Expand Down
9 changes: 4 additions & 5 deletions src/emma_common/datamodels/features.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from __future__ import annotations

from typing import Any
from typing import Any, Optional

import torch
from pydantic import BaseModel
from typing_extensions import Self


class EmmaExtractedFeatures(BaseModel):
Expand All @@ -14,7 +13,7 @@ class EmmaExtractedFeatures(BaseModel):
bbox_probas: torch.Tensor
cnn_features: torch.Tensor
class_labels: list[str]
entity_labels: list[str] | None = None
entity_labels: Optional[list[str]] = None
width: int
height: int

Expand All @@ -24,7 +23,7 @@ class Config:
arbitrary_types_allowed: bool = True

@classmethod
def from_raw_response(cls, raw_response: dict[str, Any]) -> EmmaExtractedFeatures:
def from_raw_response(cls, raw_response: dict[str, Any]) -> Self:
"""Instantiate the features from a raw json response.
Dict keys that are used below can be found within the emma-simbot/perception repo.
Expand Down
5 changes: 2 additions & 3 deletions src/emma_common/datamodels/state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel

Expand All @@ -25,7 +24,7 @@ class EnvironmentStateTurn(BaseModel):
"""State of the environment at a single timestep."""

features: list[EmmaExtractedFeatures]
output: str | None = None
output: Optional[str] = None


class EmmaPolicyRequest(BaseModel):
Expand Down
4 changes: 1 addition & 3 deletions src/emma_common/datamodels/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class TorchDataMixin:
"""A utility class containing useful functions for torch serialisation."""

@staticmethod
def to_bytes( # noqa: WPS602
raw_object: Any,
) -> bytes:
def to_bytes(raw_object: Any) -> bytes: # noqa: WPS602
"""Factory method that builds a byte representation from a raw object."""
buffer = io.BytesIO()
torch.save(raw_object, buffer)
Expand Down

0 comments on commit 0c38415

Please sign in to comment.