holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.59k stars 499 forks source link

Pipeline with class inheritance #216

Closed kcpevey closed 5 years ago

kcpevey commented 5 years ago

I have a few parameterized classes that I'm using to build pipelines. I have a general one:

class inputData(param.Parameterized):
    # placeholders for the incoming parameters
    load_sim_widget = param.ClassSelector(class_=load_adh_simulation)
    att_widget = param.ClassSelector(class_=attributes)
    proj_widget = param.ClassSelector(class_=projections.projections)

    label = param.String(default='Basic Input', precedence=-1)

    def __init__(self, **params):
        super(inputData, self).__init__(**params)

    # output the adh_viz object
    @param.output()
    def adh_viz(self):
        return self.execute()[0]

    # output the adh_model object
    @param.output()
    def adh_model(self):
        return self.execute()[1]

    # visualize the page
    def panel(self):
        return pn.Row(pn.Spacer(height=700), pn.Param(self.load_sim_widget, show_name=False),
                      pn.Param(self.att_widget, show_name=False), pn.Param(self.proj_widget, show_name=False),
                      name=self.label)

    # run this page
    def execute(self):
        # collect everything from this page and return (adh_viz, adh_model)
        return self.load_sim_widget.run(att_widget=self.att_widget, proj=self.proj_widget.get_crs())

Which visualizes like this: image

then I have a more specific one that inherits from the general:

class inputDataHurricane(model.inputData):
    hurricane_params = param.ClassSelector(class_=hurricane_parameters)
    grid_width = param.ClassSelector(class_=owi_grid_width)

    def __init__(self, **params):
        super(inputDataHurricane, self).__init__(**params)

    def panel(self):
        return pn.Tabs(pn.Row(pn.Spacer(height=600), pn.Param(self.load_sim_widget, show_name=False),
                                        pn.Param(self.att_widget, show_name=False),
                                        pn.Param(self.proj_widget, show_name=False),
                                        name=self.label),
                       pn.Row(pn.Spacer(height=600), pn.Param(self.hurricane_params), pn.Param(self.grid_width),
                              name='advanced'),
                       height=600, width=600)

That visualizes like this: image

They are both working as expected outside of Pipeline. The general one also works inside of Pipeline:
image

But the specific one doesn't visualize anything other than the built in pipeline buttons:
image

I've also done something similar to another class and have seen the same behavior. Is this a bug or am I missing something?

DancingQuanta commented 5 years ago

What versions of module you are using and what environment?

Have you tried Pipeline(debug=True) and what the console say?

DancingQuanta commented 5 years ago

I haven't thought of using a general Pipeline Stage class and inheriting from it before. So I refactored my app that I have built using a Pipeline. My pipeline follows the general example code

import numpy as np
import xarray as xr
import param
import panel as pn
import holoviews as hv

hv.extension('bokeh')

class Stage(param.Parameterized):
    """
    A generic pipeline stage
    """

    data = param.Parameter()

    def __init__(self, **params):
        super().__init__(**params)

class DataLoader(Stage):

    generate_data = param.Action(
        default=lambda self: self._generate_data(),
        precedence=1,
        doc="""Button to generate data.""")

    def __init__(self, **params):
        super().__init__(**params)

        self._layout = pn.Column(
            pn.Param(self, parameters=['generate_data'], show_name=False),
        )

    def _generate_data(self):
        # Random data
        x = np.arange(0, 10)
        y = x
        z = x
        data = np.random.rand(len(x), len(y), len(z))
        self.data = xr.DataArray(data,
                                 coords={'x': x, 'y': y, 'wavenumber': z},
                                 dims=['x', 'y', 'wavenumber'],
                                 name='Signal')

    def panel(self):

        return self._layout

class DataViewer(Stage):

    def view_image(self):
        return hv.Dataset(self.data).to(hv.Image, ['x', 'y'], dynamic=True)

    def panel(self):

        image = pn.panel(self.view_image())

        return pn.Row(
            image
        )

stages = [
    ('Load Data', DataLoader),
    ('Browser', DataViewer),
]

pipeline = pn.pipeline.Pipeline(stages, debug=True)

pipeline.layout.servable()

