multiple bokeh apps using one server - name collision?

Hi,

I am running multiple bokeh apps like this:

$ bokeh serve app1/ app2/

but I have problems if the apps have a python module with the same name. The example below can be used to reproduce the problem

app1/

├── layout.py

└── main.py

app2/

├── layout.py

└── main.py

$ cat app1/main.py

from bokeh.io import curdoc

import layout

curdoc().title = “My App 1”

$ cat app1/layout.py

print(“Importing layout for My app 1”)

···

Angelo Fausti

Hi,

let me explain the motivation behind my previous question.

When developing more complex visualizations with bokeh, for example https://squash-demo.lsst.codes/dash/monitor/ I find it hard to maintain the code in a single file, so I tried to separate the application layout from the interactions and the data loading like this:

├── monitor

│ ├── base.py

│ ├── interactions.py

│ ├── layout.py

│ ├── main.py

│ └── theme.yaml

the source code is here: https://github.com/lsst-sqre/squash-bokeh/tree/master/app/monitor

the problem is that if I have another app and start both on a single bokeh server:

bokeh serve monitor/ AMx/

I have to rename the files to avoid the “name collision” as explained before.

├── AMx

│ ├── amx_base.py

│ ├── amx_interactions.py

│ ├── amx_layout.py

│ ├── main.py

├── monitor

│ ├── base.py

│ ├── interactions.py

│ ├── layout.py

│ ├── main.py

│ └── theme.yaml

I was wondering if that is a bug or a feature of the “multiple bokeh apps using one server” model, and what would you recommend for developing more complex apps.

thanks,

···

On Mon, Apr 16, 2018 at 2:13 PM, Angelo Fausti [email protected] wrote:

Hi,

I am running multiple bokeh apps like this:

$ bokeh serve app1/ app2/

but I have problems if the apps have a python module with the same name. The example below can be used to reproduce the problem

app1/

├── layout.py

└── main.py

app2/

├── layout.py

└── main.py

$ cat app1/main.py

from bokeh.io import curdoc

import layout

curdoc().title = “My App 1”

$ cat app1/layout.py

print(“Importing layout for My app 1”)


$ cat app2/main.py

from bokeh.io import curdoc

import layout

curdoc().title = “My App 2”

$ cat app2/layout.py

print(“Importing layout for My app 2”)

If I run bokeh serve and load app1 first and then app2 I get:

$ bokeh serve app1/ app2/

2018-04-16 13:41:31,424 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)

2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app1

2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app2

2018-04-16 13:41:31,431 Starting Bokeh server with process id: 23343

Importing layout for My app 1

2018-04-16 13:41:37,683 200 GET /app1 (::1) 37.54ms

2018-04-16 13:41:37,834 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=VMrctqs4mhSot4rRg5fKstHdf9fzh6Tu79AhX0iHfhGA (::1) 0.78ms

2018-04-16 13:41:37,834 WebSocket connection opened

2018-04-16 13:41:37,834 ServerConnection created

2018-04-16 13:41:44,180 200 GET /app2 (::1) 4.45ms

2018-04-16 13:41:44,187 WebSocket connection closed: code=1001, reason=None

2018-04-16 13:41:44,308 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=Plh8OFoLBlCLgOyrL4F6R4en5Bn9ASCZTMvhMXYPjRAz (::1) 0.65ms

2018-04-16 13:41:44,308 WebSocket connection opened

2018-04-16 13:41:44,309 ServerConnection created

However, loading app2 first and then app1 I get:

$ bokeh serve app1/ app2/

2018-04-16 13:42:39,666 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)

2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app1

2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app2

2018-04-16 13:42:39,675 Starting Bokeh server with process id: 23364

Importing layout for My app 2

2018-04-16 13:42:47,741 200 GET /app2 (::1) 38.12ms

2018-04-16 13:42:47,860 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=ImsMhlrF4052du8Tm3F89i21FBSsjnMR5XgTrJ5JqZbM (::1) 0.77ms

2018-04-16 13:42:47,860 WebSocket connection opened

2018-04-16 13:42:47,861 ServerConnection created

2018-04-16 13:42:54,152 200 GET /app1 (::1) 6.23ms

2018-04-16 13:42:54,617 WebSocket connection closed: code=1001, reason=None

2018-04-16 13:42:54,743 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=35QKAk7l9SkRFK4GfUbhl8l1wc69JcWJFZtFQQ63qtwM (::1) 0.66ms

2018-04-16 13:42:54,743 WebSocket connection opened

2018-04-16 13:42:54,744 ServerConnection created

Note that layout.py is not imported by the second app.

I’ve tried a relative import without success

from .layout import *

ModuleNotFoundError: No module named ‘bk_script_fbca4a0f3e7e4582ada12154b4ff20fe.layout’; ‘bk_script_fbca4a0f3e7e4582ada12154b4ff20fe’ is not a package

Is there a way to solve this running the apps on a single server (and same port) without renaming the python modules?

Angelo Fausti

Angelo Fausti

Hi,

This is probably worth making a GitHub issue about, it will probably require some investigation.

Thanks,

