My app only loads properly some of the time

I have successfully published an app to the shinyapps.io site and it utilizes reticulate to run saved models (made with keras) in python. Interestingly, when I go to the shinyapps.io site that hosts this app, it sometimes says Disconnected from server and isn't able to reload. When I look at the logs when that happens it says keras not found. However, other times it works just fine and the logs show that everything is working properly. As far as I can tell I'm not doing anything differently in these situations.

I will be sending this to others very soon (turning it in) and would like for it to be working reliably.
logs.pdf (44.8 KB)

Thank you!

EDIT: uploading the logs here too.

I am uploading the logs -- it includes an example of both when it has worked and when it hasn't. The error Warning: Error in py_run_file_impl: ImportError: No module named kerasis indicative of when it doesn't work, and when you see I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2900060000 it is running properly. I don't have much experience debugging from logs, and am not sure what to make of what I'm seeing.logs.pdf (44.8 KB)

2 Likes

it seems keras install in a different working directory. You can provide a more reproducible example by reprex package.

@esulli I am also experiencing this problem. My app (on shinyapps server) sometimes works and sometimes it doesn't. Most of the time it doesn't.

I've run the code in deployment one line at a time (see screenshot) and there are no errors until Import function is needed.

My code
virtualenv_create(envname = "python_environment")
virtualenv_install("python_environment", c('pandas', 'snowflake.sqlalchemy', 'sqlalchemy'))
use_virtualenv("python_environment")
pd = import("pandas")

On Shiny Server

1 Like

On my local computer (same exact code as above)

1 Like