I ran above run via bokeh serve. The first stage have a button that generates random data upon a click. The second stage visualise an image from the 3D dataset with a slider. Do this code work for you?

EDIT: here are the pictures of the stages image image

kcpevey commented 5 years ago

Your code shows the same behavior as mine.

Even with pn.pipeline.Pipeline(debug=True) I get no errors in the console.

My environment hasn't been updated in maybe a week so its possible I'm missing some new addition?

# Name                    Version                   Build  Channel
affine                    2.2.2                      py_0    conda-forge
alabaster                 0.7.12                     py_0    conda-forge
appdirs                   1.4.3                      py_1    conda-forge
appnope                   0.1.0                 py36_1000    conda-forge
argparse                  1.4.0                     <pip>
asn1crypto                0.24.0                py36_1003    conda-forge
atomicwrites              1.2.1                      py_0    conda-forge
attrs                     18.2.0                     py_0    conda-forge
babel                     2.6.0                      py_1    conda-forge
backcall                  0.1.0                      py_0    conda-forge
beautifulsoup4            4.7.1                 py36_1001    conda-forge
blas                      1.1                    openblas    conda-forge
bleach                    3.1.0                      py_0    conda-forge
blinker                   1.4                        py_1    conda-forge
blosc                     1.15.1               hfc679d8_2    conda-forge
bokeh                     1.0.4                      py_0    bokeh
boost                     1.66.0                   py36_1    conda-forge
boost-cpp                 1.66.0                        1    conda-forge
boto3                     1.9.78                     py_0    conda-forge
botocore                  1.12.78                    py_0    conda-forge
bottleneck                1.2.1            py36h7eb728f_1    conda-forge
bzip2                     1.0.6                h470a237_2    conda-forge
ca-certificates           2018.03.07                    0  
cairo                     1.14.12              he56eebe_3    conda-forge
cartopy                   0.16.0           py36h81b52dc_2    conda-forge
certifi                   2018.11.29               py36_0  
cffi                      1.11.5           py36h5e8e0c9_1    conda-forge
cftime                    1.0.3.4          py36h7eb728f_0    conda-forge
chardet                   3.0.4                 py36_1003    conda-forge
click                     7.0                        py_0    conda-forge
click-plugins             1.0.4                      py_0    conda-forge
cligj                     0.5.0                      py_0    conda-forge
cloudpickle               0.6.1                      py_0    conda-forge
colorcet                  1.0.0                      py_0    conda-forge
coverage                  4.5.2            py36h470a237_0    conda-forge
coveralls                 1.5.1                      py_0    conda-forge
cryptography              2.3.1            py36hdffb7b8_0    conda-forge
cryptography-vectors      2.3.1                 py36_1000    conda-forge
curl                      7.63.0               h74213dd_0    conda-forge
cycler                    0.10.0                     py_1    conda-forge
cytoolz                   0.9.0.1          py36h470a237_1    conda-forge
dask                      1.0.0                      py_0    conda-forge
dask-core                 1.0.0                      py_0    conda-forge
datashader                0.6.9a1                    py_0    pyviz/label/earthsim
datashape                 0.5.4                    py36_0    conda-forge
decorator                 4.3.0                      py_0    conda-forge
descartes                 1.1.0                      py_2    conda-forge
diskcache                 3.1.1                      py_0    conda-forge
distributed               1.25.2                py36_1000    conda-forge
docopt                    0.6.2                      py_1    conda-forge
docutils                  0.14                  py36_1001    conda-forge
earthsim                  1.1.0a3.post8+g2e56d05           <pip>
entrypoints               0.3                   py36_1000    conda-forge
es-workflows              0.1                       <pip>
expat                     2.2.5                hfc679d8_2    conda-forge
ffmpeg                    3.2.4                         3    conda-forge
filigree                  0.2.2+pyviz.0    py36h2d50403_1    pyviz/label/earthsim
fiona                     1.7.12                   py36_0    conda-forge
flask                     1.0.2                      py_2    conda-forge
fontconfig                2.13.0               h8c010e7_5    conda-forge
freetype                  2.8.1                hfa320df_1    conda-forge
freexl                    1.0.5                h470a237_2    conda-forge
freezegun                 0.3.11                   py36_0    conda-forge
future                    0.17.1                py36_1000    conda-forge
futures-compat            1.0                       py3_0    conda-forge
gazar                     0.0.5                      py_0    conda-forge
gdal                      2.2.4                    py36_0    pyviz/label/earthsim
geojson                   2.4.1                      py_0    conda-forge
geopandas                 0.3.0                      py_1    conda-forge
geos                      3.6.2                hfc679d8_4    conda-forge
geotiff                   1.4.2                h700e5ad_5    conda-forge
geoviews                  1.6.1a2                    py_0    pyviz/label/dev
geoviews-core             1.6.1a2                    py_0    pyviz/label/earthsim
gettext                   0.19.8.1             h1f1d5ed_1    conda-forge
giflib                    5.1.4                h470a237_1    conda-forge
girder-client             2.4.0                      py_0    conda-forge
glib                      2.55.0               h464dc38_2    conda-forge
graphite2                 1.3.13               h7d4d677_0    conda-forge
gssha                     7.12+pyviz.0         h2d50403_1    pyviz/label/earthsim
gsshapy                   2.3.8                    py36_0    conda-forge
h5netcdf                  0.6.2                      py_0    conda-forge
h5py                      2.8.0            py36h470a237_0    conda-forge
harfbuzz                  1.7.6                         0    conda-forge
harmonica                 0.1a0+4.g488570e           <pip>
hdf4                      4.2.13               h951d187_2    conda-forge
hdf5                      1.10.1                        2    conda-forge
heapdict                  1.0.0                 py36_1000    conda-forge
holoviews                 1.11.0             pyh39e3cac_0    pyviz/label/dev
hs_restclient             1.3.1                      py_0    conda-forge
html5lib                  0.9999999                py36_0    conda-forge
icu                       58.2                 hfc679d8_0    conda-forge
idna                      2.8                   py36_1000    conda-forge
imageio                   2.4.1                 py36_1000    conda-forge
imagesize                 1.1.0                      py_0    conda-forge
importlib_resources       1.0.2                 py36_1000    conda-forge
ipykernel                 5.1.0           py36h24bf2e0_1001    conda-forge
ipython                   7.2.0           py36h24bf2e0_1000    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.4.2                      py_0    conda-forge
isodate                   0.6.0                      py_1    conda-forge
itsdangerous              1.1.0                      py_0    conda-forge
jasper                    1.900.1              hff1ad4c_5    conda-forge
jedi                      0.13.2                py36_1000    conda-forge
jinja2                    2.10                       py_1    conda-forge
jmespath                  0.9.3                      py_1    conda-forge
jpeg                      9c                   h470a237_1    conda-forge
json-c                    0.12.1               h470a237_1    conda-forge
jsonschema                3.0.0a3               py36_1000    conda-forge
jupyter                   1.0.0                      py_1    conda-forge
jupyter_client            5.2.4                      py_0    conda-forge
jupyter_console           6.0.0                      py_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
jupyterlab                0.35.3                   py36_0    conda-forge
jupyterlab_server         0.2.0                      py_0    conda-forge
kealib                    1.4.7                         4    conda-forge
kiwisolver                1.0.1            py36h2d50403_2    conda-forge
krb5                      1.16.3               hbb41f41_0    conda-forge
lancet                    0.9.0                    py36_0    conda-forge
libcurl                   7.63.0               hbdb9355_0    conda-forge
libcxx                    7.0.0                h2d50403_2    conda-forge
libdap4                   3.18.3                        2    conda-forge
libedit                   3.1.20170329         haf1bffa_1    conda-forge
libffi                    3.2.1                hfc679d8_5    conda-forge
libfiligree               0.1+pyviz.0          h2d50403_1    pyviz/label/earthsim
libgdal                   2.2.4                         5    pyviz/label/earthsim
libgfortran               3.0.0                      1001    conda-forge
libiconv                  1.15                 h470a237_4    conda-forge
libkml                    1.3.0                         6    pyviz/label/earthsim
libnetcdf                 4.6.1                         2    conda-forge
libpng                    1.6.34               ha92aebf_2    conda-forge
libpq                     10.6                 hf16a0db_0    conda-forge
libsodium                 1.0.16               h470a237_1    conda-forge
libspatialindex           1.8.5                hfc679d8_3    conda-forge
libspatialite             4.3.0a                       19    conda-forge
libssh2                   1.8.0                h5b517e9_3    conda-forge
libtiff                   4.0.9                he6b73bb_2    conda-forge
libwebp                   0.5.2                         7    conda-forge
libxml2                   2.9.8                h422b904_5    conda-forge
libxslt                   1.1.32               h88dbc4e_2    conda-forge
llvm-meta                 7.0.0                         0    conda-forge
llvmlite                  0.26.0          py36h3fea490_1000    conda-forge
locket                    0.2.0                      py_2    conda-forge
lxml                      4.3.0            py36hc9114bc_0    conda-forge
mapkit                    1.2.3                      py_1    conda-forge
markdown                  2.6.11                     py_0    conda-forge
markupsafe                1.1.0            py36h470a237_0    conda-forge
matplotlib                2.2.2                    py36_1    conda-forge
mistune                   0.8.4            py36h470a237_0    conda-forge
mock                      2.0.0                 py36_1000    conda-forge
more-itertools            4.3.0                 py36_1000    conda-forge
msgpack-python            0.6.0            py36h2d50403_0    conda-forge
multipledispatch          0.6.0                      py_0    conda-forge
munch                     2.3.2                      py_0    conda-forge
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                      py_1    conda-forge
nbsmoke                   0.2.7                      py_0    pyviz/label/earthsim
nbstripout                0.3.3                      py_0    conda-forge
ncurses                   6.1                  hfc679d8_2    conda-forge
netcdf4                   1.4.0                    py36_0    conda-forge
networkx                  2.2                        py_1    conda-forge
nmutils                   0.1                       <pip>
nodejs                    9.11.1                        0    conda-forge
notebook                  5.5.0                    py36_0    conda-forge
numba                     0.41.0           py36hf8a1672_0    conda-forge
numexpr                   2.6.9            py36hf8a1672_0    conda-forge
numpy                     1.14.5          py36_blas_openblashd3ea46f_202  [blas_openblas]  conda-forge
oauthlib                  2.1.0                      py_0    conda-forge
olefile                   0.46                       py_0    conda-forge
openblas                  0.2.20                        8    conda-forge
opencv                    3.4.1           py36_blas_openblas_200  [blas_openblas]  conda-forge
openjpeg                  2.3.0                h316dc23_3    conda-forge
openmp                    7.0.0                h2d50403_0    conda-forge
openssl                   1.0.2p               h1de35cc_0  
owslib                    0.17.1                     py_0    conda-forge
packaging                 18.0                       py_0    conda-forge
pandas                    0.22.0                   py36_1    conda-forge
pandoc                    2.5                           0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
panel                     0.3.0                      py_0    pyviz/label/dev
pangaea                   0.0.4                    py36_0    conda-forge
param                     1.8.2a1                    py_0    pyviz/label/dev
parambokeh                0.2.3                      py_0    pyviz/label/earthsim
paramnb                   2.0.4                      py_0    pyviz/label/earthsim
parso                     0.3.1                      py_0    conda-forge
partd                     0.3.9                      py_0    conda-forge
pbr                       5.1.1                      py_0    conda-forge
pcre                      8.41                 hfc679d8_3    conda-forge
peewee                    3.6.4           py36h65ede16_1000    conda-forge
pexpect                   4.6.0                 py36_1000    conda-forge
pickleshare               0.7.5                 py36_1000    conda-forge
pillow                    5.2.0            py36h2dc6135_1    conda-forge
pint                      0.8.1                      py_1    conda-forge
pip                       18.1                  py36_1000    conda-forge
pixman                    0.34.0               h470a237_3    conda-forge
pluggy                    0.8.1                      py_0    conda-forge
pony                      0.7.1                    py36_0    conda-forge
poppler                   0.61.1                        3    conda-forge
poppler-data              0.4.9                         1    conda-forge
proj4                     4.9.3                h470a237_8    conda-forge
prompt_toolkit            2.0.7                      py_0    conda-forge
psutil                    5.4.8            py36h470a237_0    conda-forge
psycopg2                  2.7.6.1          py36hdffb7b8_0    conda-forge
ptyprocess                0.6.0                 py36_1000    conda-forge
py                        1.7.0                      py_0    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyct                      0.4.4a10                   py_0    pyviz/label/earthsim
pyct-core                 0.4.4a10                   py_0    pyviz/label/earthsim
pyepsg                    0.4.0                      py_0    conda-forge
pyflakes                  2.0.0                      py_0    conda-forge
pygments                  2.3.1                      py_0    conda-forge
pyjwt                     1.7.1                      py_0    conda-forge
pykdtree                  1.3.1            py36h1d22016_2  
pyopenssl                 18.0.0                py36_1000    conda-forge
pyparsing                 2.3.1                      py_0    conda-forge
pyproj                    1.9.5.1          py36h508ed2a_6    conda-forge
pyqt                      5.6.0            py36h8210e8a_8    conda-forge
pyrsistent                0.14.9           py36h470a237_0    conda-forge
pysal                     1.14.4.post2          py36_1001    conda-forge
pyshp                     2.0.1                      py_0    conda-forge
pysocks                   1.6.8                 py36_1002    conda-forge
pytables                  3.4.4                    py36_8    conda-forge
pytest                    4.1.1                 py36_1000    conda-forge
pytest-cov                2.6.1                      py_0    conda-forge
python                    3.6.5                         1    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
pytides                   0.0.4                     <pip>
pytz                      2018.7                     py_0    conda-forge
pyviz_comms               0.7.0                      py_0    pyviz
pywavelets                1.0.1            py36h7eb728f_0    conda-forge
pyyaml                    3.13             py36h470a237_1    conda-forge
pyzmq                     17.1.2           py36hae99301_1    conda-forge
qt                        5.6.2                h9e3eb04_4    conda-forge
qtconsole                 4.4.3                      py_0    conda-forge
quest                     2.6.1                      py_0    erdc
rapidpy                   2.6.0                    py36_0    conda-forge
rasterio                  1.0.9            py36h1b5fcde_0    conda-forge
readline                  7.0                  haf1bffa_1    conda-forge
requests                  2.21.0                py36_1000    conda-forge
requests-oauthlib         1.0.0                      py_1    conda-forge
requests-toolbelt         0.8.0                      py_1    conda-forge
roamsADH                  2.5.0                     <pip>
roamsUTIL                 2.5.0                     <pip>
rtree                     0.8.3                 py36_1000    conda-forge
s3transfer                0.1.13                py36_1001    conda-forge
scikit-image              0.14.0           py36hfc679d8_1    conda-forge
scipy                     1.1.0           py36_blas_openblas_200  [blas_openblas]  pyviz/label/earthsim
send2trash                1.5.0                      py_0    conda-forge
setuptools                40.6.3                   py36_0    conda-forge
shapely                   1.6.4            py36h164cb2d_1    conda-forge
sip                       4.18.1           py36hfc679d8_0    conda-forge
six                       1.12.0                py36_1000    conda-forge
snowballstemmer           1.2.1                      py_1    conda-forge
snuggs                    1.4.1                      py_1    conda-forge
sortedcollections         1.1.1                      py_0    conda-forge
sortedcontainers          2.1.0                      py_0    conda-forge
soupsieve                 1.7.1                 py36_1000    conda-forge
sphinx                    1.8.3                 py36_1000    conda-forge
sphinx_rtd_theme          0.4.2                      py_0    conda-forge
sphinxcontrib-websupport  1.1.0                      py_1    conda-forge
sqlalchemy                1.2.16           py36h470a237_0    conda-forge
sqlite                    3.20.1                        0    conda-forge
suds-jurko                0.6                   py36_1001    conda-forge
tblib                     1.3.2                      py_1    conda-forge
terminado                 0.8.1                 py36_1001    conda-forge
testpath                  0.3.1                    py36_1    conda-forge
timezonefinder            3.4.1                      py_0    conda-forge
tk                        8.6.9                ha92aebf_0    conda-forge
toolz                     0.9.0                      py_1    conda-forge
tornado                   5.1.1            py36h470a237_0    conda-forge
traitlets                 4.3.2                 py36_1000    conda-forge
uit                       0.1.0                     <pip>
ulmo                      0.8.4                      py_1    conda-forge
urllib3                   1.24.1                py36_1000    conda-forge
utm                       0.4.2                    py36_0    conda-forge
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
werkzeug                  0.14.1                     py_0    conda-forge
wheel                     0.32.3                   py36_0    conda-forge
widgetsnbextension        3.4.2                 py36_1000    conda-forge
wrapt                     1.11.0           py36h470a237_0    conda-forge
wrf-python                1.3.0            py36h18b3941_0    conda-forge
x264                      20131218                      0    pyviz/label/earthsim
xarray                    0.10.7                   py36_0    conda-forge
xerces-c                  3.2.0                h5d6a6da_2    conda-forge
xz                        5.2.4                h470a237_1    conda-forge
yaml                      0.1.7                h470a237_1    conda-forge
zeromq                    4.2.5                hfc679d8_2    pyviz/label/earthsim
zict                      0.1.3                      py_0    conda-forge
zlib                      1.2.11               h470a237_4    conda-forge
kcpevey commented 5 years ago