Bryan

···

On Apr 19, 2018, at 18:07, Angelo Fausti <[email protected]> wrote:

Hi,

let me explain the motivation behind my previous question.

When developing more complex visualizations with bokeh, for example https://squash-demo.lsst.codes/dash/monitor/ I find it hard to maintain the code in a single file, so I tried to separate the application layout from the interactions and the data loading like this:

├── monitor
│ ├── base.py
│ ├── interactions.py
│ ├── layout.py
│ ├── main.py
│ └── theme.yaml

the source code is here: https://github.com/lsst-sqre/squash-bokeh/tree/master/app/monitor

the problem is that if I have another app and start both on a single bokeh server:

bokeh serve monitor/ AMx/

I have to rename the files to avoid the "name collision" as explained before.

├── AMx
│ ├── amx_base.py
│ ├── amx_interactions.py
│ ├── amx_layout.py
│ ├── main.py
├── monitor
│ ├── base.py
│ ├── interactions.py
│ ├── layout.py
│ ├── main.py
│ └── theme.yaml

I was wondering if that is a bug or a feature of the "multiple bokeh apps using one server" model, and what would you recommend for developing more complex apps.

thanks,

Angelo Fausti

On Mon, Apr 16, 2018 at 2:13 PM, Angelo Fausti <[email protected]> wrote:

Hi,

I am running multiple bokeh apps like this:

$ bokeh serve app1/ app2/

but I have problems if the apps have a python module with the same name. The example below can be used to reproduce the problem

app1/
├── layout.py
└── main.py

app2/
├── layout.py
└── main.py

$ cat app1/main.py

from bokeh.io import curdoc
import layout

curdoc().title = "My App 1"

$ cat app1/layout.py

print("Importing layout for My app 1")

------------

$ cat app2/main.py

from bokeh.io import curdoc
import layout

curdoc().title = "My App 2"

$ cat app2/layout.py
print("Importing layout for My app 2")

If I run bokeh serve and load app1 first and then app2 I get:

$ bokeh serve app1/ app2/
2018-04-16 13:41:31,424 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)
2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app1
2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app2
2018-04-16 13:41:31,431 Starting Bokeh server with process id: 23343
Importing layout for My app 1
2018-04-16 13:41:37,683 200 GET /app1 (::1) 37.54ms
2018-04-16 13:41:37,834 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=VMrctqs4mhSot4rRg5fKstHdf9fzh6Tu79AhX0iHfhGA (::1) 0.78ms
2018-04-16 13:41:37,834 WebSocket connection opened
2018-04-16 13:41:37,834 ServerConnection created
2018-04-16 13:41:44,180 200 GET /app2 (::1) 4.45ms
2018-04-16 13:41:44,187 WebSocket connection closed: code=1001, reason=None
2018-04-16 13:41:44,308 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=Plh8OFoLBlCLgOyrL4F6R4en5Bn9ASCZTMvhMXYPjRAz (::1) 0.65ms
2018-04-16 13:41:44,308 WebSocket connection opened
2018-04-16 13:41:44,309 ServerConnection created

However, loading app2 first and then app1 I get:

$ bokeh serve app1/ app2/
2018-04-16 13:42:39,666 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)
2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app1
2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app2
2018-04-16 13:42:39,675 Starting Bokeh server with process id: 23364
Importing layout for My app 2
2018-04-16 13:42:47,741 200 GET /app2 (::1) 38.12ms
2018-04-16 13:42:47,860 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=ImsMhlrF4052du8Tm3F89i21FBSsjnMR5XgTrJ5JqZbM (::1) 0.77ms
2018-04-16 13:42:47,860 WebSocket connection opened
2018-04-16 13:42:47,861 ServerConnection created
2018-04-16 13:42:54,152 200 GET /app1 (::1) 6.23ms
2018-04-16 13:42:54,617 WebSocket connection closed: code=1001, reason=None
2018-04-16 13:42:54,743 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=35QKAk7l9SkRFK4GfUbhl8l1wc69JcWJFZtFQQ63qtwM (::1) 0.66ms
2018-04-16 13:42:54,743 WebSocket connection opened
2018-04-16 13:42:54,744 ServerConnection created

Note that layout.py is not imported by the second app.

I've tried a relative import without success

    from .layout import *
ModuleNotFoundError: No module named 'bk_script_fbca4a0f3e7e4582ada12154b4ff20fe.layout'; 'bk_script_fbca4a0f3e7e4582ada12154b4ff20fe' is not a package

Is there a way to solve this running the apps on a single server (and same port) without renaming the python modules?

Angelo Fausti

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5OwA%3DJVVrJT621DmTsAe1_z4hdBfsjmrimEyntBEhLhqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan!

For the record https://github.com/bokeh/bokeh/issues/7826

···

On Fri, Apr 20, 2018 at 7:56 AM, Bryan Van de ven [email protected] wrote:

Hi,

This is probably worth making a GitHub issue about, it will probably require some investigation.

Thanks,

Bryan

On Apr 19, 2018, at 18:07, Angelo Fausti [email protected] wrote:

Hi,

