dieterich-lab / rp-bp

Rp-Bp is a Bayesian approach to predict, at base-pair resolution, ribosome occupancy and translation.
MIT License
7 stars 5 forks source link

Apps don't work with docker #150

Closed eboileau closed 1 year ago

eboileau commented 1 year ago

Description

Using the package(s) built on Azure, we can still test if the apps work with the containers. They don't, or I haven't been able to make it work.

Expected behavior

We should be able to launch the apps using Docker or Singularity.

To Reproduce

I prepared a minimal example

wget https://data.dieterichlab.org/s/Te9tdP6ifMLM5D8/download -O docker_app.zip && unzip docker_app.zip && cd docker_app
docker run -p 8050:8080 --volume `pwd`:/data quay.io/biocontainers/rp-bp:3.0.0--py310h9f5acd7_0 rpbp-predictions-dashboard /data/c-elegans-test.yaml

I don't know if there is a default port, I tried a few, but none works. I never built a dockerised app, but this is a bit different here, I don't know if there are examples similar to what we do?

Output

... can’t establish a connection to the server at localhost:8050.

Environment

dokempf commented 1 year ago

I cannot reproduce right now, because my bandwidth struggles with the containers, but the command you wrote has a typo in the port mapping. The second port being inside the container it needs to be 8050, e.g. 8050:8050.

lkeegan commented 1 year ago

In addition to the typo @dokempf mentions, when running a web server inside a docker container its "localhost" is inside the container itself and is not the same as your "localhost" (unless you use the --network="host" option but this only works on linux).

To expose the web server outside the docker container you can set the host to 0.0.0.0 (bind to all interfaces) inside the container:

sudo docker run -p 8050:8050 --volume `pwd`:/data quay.io/biocontainers/rp-bp:3.0.0--py310h9f5acd7_0 rpbp-predictions-dashboard --host "0.0.0.0" /data/c-elegans-test.yaml

For me I then see a dashboard (although also a FileNotFoundError: [Errno 2] No such file or directory: '/data/WBcel235.chrI.fa.fai' in the logs, maybe the symlinks issue you mentioned?)

eboileau commented 1 year ago

Ok, thanks, indeed the --host "0.0.0.0" was missing. As for the file, my bad, it was missing from the example. I have now added it, so if you do

wget https://data.dieterichlab.org/s/Te9tdP6ifMLM5D8/download -O docker_app.zip && unzip docker_app.zip && cd docker_app
docker run -p 8050:8050 --volume `pwd`:/data quay.io/biocontainers/rp-bp:3.0.0--py310h9f5acd7_0 rpbp-predictions-dashboard /data/c-elegans-test.yaml --host="0.0.0.0"

the app works fine (I haven't yest tested the other one though), however the layout is completely distorted, as assets folder is not found (404). There are a few suggested solutions... such as

app = dash.Dash(
    __name__,
    assets_external_path=... # relative path? would work for images and css?
)
# to be used with serve_locally=False, but what are the implications?

or app = dash.Dash(__name__, external_stylesheets=./assets/style.css) # only for style sheet

Please advise if possible. Thanks.

eboileau commented 1 year ago

There is also assets_folder option... but it defaults to 'assets'... so this doesn't seem to work with docker...

lkeegan commented 1 year ago

This isn't a docker-specific issue - it also occurs for me with a local install

You create the dash app with App(__name__) which dash uses to find the location of the current module, and then it automatically loads anything from the assets folder there.

The problem is that the assets folder is not currently installed.

If I add this line to MANIFEST.in & re-install then the assets folder is installed and found automatically by dash (for a local install, haven't tried with docker but the same logic should apply):

include src/rpbp/analysis/rpbp_predictions/dashboard/assets/*.*
eboileau commented 1 year ago

That would be the simplest solution. I guess we can't try it now with containers, but this should indeed work.

lkeegan commented 1 year ago

Now tested & working with docker container built here: https://github.com/bioconda/bioconda-recipes/pull/39210

eboileau commented 1 year ago

This

docker run -p 8050:8050 --volume `pwd`:/data quay.io/biocontainers/rpbp:3.0.1--py37h96cfd12_0 rpbp-predictions-dashboard /data/c-elegans-test.yaml --host="0.0.0.0"

works fine,

172.17.0.1 - - [06/Mar/2023 09:52:54] "GET / HTTP/1.1" 200 - 172.17.0.1 - - [06/Mar/2023 09:52:54] "GET /assets/style.css?m=1677687035.0 HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:54] "GET /_dash-component-suites/dash_bio/bundle.v1_0_2m1647667389.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_dash-layout HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_dash-dependencies HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_favicon.ico?v=2.8.1 HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /assets/logo-rpbp.png HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_dash-component-suites/dash/dcc/async-markdown.js HTTP/1.1" 304 - 

172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_dash-component-suites/dash/dash_table/async-highlight.js HTTP/1.1" 200 -

 172.17.0.1 - - [06/Mar/2023 09:52:55] "GET /_dash-component-suites/dash/dash_table/async-table.js HTTP/1.1" 200 -

...

but

docker run -p 8050:8050 --volume `pwd`:/data quay.io/biocontainers/rpbp:3.0.1--py37h96cfd12_0 rpbp-profile-construction-dashboard /data/c-elegans-test.yaml --host="0.0.0.0"

not, cf.

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET / HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/deps/polyfill@7.v2_8_1m1675174511.12.1.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/deps/react@16.v2_8_1m1675174511.14.0.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/deps/prop-types@15.v2_8_1m1675174511.8.1.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash_bootstrap_components/_components/dash_bootstrap_components.v1_4_0m1677548663.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/deps/react-dom@16.v2_8_1m1675174511.14.0.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_8_1m1675174511.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/dcc/dash_core_components-shared.v2_8_0m1675174511.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/html/dash_html_components.v2_0_8m1675174511.min.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/dcc/dash_core_components.v2_8_0m1675174511.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-component-suites/dash/dash_table/bundle.v5_2_2m1675174511.js HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-layout HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:27] "GET /_dash-dependencies HTTP/1.1" 200 -

 172.17.0.1 - - [06/Mar/2023 09:48:28] "GET /_favicon.ico?v=2.8.1 HTTP/1.1" 200 - 

172.17.0.1 - - [06/Mar/2023 09:48:28] "GET /assets/logo-rpbp.png HTTP/1.1" 404 -

...

The display is distorted, as it doesn't find the assets. I don't know why this works with one, but not the other...

I'll update the dataset above to include the profile construction data.

lkeegan commented 1 year ago

This is because the assets from this folder are not listed in MANIFEST.in and so are not installed.

Sorry I didn't notice there were two separate dashboards each with their own assets folder..

eboileau commented 1 year ago

Indeed, I also just noticed it... I completely overlooked that!

eboileau commented 1 year ago

So we do need a patch release...

lkeegan commented 1 year ago

Yes - but maybe it would make sense to try using it for a bit and see if anything else comes up before making the release?

eboileau commented 1 year ago

Indeed, that was my intention. I have some data waiting to be analysed, etc. And also I have some old related code here https://github.com/eboileau/pyproc-utils that I might have to clean-up and update to work with this new release.