@philippjfr I'm still seeing the same behavior with panel=0.3.2a1.post3+g80204b6-dirty

kcpevey commented 5 years ago

I probably need to update several other packages, but I'm hesitant to do so until I get the go-ahead from @philippjfr given our current issues with GDAL and gcc.

DancingQuanta commented 5 years ago

My environment is

# Name                    Version                   Build  Channel
appmode                   0.4.0                 py36_1001    conda-forge
asn1crypto                0.24.0                py36_1003    conda-forge
asteval                   0.9.13             pyh24bf2e0_0    conda-forge
attrs                     18.2.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl
bleach                    3.0.2                      py_1    conda-forge
bokeh                     1.0.3rc1                   py_0    bokeh/channel/dev
bzip2                     1.0.6             hfa6e2cd_1002    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py36_1000    conda-forge
cffi                      1.11.5          py36hfa6e2cd_1001    conda-forge
cftime                    1.0.3.4         py36h452e1ab_1000    conda-forge
chardet                   3.0.4                 py36_1003    conda-forge
colorama                  0.4.1                      py_0    conda-forge
cryptography              2.3.1           py36h74b6da3_1000    conda-forge
curl                      7.63.0            h4496350_1000    conda-forge
cycler                    0.10.0                     py_1    conda-forge
decorator                 4.3.0                      py_0    conda-forge
entrypoints               0.2.3                 py36_1002    conda-forge
freetype                  2.9.1             he8b6a0d_1004    conda-forge
futures-compat            1.0                       py3_0    conda-forge
h5netcdf                  0.6.2                      py_0    conda-forge
h5py                      2.9.0           py36hf098a70_1000    conda-forge
hdf4                      4.2.13            hf8e6fe8_1002    conda-forge
hdf5                      1.10.4          nompi_hcc15c50_1105    conda-forge
holoviews                 1.11.0             pyh39e3cac_0    pyviz/label/dev
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                     vc14_0    conda-forge
idna                      2.8                   py36_1000    conda-forge
intel-openmp              2019.1                      144
ipykernel                 5.1.0           py36h39e3cac_1001    conda-forge
ipython                   7.2.0           py36h39e3cac_1000    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.4.2                      py_0    conda-forge
jedi                      0.13.2                py36_1000    conda-forge
jinja2                    2.10                       py_1    conda-forge
jpeg                      9c                hfa6e2cd_1001    conda-forge
jsonschema                3.0.0a3               py36_1000    conda-forge
jupyter                   1.0.0                      py_1    conda-forge
jupyter_client            5.2.4                      py_0    conda-forge
jupyter_console           6.0.0                      py_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
kiwisolver                1.0.1           py36he980bc4_1002    conda-forge
krb5                      1.16.3            h038dc86_1000    conda-forge
libcurl                   7.63.0            h4496350_1000    conda-forge
libnetcdf                 4.6.2             h396784b_1001    conda-forge
libpng                    1.6.36            h7602738_1000    conda-forge
libsodium                 1.0.16            h2fa13f4_1001    conda-forge
libssh2                   1.8.0             hc4dcbb0_1003    conda-forge
libtiff                   4.0.10            h36446d0_1001    conda-forge
lmfit                     0.9.12             pyh24bf2e0_0    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  2.6.11                     py_0    conda-forge
markupsafe                1.1.0           py36hfa6e2cd_1000    conda-forge
matplotlib                3.0.2           py36h8a2030e_1001    conda-forge
matplotlib-base           3.0.2           py36h3e3dc42_1001    conda-forge
micro-spectra-browser     0.1.0                     <pip>
mistune                   0.8.4           py36hfa6e2cd_1000    conda-forge
mkl                       2018.0.3                      1
mkl_fft                   1.0.10                   py36_0    conda-forge
mkl_random                1.0.2                    py36_0    conda-forge
msys2-conda-epoch         20160418                      1
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                      py_1    conda-forge
netcdf4                   1.4.2           py36h3a1a99f_1001    conda-forge
notebook                  5.7.4                 py36_1000    conda-forge
numpy                     1.15.4           py36ha559c80_0
numpy-base                1.15.4           py36h8128ebf_0
olefile                   0.46                       py_0    conda-forge
openssl                   1.0.2p            hfa6e2cd_1002    conda-forge
packaging                 18.0                       py_0    conda-forge
pandas                    0.23.4          py36h830ac7b_1000    conda-forge
pandoc                    2.5                           0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
panel                     0.3.2a1                    py_0    pyviz/label/dev
param                     1.8.2a1                    py_0    pyviz/label/dev
parso                     0.3.1                      py_0    conda-forge
pickleshare               0.7.5                 py36_1000    conda-forge
pillow                    5.3.0           py36h9a613e6_1000    conda-forge
pip                       18.1                  py36_1000    conda-forge
prometheus_client         0.5.0                      py_0    conda-forge
prompt_toolkit            2.0.7                      py_0    conda-forge
py-wdf-reader             0.0.1                     <pip>
pybroom                   0.2                   py36_1000    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyct                      0.4.6                      py_0    pyviz/label/dev
pyct-core                 0.4.6                      py_0    pyviz/label/dev
pygments                  2.3.1                      py_0    conda-forge
pyopenssl                 18.0.0                py36_1000    conda-forge
pyparsing                 2.3.0                      py_0    conda-forge
pyqt                      5.6.0           py36h764d66f_1008    conda-forge
pyreadline                2.1                   py36_1000    conda-forge
pyrsistent                0.14.8          py36hfa6e2cd_1000    conda-forge
pysocks                   1.6.8                 py36_1002    conda-forge
python                    3.6.6                he025d50_0    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
pytz                      2018.7                     py_0    conda-forge
pyviz_comms               0.7.0                      py_0    pyviz/label/dev
pywinpty                  0.5.5                 py36_1000    conda-forge
pyyaml                    3.13            py36hfa6e2cd_1001    conda-forge
pyzmq                     17.1.2          py36hf576995_1001    conda-forge
qt                        5.6.2                h2639256_8    conda-forge
qtconsole                 4.4.3                      py_0    conda-forge
requests                  2.21.0                py36_1000    conda-forge
scipy                     1.1.0            py36h4f6bf74_1
send2trash                1.5.0                      py_0    conda-forge
setuptools                40.6.3                   py36_0    conda-forge
sip                       4.18.1          py36h6538335_1000    conda-forge
six                       1.12.0                py36_1000    conda-forge
sqlite                    3.26.0            hfa6e2cd_1000    conda-forge
terminado                 0.8.1                 py36_1001    conda-forge
testpath                  0.3.1                    py36_1    conda-forge
tk                        8.6.9             hfa6e2cd_1000    conda-forge
tornado                   5.1.1           py36hfa6e2cd_1000    conda-forge
traitlets                 4.3.2                 py36_1000    conda-forge
uncertainties             3.0.3                 py36_1000    conda-forge
urllib3                   1.24.1                py36_1000    conda-forge
vc                        14                            0    conda-forge
vs2015_runtime            14.0.25420                    0    conda-forge
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.32.3                   py36_0    conda-forge
widgetsnbextension        3.4.2                 py36_1000    conda-forge
win_inet_pton             1.0.1                 py36_1002    conda-forge
wincertstore              0.2                   py36_1002    conda-forge
winpty                    0.4.3                         4    conda-forge
xarray                    0.11.2                py36_1000    conda-forge
yaml                      0.1.7             hfa6e2cd_1001    conda-forge
zeromq                    4.2.5             he025d50_1006    conda-forge
zlib                      1.2.11            h2fa13f4_1003    conda-forge