let me explain the motivation behind my previous question.

When developing more complex visualizations with bokeh, for example https://squash-demo.lsst.codes/dash/monitor/ I find it hard to maintain the code in a single file, so I tried to separate the application layout from the interactions and the data loading like this:

├── monitor

│ ├── base.py

│ ├── interactions.py

│ ├── layout.py

│ ├── main.py

│ └── theme.yaml

the source code is here: https://github.com/lsst-sqre/squash-bokeh/tree/master/app/monitor

the problem is that if I have another app and start both on a single bokeh server:

bokeh serve monitor/ AMx/

I have to rename the files to avoid the “name collision” as explained before.

├── AMx

│ ├── amx_base.py

│ ├── amx_interactions.py

│ ├── amx_layout.py

│ ├── main.py

├── monitor

│ ├── base.py

│ ├── interactions.py

│ ├── layout.py

│ ├── main.py

│ └── theme.yaml

I was wondering if that is a bug or a feature of the “multiple bokeh apps using one server” model, and what would you recommend for developing more complex apps.

thanks,

Angelo Fausti

On Mon, Apr 16, 2018 at 2:13 PM, Angelo Fausti [email protected] wrote:

Hi,

I am running multiple bokeh apps like this:

$ bokeh serve app1/ app2/

but I have problems if the apps have a python module with the same name. The example below can be used to reproduce the problem

app1/

├── layout.py

└── main.py

app2/

├── layout.py

└── main.py

$ cat app1/main.py

from bokeh.io import curdoc

import layout

curdoc().title = “My App 1”

$ cat app1/layout.py

print(“Importing layout for My app 1”)


$ cat app2/main.py

from bokeh.io import curdoc

import layout

curdoc().title = “My App 2”

$ cat app2/layout.py

print(“Importing layout for My app 2”)

If I run bokeh serve and load app1 first and then app2 I get:

$ bokeh serve app1/ app2/

2018-04-16 13:41:31,424 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)

2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app1

2018-04-16 13:41:31,430 Bokeh app running at: http://localhost:5006/app2

2018-04-16 13:41:31,431 Starting Bokeh server with process id: 23343

Importing layout for My app 1

2018-04-16 13:41:37,683 200 GET /app1 (::1) 37.54ms

2018-04-16 13:41:37,834 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=VMrctqs4mhSot4rRg5fKstHdf9fzh6Tu79AhX0iHfhGA (::1) 0.78ms

2018-04-16 13:41:37,834 WebSocket connection opened

2018-04-16 13:41:37,834 ServerConnection created

2018-04-16 13:41:44,180 200 GET /app2 (::1) 4.45ms

2018-04-16 13:41:44,187 WebSocket connection closed: code=1001, reason=None

2018-04-16 13:41:44,308 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=Plh8OFoLBlCLgOyrL4F6R4en5Bn9ASCZTMvhMXYPjRAz (::1) 0.65ms

2018-04-16 13:41:44,308 WebSocket connection opened

2018-04-16 13:41:44,309 ServerConnection created

However, loading app2 first and then app1 I get:

$ bokeh serve app1/ app2/

2018-04-16 13:42:39,666 Starting Bokeh server version 0.12.15 (running on Tornado 5.0.1)

2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app1

2018-04-16 13:42:39,675 Bokeh app running at: http://localhost:5006/app2

2018-04-16 13:42:39,675 Starting Bokeh server with process id: 23364

Importing layout for My app 2

2018-04-16 13:42:47,741 200 GET /app2 (::1) 38.12ms

2018-04-16 13:42:47,860 101 GET /app2/ws?bokeh-protocol-version=1.0&bokeh-session-id=ImsMhlrF4052du8Tm3F89i21FBSsjnMR5XgTrJ5JqZbM (::1) 0.77ms

2018-04-16 13:42:47,860 WebSocket connection opened

2018-04-16 13:42:47,861 ServerConnection created

2018-04-16 13:42:54,152 200 GET /app1 (::1) 6.23ms

2018-04-16 13:42:54,617 WebSocket connection closed: code=1001, reason=None

2018-04-16 13:42:54,743 101 GET /app1/ws?bokeh-protocol-version=1.0&bokeh-session-id=35QKAk7l9SkRFK4GfUbhl8l1wc69JcWJFZtFQQ63qtwM (::1) 0.66ms

2018-04-16 13:42:54,743 WebSocket connection opened

2018-04-16 13:42:54,744 ServerConnection created

Note that layout.py is not imported by the second app.

I’ve tried a relative import without success

from .layout import *

ModuleNotFoundError: No module named ‘bk_script_fbca4a0f3e7e4582ada12154b4ff20fe.layout’; ‘bk_script_fbca4a0f3e7e4582ada12154b4ff20fe’ is not a package

Is there a way to solve this running the apps on a single server (and same port) without renaming the python modules?

Angelo Fausti

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5OwA%3DJVVrJT621DmTsAe1_z4hdBfsjmrimEyntBEhLhqQ%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5320A5E9-F132-4ADC-9F7D-EB66E0F79856%40anaconda.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Angelo Fausti