fixed argument types
This commit is contained in:
@@ -12,8 +12,8 @@ from PIL import Image
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pymongo.collection import Collection
|
||||
|
||||
from shared.datastore import get, put
|
||||
from shared.mongodb.classes import ModelData
|
||||
from shared.datastore import get_image, put_image
|
||||
from shared.mongodb.src.classes import ModelData
|
||||
|
||||
|
||||
class VisualCommunication(BaseModel):
|
||||
@@ -39,11 +39,9 @@ class VisualCommunication(BaseModel):
|
||||
"""Upload image to MinIO and return MD5 checksum of hashed image."""
|
||||
assert isinstance(image, Image.Image)
|
||||
assert isinstance(minio_client, Minio)
|
||||
buffer = BytesIO()
|
||||
image.save(buffer, 'png')
|
||||
object_name = put(
|
||||
object_name = put_image(
|
||||
client=minio_client,
|
||||
buffer=buffer,
|
||||
image=image,
|
||||
)
|
||||
return object_name
|
||||
|
||||
@@ -92,14 +90,12 @@ class VisualCommunication(BaseModel):
|
||||
def get_image(self, minio_client: Minio) -> Image.Image:
|
||||
"""Load image data from minio."""
|
||||
assert isinstance(minio_client, Minio)
|
||||
# get buffer from minio
|
||||
buffer = get(
|
||||
# get image from minio
|
||||
image = get_image(
|
||||
client=minio_client,
|
||||
object_name=self.object_name,
|
||||
)
|
||||
# convert data to image
|
||||
im = Image.open(buffer)
|
||||
return im
|
||||
return image
|
||||
|
||||
def save_to_mongo(self, collection: Collection) -> None:
|
||||
"""Save self as document in MongoDB."""
|
||||
|
||||
Reference in New Issue
Block a user