I have installed this environment a few weeks ago with the following environment.yml

name: raman_dev
channels:
  - pyviz/label/dev
  - conda-forge
  - defaults
dependencies:
  - holoviews
  - panel
  - xarray
  - netcdf4
  - jupyter
  - appmode
  - lmfit
  - pybroom
  - pip:
    # local package
    - -e src/micro_spectra_browser
    - -e src/py-wdf-reader

As far as I can see, your panel version is a bit behind mine. Try updating that one first?

EDIT: I have missed one of your comments saying that panel=0.3.2a1 did not help. Then can I suggest starting a new environment with just panel and see if my example works for you. Then you can add a few batches of packages and see whether there is failture after installing a package?

kcpevey commented 5 years ago

First, I think I was missing understanding what @DancingQuanta 's code was supposed to do. Once I got that figured out, I adapted it to be similar to my code by changing my panel layout to be Tabs.

I eventually figured out that my code WAS displaying everything properly, the jupyter cell was just not sized properly. Then, after 8+ attempts of adding height=600 or pn.Spacer(heigh=600) into every possible location in my panel.Tabs call, I FINALLY figured out where it needed to go - I had to wrap my tabs call into a pn.Row and add a pn.Spacer as an object in the row.

Adapted, operational example code below:

import numpy as np
import xarray as xr
import param
import panel as pn
import holoviews as hv

