Open banesullivan opened 2 years ago
Hi Bane, Am i right to assume that the idea here is to grab the url from a users browser window and parse it to set up licaltileserver?
If so have a look at my code here: https://github.com/davidbrochart/ipyurl/issues/2#issuecomment-1397803934
ive been using this in the jupyterhub environment i work on successfully to set up localtileserver with the following code
import os
import urllib
def init_hub():
'''
initialises environment variables needed to make localtileserver work on jupyter hub
'''
url = window_url()
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = f"{os.environ['JUPYTERHUB_SERVICE_PREFIX'].lstrip('/')}proxy/{{port}}"
up = urllib.parse.urlparse(url)
os.environ["LOCALTILESERVER_CLIENT_HOST"] = url[: -(len(up.path))].rstrip("/") + "/"
I hope that helps
Am i right to assume that the idea here is to grab the url from a users browser window and parse it to set up licaltileserver?
That is one way to go about it if you can get it to work (I struggled to initially).
ive been using this in the jupyterhub environment i work on successfully to set up localtileserver with the following code
This is fantastic! Thank you for sharing! I will test this out when I have some time (localtileserver
is hobby project so it can be tough for me to make proper time to address things 😄 )
@artttt Could your solution work on AWS SageMaker?
Sorry for my delay looking into SageMaker, @giswqs 😄 ... tough to find time for this hobby project at the moment
(ref #128)
@banesullivan No worries. Let's explore this.
@giswqs ive not tried AWS SageMaker so im not sure but as long as you can install the required package/s then it is worth a try. You may have to modify the parsing of the url to suit. Hopefully @banesullivan gets a chance to incorporate a generic solution into localtileserver
.
Note: i've updated the comment that i linked to above with an additional code sample. https://github.com/davidbrochart/ipyurl/issues/2#issuecomment-1397803934
I just tried the method @artttt provided on SageMaker Studio, it does not work. Any other method for getting the URL prefix?
Note that it is SageMaker Studio, not Studio Lab. They are different products. The method that works for Studio Lab does not work for SageMaker Studio
import os
os.environ['LOCALTILESERVER_CLIENT_PREFIX'] = f"studiolab/default/jupyter/proxy/{{port}}"
https://github.com/davidbrochart/ipyurl/issues/2#issuecomment-1397803934
I'd like to see if we could use a jupyter-server extension to improve using
localtileserver
in remote jupyter environments to resolve issues like #95cc @12rambau
reference: https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html#server-extensions
when I get some free time, I will look into this and hopefully implement a solution that will "just work"