diff --git a/app.py b/app.py index 10d902a..da5192b 100644 --- a/app.py +++ b/app.py @@ -731,7 +731,7 @@ async def new_batch_import(): container_name = data["container_name"] user_id = container_name - folder_name = data.get("folder_name") + folder_name = data["folder_name"] if folder_name == "" : folder_name = None nb_pictures = data["nb_pictures"] @@ -772,13 +772,12 @@ async def upload_picture(): container_name = data["container_name"] user_id = container_name seed_name = data["seed_name"] - seed_id = data.get("seed_id") zoom_level = data["zoom_level"] nb_seeds = data["nb_seeds"] image_base64 = data["image"] picture_set_id = data["session_id"] - if not (container_name and (seed_name or seed_id) and image_base64 and picture_set_id): + if not (container_name and seed_name and image_base64 and picture_set_id): raise BatchImportError( "wrong request arguments: either seed_name, session_id, container_name or image is wrong") @@ -789,11 +788,11 @@ async def upload_picture(): _, encoded_data = image_base64.split(",", 1) image_bytes = base64.b64decode(encoded_data) - + image_hash_value = await azure_storage.generate_hash(image_bytes) connection = datastore.get_connection() cursor = datastore.get_cursor(connection) - response = await datastore.upload_pictures(cursor, user_id, picture_set_id, container_client, [image_bytes], seed_name, seed_id, zoom_level, nb_seeds) + response = await datastore.upload_pictures(cursor, user_id, picture_set_id, container_client, [image_hash_value], seed_name, zoom_level, nb_seeds) datastore.end_query(connection, cursor) if response: diff --git a/requirements.txt b/requirements.txt index 71a29f8..1291083 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ cryptography pyyaml pydantic python-magic -nachet-datastore @git+https://github.com/ai-cfia/ailab-datastore.git@bd098c342b45e1cf710cc7ab807182d510ed5553 +nachet-datastore @git+https://github.com/ai-cfia/ailab-datastore.git@main diff --git a/storage/datastore_storage_api.py b/storage/datastore_storage_api.py index 9955efc..cb7dcc3 100644 --- a/storage/datastore_storage_api.py +++ b/storage/datastore_storage_api.py @@ -103,9 +103,9 @@ async def get_picture_id(cursor, user_id, image, container_client) : picture_id = await nachet_datastore.upload_picture_unknown(cursor, str(user_id), image, container_client) return picture_id -def upload_pictures(cursor, user_id, picture_set_id, container_client, pictures, seed_name, seed_id: str, zoom_level: float = None, nb_seeds: int = None) : +def upload_pictures(cursor, user_id, picture_set_id, container_client, pictures, seed_name: str, zoom_level: float = None, nb_seeds: int = None) : try : - return nachet_datastore.upload_pictures(cursor, user_id, picture_set_id, container_client, pictures, seed_name, seed_id, zoom_level, nb_seeds) + return nachet_datastore.upload_pictures(cursor, user_id, picture_set_id, container_client, pictures, seed_name, zoom_level, nb_seeds) except Exception as error: raise DatastoreError(error) diff --git a/tests/test_image_batch_import.py b/tests/test_image_batch_import.py index b88ef4d..26f9ea7 100644 --- a/tests/test_image_batch_import.py +++ b/tests/test_image_batch_import.py @@ -164,7 +164,6 @@ def setUp(self): self.session_id = result_json.get("session_id") self.seed_name = "Ambrosia artemisiifolia" - self.seed_id = "14e96554-aadf-42e4-8665-d141354800d1" self.zoom_level = None self.nb_seeds = None current_dir = os.path.dirname(__file__) @@ -205,7 +204,6 @@ def test_upload_picture_successfull(self): "container_name": self.container_name, "session_id": self.session_id, "seed_name": self.seed_name, - "seed_id" : self.seed_id, "zoom_level": self.zoom_level, "nb_seeds": self.nb_seeds, "image": self.image @@ -232,7 +230,6 @@ def test_upload_picture_missing_arguments_error(self): "container_name": self.container_name, # missing session_id "seed_name": self.seed_name, - "seed_id" : self.seed_id, "zoom_level": self.zoom_level, "nb_seeds": self.nb_seeds, "image": self.image @@ -260,7 +257,6 @@ def test_upload_picture_wrong_arguments_error(self): "container_name": "", # wrong container_name "session_id": self.session_id, "seed_name": self.seed_name, - "seed_id" : self.seed_id, "zoom_level": self.zoom_level, "nb_seeds": self.nb_seeds, "image": self.image