holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

Linked objects (map+table) in panel #297

Closed kcpevey closed 5 years ago

kcpevey commented 5 years ago

When an annotator is displayed using the map_view in one pane and the table_view in another, it breaks the dynamic link between the table and the map and the underlying data. The example below recreates it - This is the embedding I was using when I noticed (I removed a bunch of other parts).

sample_poly=dict(
    Longitude = [-10114986, -10123906, -10130333, -10121522, -10129889, -10122959],
    Latitude  = [  3806790,   3812413,   3807530,   3805407,   3798394,   3796693])
sample_points = dict(
    Longitude = [-10131185, -10131943, -10131766, -10131032],
    Latitude  = [  3805587,   3803182,   3801073,   3799778])

annot = PolyAndPointAnnotator(
    poly_columns =['Group'], polys=[sample_poly], vertex_columns=['Weight'], 
    point_columns=['Size'],  points=sample_points
)
pn.Column(pn.Row(pn.Column(annot.map_view),
                      pn.Tabs(('Input Data', annot.table_view),
                              ('Mesh Options', pn.panel('foo'))
                                )))
philippjfr commented 5 years ago

I'm going to push up a PR to panel some time tomorrow. I'd ask you to test it but it means updating your entire stack to param, bokeh and panel dev versions. There are lots of exciting new features there but it also may start warning about a few updated APIs.

kcpevey commented 5 years ago

I'd be happy to test after you release!

kcpevey commented 5 years ago

@philippjfr I tried switching to dev versions of param, bokeh, and panel but my imports failed. Would you also expect I need to switch to updated dev releases of hv and gv? Anything else you think I need to update?

philippjfr commented 5 years ago

I tried switching to dev versions of param, bokeh, and panel but my imports failed. Would you also expect I need to switch to updated dev releases of hv and gv? Anything else you think I need to update?

The migration may not be totally straightforward, specifically panel has changed a lot and some imports may not have to be updated. It may be best for me to work up a PR to update your code which we can then go over together. A lot of things have become a lot easier and it will be good for you to know about those changes. To answer your question, yes I think you have to update holoviews as well, you should get all the latest versions with:

conda install -c pyviz/label/dev -c bokeh/label/dev bokeh param panel holoviews
kcpevey commented 5 years ago

Did this:

conda install -c pyviz/label/dev -c bokeh/label/dev bokeh param panel holoviews

Still seeing the same issue:
Looks like an issue with the custom tools in earthsim?

---------------------------------------------------------------------------
CompilationError                          Traceback (most recent call last)
~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/util/compiler.py in bundle_models(models)
    337         try:
--> 338             _bundle_cache[key] = bundle = _bundle_models(custom_models)
    339         except CompilationError as error:

~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/util/compiler.py in _bundle_models(custom_models)
    554     known_modules = set(sum([ read_json(name) for name in bundles ], []))
--> 555     custom_impls = _compile_models(custom_models)
    556 

~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/util/compiler.py in _compile_models(custom_models)
    537         if "error" in compiled:
--> 538             raise CompilationError(compiled.error)
    539 

CompilationError: 
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:12:18 - error TS2339: Property 'buffer' does not exist on type 'ColumnDataSource'.

12       if (source.buffer == undefined) { source.buffer = [] }
                    ~~~~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:12:48 - error TS2339: Property 'buffer' does not exist on type 'ColumnDataSource'.

12       if (source.buffer == undefined) { source.buffer = [] }
                                                  ~~~~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:17:27 - error TS2569: Type 'Arrayable<any>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

