HendrikPN / scigym-api

API for the scigym library to curate scientific reinforcement learning environments.
0 stars 2 forks source link

bug: image upload fails #24

Open HendrikPN opened 5 years ago

HendrikPN commented 5 years ago

no module named PIL in from PIL import Image. If the module is installed, the image can be created but cannot be accessed. This error appears since PR #17

HendrikPN commented 5 years ago

Maybe it's sufficient to put Pillow==6.0.0 in requirements.txt

HendrikPN commented 5 years ago

Maybe it's sufficient to put Pillow==6.0.0 in requirements.txt

This is unimportant. As long as some version is installed, it is all good. But now it cannot find the images anymore: "GET /static/code/scigym/files/images/b479c625-cc8f-49ac-8a1a-f580f9af9bd5.png HTTP/1.1" 404 1933

HendrikPN commented 5 years ago

Okay. It is actually my fault: I used the frontend to determine the upload URL of the images from the file path. That is, the file path is e.g. code/scigym/files/images/img.png which is actually new since #17 since the BASE_DIR changed to code/scigym. The corresponding url would be localhost:8000/static/images/img.png. So we should remove code/scigym/files/ from the file path in the frontend. However, before the changes in #17 the file path would have been code/files/images/img.png so it only removed code/files/ which of course does not work. Instead, we should do this now in the backend, i.e. use a new field download_path for this. This would be in accordance to having a single source of truth.

HendrikPN commented 5 years ago

heroku still fails to upload image:

django.db.utils.ProgrammingError: column images_image.upload_path does not exist
LINE 1: ...images_image"."name", "images_image"."file_path", "images_im...
HendrikPN commented 5 years ago

https://github.com/HendrikPN/scigym-api/issues/24#issuecomment-508539823 Solved this. Had to apply heroku run:detached python manage.py migrate

HendrikPN commented 5 years ago

Still bug: Now there is nothing in the logs when an image is posted. It just throws an error... @erik-sn Do you have any idea why this still fails in heroku but works perfectly fine locally?

HendrikPN commented 5 years ago

UPDATE: It seems that every time I deploy it is missing the module PIL despite it being in the requirements.txt.

HendrikPN commented 5 years ago

So it seems that the image is being saved here and I can even verify that it exists right after its creation. However, it seems to be deleted immediately after. That is, I can run heroku run:detached ls /app/scigym/files/images/ and not see any file there. It has just vanished even though I could verify its existence by running logger.info(os.path.exists(save_path)) right after this. Something is fishy.

HendrikPN commented 5 years ago

Is this a problem with heroku?