GithubHelp home page GithubHelp logo

Comments (16)

banesullivan avatar banesullivan commented on July 28, 2024 1

It's as simple as:

from localtileserver import get_leaflet_tile_layer, examples, TileClient
from ipyleaflet import Map

client = TileClient(examples.get_data_path("bahamas_rgb.tif"))
client.client_host = f'localhost:{client.server.port}'

t = get_leaflet_tile_layer(client)

m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m

But I'll make this a little easier in the next release

Screen Shot 2023-01-29 at 9 01 48 PM

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024 1

yeah... ran into that too... Google Colab installs GDAL and their build is wack (and missing that module). This was handled in afe669c and will be good on the next release

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024 1

The reason it works is actually pretty specific to colab supporting this localhost remapping. Reference https://colab.research.google.com/notebooks/snippets/advanced_outputs.ipynb

Outputs in the browser can request resources from the kernel by requesting https://localhost:{port}. The protocol will automatically be translated from https to http and the localhost will be the kernel executing the code.

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

@giswqs, it's been a long time since I've used Colab. Could you post a link to a repo and session I could launch to debug this?

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

Here it is
https://colab.research.google.com/drive/1tWU1Th_qmOLbixbW2HUCUW7eXEvf0Xgs?usp=sharing

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

I have no idea how to do this on google colab. It's seemingly not a Jupyter Hub/Lab instance and I have absolutely no idea how to expose a port on the runner. jupyter-server-proxy is really the only safe way to do this in cloud environments and I don't think that's possible with google colab

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

This is actually really easy! I figured it out while trying to get this to work for PyVista in pyvista/pyvista#3851

I'll see if I can add support directly in localtileserver

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

@banesullivan That's awesome to hear. Can't wait to try it out.

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

Excited to try this out. Got an error. I should probably wait for the next release.
image

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

So, this is fixed by de4d2ef

What do you think, @giswqs?

from localtileserver import get_leaflet_tile_layer, examples, TileClient
from ipyleaflet import Map

path = examples.get_data_path("bahamas_rgb.tif")

client = TileClient(path)
client.enable_colab()

t = get_leaflet_tile_layer(client)

m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

This gives me hope that localtileserver might work with all major Jupyter notebook platforms, including AWS SageMaker.

client.client_host = f'localhost:{client.server.port}'

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

You may not need that client.enable_colab() explicitly. You might be able to integrate this into TileClient.

import sys
if "google.colab" in sys.modules:
  self.client_host = "localhost"
  self.client_port = True

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

Ah, good point. This assumes google.clolab is only ever installed on colab... which is probably a safe assumption

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

Correct. The google.colab module can only be found on Colab. That module can't be found on any other Jupyter platforms or local computers.

from localtileserver.

banesullivan avatar banesullivan commented on July 28, 2024

Check out https://colab.research.google.com/drive/1h1iTDl4KqbXxKiyox9eM211vAg6_ONKT?usp=sharing (you have to restart the runtime after installing localtileserver)

0.6.4 now autodetects google colab and all should work

from localtileserver.

giswqs avatar giswqs commented on July 28, 2024

It worked like a charm! Thank you very much for this!

from localtileserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.