ai-cfia / ailab-datastore

This is a repo representing the data layer of multiple ailab projects
MIT License
2 stars 0 forks source link

Blob not found #142

Open ChromaticPanic opened 2 months ago

ChromaticPanic commented 2 months ago

I'm getting a bob not found error

[ "Datastore Error retrieving the picture : The specified blob does not exist.\nRequestId:628986d5-601e-0060-7c8d-fdb62e000000\nTime:2024-09-02T23:10:16.3300199Z\nErrorCode:BlobNotFound\nContent: <?xml version=\"1.0\" encoding=\"utf-8\"?>BlobNotFoundThe specified blob does not exist.\nRequestId:628986d5-601e-0060-7c8d-fdb62e000000\nTime:2024-09-02T23:10:16.3300199Z\nError getting blob:6835a15d-655a-478d-a9d4-c6bdb9230621/9b186422-0650-4b1a-87ed-521c57cedad8.png" ]

using these parameters { "user_id": "a427278e-28df-428f-8937-ddeeef44e72f", "container_name": "6835a15d-655a-478d-a9d4-c6bdb9230621", "picture_id": "9b186422-0650-4b1a-87ed-521c57cedad8" }

I'm guessing from this line 446 in app.py of nachet backend

        blob = await datastore.get_picture_blob(cursor, str(user_id), container_client, str(picture_id))
@app.post("/get-picture")
async def get_picture():
    """
    get all directories in the user's container with pictures names and number of pictures
    """
    try:
        data = await request.get_json()        
        container_name = data.get("container_name")
        user_id = data.get("user_id")
        picture_id = data.get("picture_id")

        if user_id and picture_id:

            container_client = await azure_storage.mount_container(
                CONNECTION_STRING, container_name, create_container=True
            )
            # Open db connection
            connection = datastore.get_connection()
            cursor = datastore.get_cursor(connection)

            picture = {}
            picture["picture_id"] = picture_id

            inference = await datastore.get_inference(cursor, str(user_id), str(picture_id))
            picture["inference"] = inference

            blob = await datastore.get_picture_blob(cursor, str(user_id), container_client, str(picture_id))
            image_base64 = base64.b64encode(blob)
            picture["image"] = "data:image/tiff;base64," + image_base64.decode("utf-8")

            # Close connection
            datastore.end_query(connection, cursor)
            return jsonify(picture)
        else:
            raise MissingArgumentsError("Missing container name")

    except datastore.DatastoreError as error:
        print(error)
        return jsonify([f"Datastore Error retrieving the picture : {str(error)}"]), 400
    except (KeyError, TypeError, APIError) as error:
        print(error)
        return jsonify([f"API Error retrieving the picture : {str(error)}"]), 400
    except Exception as error :
        print(error)
        return jsonify(["Unhandled API error : Error retrieving the picture"]), 400
ChromaticPanic commented 2 months ago

@Francois-Werbrouck What do you think is causing this? I don't have access to blob storage so not sure if doesn't exist or if there is a bug in the datastore module

You can try running this branch, it displays the contents of the folders on the frontend https://github.com/ai-cfia/nachet-frontend/pull/188

Francois-Werbrouck commented 1 month ago

Sorry for the delay. I'm unsure what is causing this I could try to directly search the DB to find if these exists.

More details on what the prior operations were before receiving this error would also help narrowing the scope of where to look for this issue. @ChromaticPanic

I'll take a deeper look into this soon

ChromaticPanic commented 1 month ago

Sorry for the delay. I'm unsure what is causing this I could try to directly search the DB to find if these exists.

More details on what the prior operations were before receiving this error would also help narrowing the scope of where to look for this issue. @ChromaticPanic

I'll take a deeper look into this soon

Thanks! Those values were from the get directory API. So I was surprised to get the error.

I'm attempting to use the get-directory api return values to retrieve images to display on the frontend.