Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 19:45
    kcpevey commented #4592
  • 19:45
    kcpevey commented #4592
  • 19:36
    jbednar commented #4653
  • 19:34
    kcpevey commented #4592
  • 19:34
    jbednar commented #4653
  • 19:31
    jbednar transferred #516
  • 19:31
    scottyhq opened #4653
  • 19:30
    kcpevey synchronize #4592
  • 19:30

    kcpevey on add_gh_actions

    run coveralls [ci skip] (compare)

  • 19:17
    xavArtley commented #1666
  • 19:15
    philippjfr commented #1666
  • 19:13
    xavArtley commented #1666
  • 18:54
    philippjfr commented #1666
  • 18:51
    xavArtley commented #1666
  • 18:44
    rsignell-usgs commented #516
  • 18:26
    Hoxbro commented #1673
  • 17:57
    philippjfr closed #1676
  • 17:57
    philippjfr commented #1676
  • 17:57
    ceball commented #1500
  • 17:57
    jbednar commented #514
sameerCoder
@sameerCoder
How we can save panel plot/holoview plot/bokeh plot in geotiff format?
Thank you
Marc Skov Madsen
@MarcSkovMadsen
Hi @sameerCoder . I can see you have posted on Discourse https://discourse.holoviz.org/t/how-we-cann-save-panel-plot-holoview-plot-bokeh-plot-in-geotiff-format/1234. Thanks. That is the right place for questions.
Philipp Rudiger
@philippjfr
@sameerCoder I really don't know what it would mean to save a plot to GeoTIFF really.
Kim Pevey
@kcpevey

