Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure jupyter server extension #101

Open
banesullivan opened this issue Jul 18, 2022 · 7 comments
Open

Configure jupyter server extension #101

banesullivan opened this issue Jul 18, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@banesullivan
Copy link
Owner

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 #95

cc @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"

@artttt
Copy link

artttt commented Jan 20, 2023

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:
davidbrochart/ipyurl#2 (comment)

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

@banesullivan
Copy link
Owner Author

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 😄 )

@giswqs
Copy link
Contributor

giswqs commented Jan 20, 2023

@artttt Could your solution work on AWS SageMaker?

@banesullivan
Copy link
Owner Author

banesullivan commented Jan 20, 2023

Sorry for my delay looking into SageMaker, @giswqs 😄 ... tough to find time for this hobby project at the moment

(ref #128)

@giswqs
Copy link
Contributor

giswqs commented Jan 20, 2023

@banesullivan No worries. Let's explore this.

@artttt
Copy link

artttt commented Jan 23, 2023

@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.
davidbrochart/ipyurl#2 (comment)

@giswqs
Copy link
Contributor

giswqs commented Jul 26, 2023

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}}"

davidbrochart/ipyurl#2 (comment)
image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants