dwavesystems / dwave-inspector

D-Wave Problem Inspector
https://docs.ocean.dwavesys.com/projects/inspector/
Apache License 2.0
8 stars 17 forks source link

Add support for `jupyter-server-proxy` #144

Closed randomir closed 1 year ago

randomir commented 1 year ago

Using proxy support implemented in #143, it should be easy to support jupyter-server-proxy for users that run Jupyter through reverse proxy.

randomir commented 1 year ago

To test, assuming jupyter-server-proxy is installed, run:

DWAVE_INSPECTOR_JUPYTER_SERVER_PROXY_EXTERNAL_URL='http://127.0.0.1:8888/' jupyter notebook --NotebookApp.token=''

Note: currently, jupyter-based auth is not supported (hence the token is unset above) (root cause: #150).

Open Jupyter notebook and run:

import dimod
import dwave.inspector
from dwave.system import DWaveSampler, EmbeddingComposite

# define problem
bqm = dimod.BQM.from_ising({}, {'ab': 1, 'bc': 1, 'ca': 1})

# get sampler
sampler = EmbeddingComposite(DWaveSampler(solver='Advantage_system4.1'))

# sample
sampleset = sampler.sample(bqm, num_reads=100)

then open the Inspector with:

dwave.inspector.show(sampleset)

Now notice that no request goes to http://localhost:18000 (the location of the inspector server) -- rather inspector requests are proxied via http://127.0.0.1:8888/proxy/18000/<...>.