fixed deprecated import

This commit is contained in:
brian
2024-10-19 20:09:32 +00:00
parent 14ccaace95
commit d6036a95a3
9 changed files with 37 additions and 47 deletions
+8 -9
View File
@@ -1,4 +1,5 @@
"""Script to move all images from MongoDB to MinIO."""
from __future__ import annotations
import logging
@@ -9,12 +10,9 @@ from bson import ObjectId
from dotenv import load_dotenv
from pymongo.collection import Collection
from shared.data_store import connect as connect_minio
from shared.data_store import put
from shared.database import connect
from shared.database import VisualCommunication
from shared.utils import check_env
from shared.utils import setup_logging
from shared.data_store import connect_minio, put
from shared.database import VisualCommunication, connect
from shared.utils import check_env, setup_logging
def list_mongo_document_ids(
@@ -98,7 +96,7 @@ if __name__ == '__main__':
try:
# save image to buffer
buffer = BytesIO()
vis_com.image.save(buffer, 'png') # type: ignore
vis_com.image.save(buffer, 'png') # type: ignore
# put buffer in minio
object_name = put(
client=minio_client,
@@ -110,13 +108,14 @@ if __name__ == '__main__':
continue
# update visual communication in mongodb
try:
vis_com.image = None # type: ignore
vis_com.image = None # type: ignore
vis_com.object_name = object_name
update_visual_communication(collection, vis_com)
except Exception as exc:
logging.debug(exc)
logging.error(
'failed updating visual communication %s', vis_com.name,
'failed updating visual communication %s',
vis_com.name,
)
continue
logging.debug('updated visual communication %s', vis_com.name)