17         for (const arr of column) {
                             ~~~~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:19:34 - error TS2345: Argument of type 'any[] | ArrayBufferView' is not assignable to parameter of type 'any[]'.
  Type 'ArrayBufferView' is missing the following properties from type 'any[]': length, pop, push, concat, and 24 more.

19             new_column.push(copy(arr))
                                    ~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:19:34 - error TS2345: Argument of type 'any[] | ArrayBufferView' is not assignable to parameter of type 'any[]'.
  Type 'ArrayBufferView' is not assignable to type 'any[]'.

19             new_column.push(copy(arr))
                                    ~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:24:9 - error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.

24         data_copy[key] = new_column;
           ~~~~~~~~~~~~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:26:14 - error TS2339: Property 'buffer' does not exist on type 'ColumnDataSource'.

26       source.buffer.push(data_copy)
                ~~~~~~
../../../src/earthsim/earthsim/models/checkpoint_tool.ts:52:7 - error TS2322: Type '(typeof Array | never[])[]' is not assignable to type 'undefined'.

52       sources: [ p.Array, [] ],
         ~~~~~~~

  ../../../src/earthsim/earthsim/models/checkpoint_tool.ts:52:7
    52       sources: [ p.Array, [] ],
             ~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from property 'sources' which is declared here on type 'Partial<DefineOf<{ sources: {}; }>>'

During handling of the above exception, another exception occurred:

SystemExit                                Traceback (most recent call last)
<ipython-input-1-10bb9e40ac09> in <module>
      5 
      6 import holoviews as hv
----> 7 hv.extension('bokeh')

~/miniconda3/envs/esw19/lib/python3.6/site-packages/param/parameterized.py in __new__(class_, *args, **params)
   2712         inst = class_.instance()
   2713         inst.param._set_name(class_.__name__)
-> 2714         return inst.__call__(*args,**params)
   2715 
   2716     def __call__(self,*args,**kw):

~/miniconda3/envs/esw19/lib/python3.6/site-packages/holoviews/ipython/__init__.py in __call__(self, *args, **params)
    168         Renderer.load_nb()
    169         for r in [r for r in resources if r != 'holoviews']:
--> 170             Store.renderers[r].load_nb(inline=p.inline)
    171 
    172         if hasattr(ip, 'kernel') and not loaded:

~/miniconda3/envs/esw19/lib/python3.6/site-packages/holoviews/plotting/bokeh/renderer.py in load_nb(cls, inline)
    368         LOAD_MIME_TYPE = bokeh.io.notebook.LOAD_MIME_TYPE
    369         bokeh.io.notebook.LOAD_MIME_TYPE = MIME_TYPES['jlab-hv-load']
--> 370         load_notebook(hide_banner=True, resources=INLINE if inline else CDN)
    371         bokeh.io.notebook.LOAD_MIME_TYPE = LOAD_MIME_TYPE
    372         bokeh.io.notebook.curstate().output_notebook()

~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/io/notebook.py in load_notebook(resources, verbose, hide_banner, load_timeout)
    411     _NOTEBOOK_LOADED = resources
    412 
--> 413     custom_models_js = bundle_all_models() or ""
    414 
    415     nb_js = _loading_js(resources, element_id, custom_models_js, load_timeout, register_mime=True)

~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/util/compiler.py in bundle_all_models()
    345 def bundle_all_models():
    346     """Create a bundle of all models. """
--> 347     return bundle_models(None)
    348 
    349 #-----------------------------------------------------------------------------

~/miniconda3/envs/esw19/lib/python3.6/site-packages/bokeh/util/compiler.py in bundle_models(models)
    340             print("Compilation failed:", file=sys.stderr)
    341             print(str(error), file=sys.stderr)
--> 342             sys.exit(1)
    343     return bundle
    344 

SystemExit: 1

It may be best for me to work up a PR to update your code

Are you talking about earthsim or es_workflows?

philippjfr commented 5 years ago

I should probably start with EarthSim, I hadn't thought about the custom tools in EarthSim. They will indeed need to be updated.

kcpevey commented 5 years ago

es_workflows relies on earthsim. After the tools are updated in earthsim I can retest es_workflows.

philippjfr commented 5 years ago

Should we go ahead with a technical meeting tomorrow?

kcpevey commented 5 years ago

I'd love to, but I'll be out tomorrow.

kcpevey commented 5 years ago

I have two demos for AnacondaCON that are relying on the resolution of this issue. Would it be best if I go ahead and find workarounds?

philippjfr commented 5 years ago

Should we meet to Monday to try and track this down? Hoping to at least have something you can test by then.

kcpevey commented 5 years ago

Updates from @philippjfr have fixed this for some cases, but the linking is still broken on some occasions. For the same code, sometimes it works and sometimes it doesn't. I can't seem to narrow it down.

kcpevey commented 5 years ago

This is working like it should, my code is the issue. Let's just say 'its not you, its me' :)