pn.pipeline.Pipeline(debug=True)

hv.extension('bokeh')

class Stage(param.Parameterized):
    """
    A generic pipeline stage
    """

    data = param.Parameter()

    def __init__(self, **params):
        super().__init__(**params)

class DataLoader(Stage):

    generate_data = param.Action(
        default=lambda self: self._generate_data(),
        precedence=1,
        doc="""Button to generate data.""")

    def __init__(self, **params):
        super().__init__(**params)

        self._layout = pn.Row(pn.Tabs(
            pn.Param(self, parameters=['generate_data'], show_name=False)),
            pn.Spacer(height=600)
            )

    def _generate_data(self):
        # Random data
        x = np.arange(0, 10)
        y = x
        z = x
        data = np.random.rand(len(x), len(y), len(z))
        self.data = xr.DataArray(data,
                                 coords={'x': x, 'y': y, 'wavenumber': z},
                                 dims=['x', 'y', 'wavenumber'],
                                 name='Signal')

    def panel(self):

        return self._layout

class DataViewer(Stage):

    def view_image(self):
        return hv.Dataset(self.data).to(hv.Image, ['x', 'y'], dynamic=True)

    def panel(self):

        image = pn.panel(self.view_image())

        return pn.Row(
            image
        )

stages = [
    ('Load Data', DataLoader),
    ('Browser', DataViewer),
]

