wjm41 / molplotly

add-on to plotly which show molecule images on mouseover!
Apache License 2.0
242 stars 25 forks source link

Plots doubled and problem closing ports #31

Open ekwan opened 1 year ago

ekwan commented 1 year ago

Hi there,

With this code, I am seeing the interactive plot appear twice:

# generate a scatter plot
fig = px.scatter(plot_df, x="umap1", y="umap2", width=600, height=600)

# add molecules to the plotly graph - returns a Dash app
app = molplotly.add_molecules(fig=fig,
                            df=plot_df,
                            smiles_col='smiles'
                            )

# run Dash app inline in notebook (or in an external server)
app.run_server(mode='inline', port=8701, height=650)

Also, when I re-rerun this cell in Jupyter Lab, I get this error:

/Users/kwaneu/sw/miniconda/miniconda3/envs/python/lib/python3.11/site-packages/dash/dash.py:516: UserWarning:

JupyterDash is deprecated, use Dash instead.
See https://dash.plotly.com/dash-in-jupyter for more details.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[49], line 11
      5 app = molplotly.add_molecules(fig=fig,
      6                             df=plot_df,
      7                             smiles_col='smiles'
      8                             )
     10 # run Dash app inline in notebook (or in an external server)
---> 11 app.run_server(mode='inline', port=8701, height=650) # height should be height+50

File ~/sw/miniconda/miniconda3/envs/python/lib/python3.11/site-packages/jupyter_dash/jupyter_app.py:222, in JupyterDash.run_server(self, mode, width, height, inline_exceptions, **kwargs)
    220 old_server = self._server_threads.get((host, port))
    221 if old_server:
--> 222     old_server.kill()
    223     old_server.join()
    224     del self._server_threads[(host, port)]

File ~/sw/miniconda/miniconda3/envs/python/lib/python3.11/site-packages/jupyter_dash/_stoppable_thread.py:16, in StoppableThread.kill(self)
     13 def kill(self):
     14     thread_id = self.get_id()
     15     res = ctypes.pythonapi.PyThreadState_SetAsyncExc(
---> 16         ctypes.c_long(thread_id), ctypes.py_object(SystemExit)
     17     )
     18     if res == 0:
     19         raise ValueError(f"Invalid thread id: {thread_id}")

TypeError: 'NoneType' object cannot be interpreted as an integer

Thanks!

asiomchen commented 11 months ago

@ekwan you could either install dash<=2.10 or use the solution I proposed in #32 (hope it would be accepted soon) to solve this problem