-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use anywidget for viewer without jupyter-server-proxy #219
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #219 +/- ##
==========================================
- Coverage 83.52% 79.76% -3.76%
==========================================
Files 26 27 +1
Lines 1050 1102 +52
==========================================
+ Hits 877 879 +2
- Misses 173 223 +50 |
Wow, this is amazing! I am excited. This can potentially resolve the proxy issue once and for all🚀 |
I asked ChatGPT for help. See the conversations here. Not sure if it helps. |
This maybe relevant https://x.com/kylebarron2/status/1823849445575852135?s=46 |
Well @manzt had pointed me to this PR for reference, so we have some circular references going on 😉 . |
# NOTE: when calling from a thread executor, we need a different dataset handle for each thread | ||
# finding that the kernel crashes... is rio-tiler or rasterio not thread safe? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, definitely not thread safe by default. https://github.com/gjoseph92/stackstac/blob/main/stackstac/rio_reader.py Is a really cool implementation of threading for some specific rasterio drivers (e.g. COG)
|
||
# t = threading.Thread(target=target) | ||
# t.start() | ||
THREAD_EXECUTOR.submit(target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if you get much of a speedup with a threadpool executor. I would've thought the GIL would be held most of the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think I did notice a significant speed up using multiple threads -- I'll have to make a comparison exmaple
In the longer term, I'm curious if we can make this performant by having the python callback be async so that it's not blocking other tiles' requests. But that's a bit of work to get there. |
That's an interesting idea! I'll have to give this a try! Hey @kylebarron, love seeing you here -- I've seen you up to some awesome work with Lonboard! I'm curious if you're looking at localtileserver (or rio-tiler more broadly) for some raster support in Lonboard? I'd love to contribute/help (albeit my time is incredibly limited these days) |
Thank you! I'm bummed I missed the chance to say hello at scipy! The prototype I have in lonboard uses rio-tiler to manage the abstraction of getting tiles to send to the frontend. It's not really possible to make rio-tiler async, at least not with the gdal backend, so the long term goal is to have a stable async cog reader that we can use instead of gdal for COG inputs specifically |
@manzt gave an excellent talk on
anywidget
at SciPy 2024 and I was blown away! Immediately, I saw a ton of potential for the widgets I work on across localtileserver and pyvista.I thought I'd experiment with anywidget and see if I could use it to mitigate all of the issues around localtileserver's reliance on
jupyter-server-proxy
since there are countless examples of people struggling to getjupyter-server-proxy
properly configured.The changes in this PR are the result of a few hours of hacking with @manzt's help (thank you!!). This provides a fallback widget for the
_ipython_display_
method on theTileClient
class to immediately provide a working viewer for any raster after installation -- no configuration needed!Ideally, I'd like to see if I can use the comms mechanism demonstrated here when creating a TileLayer with both
ipyleaflet
andfolium
. However, I couldn't figure out how to get this widget to talk to and add itsTileLayer
element to those widgets' maps... challenge for another day.cc @giswqs