I'm dealing with a memory leak from hv.RGB. I've traced it back to the matplotlib backend (even though I'm running hv with the bokeh backend). It's possibly related to this mpl issue matplotlib/matplotlib#8519 . It may be related to this issue as well which has been labeled a bug holoviz/hvplot#501 .

Is there a workaround for NOT using mpl as the backend for hv.RGB?

Philipp Rudiger
@philippjfr
I don't know why RGB is involved at all for RGB
Kim Pevey
@kcpevey
do you mean mpl?
Philipp Rudiger
@philippjfr
Yes, sorry :laughing:
Kim Pevey
@kcpevey
yeah I don't know why it's dropping to mpl image.py as the last step. I'm running a notebook that has the bokeh ext loaded.
So it should be able to stay with bokeh?
Philipp Rudiger
@philippjfr
What is image.py?
Kim Pevey
@kcpevey
some file in mpl. I'll look it up.

This is the tracemalloc:

[ Top 10 ]
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/site-packages/matplotlib/image.py:1663: size=402 MiB, count=6, average=66.9 MiB
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/posixpath.py:368: size=445 KiB, count=3417, average=133 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/linecache.py:137: size=336 KiB, count=3244, average=106 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/inspect.py:753: size=144 KiB, count=1, average=144 KiB
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/inspect.py:750: size=144 KiB, count=1, average=144 KiB
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/site-packages/IPython/core/builtin_trap.py:63: size=9248 B, count=1, average=9248 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/site-packages/IPython/core/compilerop.py:101: size=5446 B, count=96, average=57 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/json/decoder.py:353: size=3479 B, count=44, average=79 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/site-packages/param/parameterized.py:271: size=2184 B, count=13, average=168 B
/Users/kcp/miniconda3/envs/lbm/lib/python3.8/site-packages/tornado/gen.py:191: size=2088 B, count=8, average=261 B

With the bokeh ext loaded

Philipp Rudiger
@philippjfr
I can't tell you really, something must explicitly invoking matplotlib to make that happen.
Kim Pevey
@kcpevey
img = hv.RGB.load_image(path) was the call
Philipp Rudiger
@philippjfr
Ah okay.
Surprised plt.imread would create a figure.
Kim Pevey
@kcpevey
maybe it's just using this function https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/image.py#L1642 to create the array?
Philipp Rudiger
@philippjfr
I'd suggest replacing it with a PIL based solution.
And then make a PR to HoloViews to use that in RGB.load_image.
Right I have no idea why that would leak memory.
Kim Pevey
@kcpevey

I also tried

from PIL import Image
img = hv.RGB(np.array(Image.open(path)))

with the same results

Philipp Rudiger
@philippjfr
Also tracemalloc only checks memory allocations, not leakages.
Kim Pevey
@kcpevey
still drops to mpl
Right. so when I run the above, I can watch my machine memory increase incrementally every ttime and it never drops until I shutdown the kernel
Philipp Rudiger
@philippjfr
Does an explicit gc.collect() reclaim the memory?
Kim Pevey
@kcpevey
no
Philipp Rudiger
@philippjfr

So repeatedly running:

from PIL import Image
img = hv.RGB(np.array(Image.open(path)))

increases memory usage?

Kim Pevey
@kcpevey
yes
Philipp Rudiger
@philippjfr
And this does not?
from PIL import Image
img = np.array(Image.open(path))
Kim Pevey
@kcpevey
good question. let me check
Philipp Rudiger
@philippjfr

Use this instead:

f = open(filename, 'rb')
image = Image.open(f)
image.load()
f.close()

Pillow is leaking the file pointer

Or rather use:
with open(filename, 'rb') as:
    image = np.array(Image.open(f))
And then please make a PR to HoloViews to use PIL in the same way in HoloViews.
(Replacing the imread)
Kim Pevey
@kcpevey
Hmm. I'll have to think though how I can implement this in my panel pipeline as well.
So if the image variable is deleted or replaced, it will close the file with your second example?
oh wait, the file is automatically closed after the image variable is created
Kim Pevey
@kcpevey
@philippjfr That didn't entirely solve the issue. I've opened an issue with a reproducible example holoviz/holoviews#4632
Marc Skov Madsen
@MarcSkovMadsen

FYI. I've tried out the https://shoelace.style/ web component library to create a Panel Template with a modal/ dialog to answer this user question https://discourse.holoviz.org/t/can-i-use-create-a-modal-dialog-in-panel/1207/4. It worked really well. For me Shoelace is currently the library of web components that I believe complements the existing Bokeh/ Panel widgets the most. They seem fairly mature and extensive. So if you needs some advanced layouts for your template take a look at them.

I believe a lot in Fast web components as well. But they are not so mature. But eventually they could be much, much bigger as they have the backing of Microsoft. And people are just starring it on Github and joining their discord forum at amazing speeds.

thumbnail.png
Checkout the live version here https://awesome-panel.org/dialog_template
Shoelace also comes with different stylesheets. And you can switch between them awesomely quick.
shoelace.gif
Marc Skov Madsen
@MarcSkovMadsen
I also think the Material MWC web components are important because Material is so widely used. But I find 1) the release cycle really slow. It's like Google is not really prioritizing this 2) The components heavy. With Shoelace and Fast you load one small library to get all components. In MWC you load a rather large library per component. And if you look at the implementation of MWC it's really just a wrapping of the "legacy" material design .js library. It does not seem that awesome.

But maybe it is better to go back to bokeh and invest in modernizing the existing css stylesheets. The problem right now is that the .css is based on a very old version of Bootstrap (I believe) and there is a lot of hard coding of colors in decentral places. Another problem is just that not so many layouts and widgets are provided.

The right thing for Bokeh styles would be to have one central place to define colors and then use them in the .css files. And create a dark version as well. And document how to customize the styles easily. And the built in styles should be as close to for example a current version of Bootstrap instead of something old or custom. This will make it a lot easier for users to customize or extend via custom templates and css.

With Fast I just need to change the background color. Then everything adjusts. That is easy ... and Fast :-).

James A. Bednar
@jbednar
Yes, Bokeh could definitely use some love from a good CSS wizard. You don't happen to know any, do you?
Marc Skov Madsen
@MarcSkovMadsen
Nope. How would Bokeh find funding to get the CSS improved visually, wrt. documention and wrt. customization? I'm thinking that the group of people developing and using Bokeh and Bokeh related things might typically not have those skills?