pipeline = pn.pipeline.Pipeline(stages, debug=True)

pipeline.layout

The important bit being:

        self._layout = pn.Row(pn.Tabs(
            pn.Param(self, parameters=['generate_data'], show_name=False)),
            pn.Spacer(height=600)
            )

Is there a more efficient way to go about this?

@DancingQuanta Thank you so much for your help and example code!

philippjfr commented 5 years ago

I eventually figured out that my code WAS displaying everything properly, the jupyter cell was just not sized properly.

Horrible, really hope the layout work lands in bokeh soon. Guess it's worth testing examples with .show() to avoid issues like this.

Is there a more efficient way to go about this?

If there is I don't know it, may be the best you can do for now.

kcpevey commented 5 years ago

Guess it's worth testing examples with .show() to avoid issues like this

I did test the visualization outside of the pipeline, and even inspected the pipline._layout object, so I knew that everything existed properly, but that didn't lead me to jupyter cell sizing until I had mulled it over for a week.

The other times I ran into this issue, I could at least see my widgets peeking out at the bottom of the cell. This particular instance was just sized perfectly to not show give any clues.

kcpevey commented 5 years ago

@philippjfr - Possible workaround - pipeline.layout is just a pn.Column so could you expose setting the height on it during the pipeline construction?

kcpevey commented 5 years ago

I think all of this has been improved with the new bokeh layout