Skip to content

Commit

Permalink
Merge pull request #18 from sci-visus/cornell2024-demo
Browse files Browse the repository at this point in the history
Cornell2024 demo
  • Loading branch information
scrgiorgio authored Jun 2, 2024
2 parents 2bfd676 + db3705e commit 12cf281
Show file tree
Hide file tree
Showing 84 changed files with 128,618 additions and 7,021 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-openvisuspy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build-openvisus
on: [push]

env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}


jobs:

build-ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ '3.9', '3.10']
steps:

# git clone
- uses: actions/checkout@v2

# login in Docker
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

# build
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: |
set -ex
export PYTHON_VERSION=${{ matrix.python-version }}
source scripts/ubuntu.sh
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ build
.vscode
**/*.npz
**/*.npy
deploy/.env
deploy/inventory.ini





17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.10

RUN python3 -m pip install --upgrade pip

COPY requirements.txt ./
RUN python3 -m pip install -r requirements.txt

RUN python3 -m pip install --upgrade OpenVisusNoGui

ARG GIT_TAG
RUN python3 -m pip install openvisuspy==$GIT_TAG

CMD ["jupyter", "lab", "--allow-root", "--notebook-dir='/usr/local/lib/python3.10/site-packages/openvisuspy/notebooks'", "--port 8888", "--NotebookApp.token=''", "--NotebookApp.allow_origin='*'", "--ip", "0.0.0.0""]
181 changes: 68 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,170 +1,125 @@
# Instructions

Important:

## Windows PIP installation
- use python `3.10` or `3.11`. **DO NOT** use `python312` does not have a good match for `libzmq`
- use JupyterLab v3 (**NOT v4**) because bokeh does not work (see https://github.com/bokeh/jupyter_bokeh/issues/197)

(OPTONAL) Remove old environment:
## Installation

```bat
.venv\Scripts\deactivate
rmdir /s /q .venv
rmdir /s /q "%USERPROFILE%\.jupyter"
```

Install new version:
- use python `3.10` or `3.11`.
- **DO NOT** use `python312` does not have a good match for `libzmq`
- use JupyterLab v3 (**NOT v4**) because bokeh does not work
- https://github.com/bokeh/jupyter_bokeh/issues/197
In Windows:

```bash
python -m venv .venv
.venv\Scripts\activate
set PATH=c:\Python310;%PATH%
where python

# OPTIONAL
# python.exe -m pip install --upgrade pip
python.exe -m venv .venv
.venv\Scripts\activate

# removed `itkwidgets`, since pyvista seems to be better maintained/compatible
# see https://github.com/imjoy-team/imjoy-jupyterlab-extension/issues/6#issuecomment-1898703563
# `imjoy` is needed for itkwidgets on jupyterlab
python -m pip install --verbose --no-cache --no-warn-script-location boto3 colorcet fsspec numpy imageio urllib3 pillow xarray xmltodict plotly requests scikit-image scipy seaborn tifffile pandas tqdm matplotlib zarr altair cartopy dash fastparquet folium geodatasets geopandas geoviews lxml numexpr scikit-learn sqlalchemy statsmodels vega_datasets xlrd yfinance pyarrow pydeck h5py hdf5plugin netcdf4 nexpy nexusformat nbgitpuller intake ipysheet ipywidgets bokeh==3.3.4 ipywidgets-bokeh panel==1.3.8 holoviews hvplot datashader vtk pyvista trame trame-vtk trame-vuetify notebook "jupyterlab==3.6.6" jupyter_bokeh jupyter-server-proxy jupyterlab-system-monitor "pyviz_comms>=2.0.0,<3.0.0" "jupyterlab-pygments>=0.2.0,<0.3.0"
python.exe -m pip install --upgrade pip
python.exe -m pip install -r requirements.txt

# install the latest version of OpenVisus
python.exe -m pip install --upgrade OpenVisusNoGui openvisuspy
```

# (OPTIONAL) in debug just use local paths
# set PYTHONPATH=C:\projects\OpenVisus\build\RelWithDebInfo;.\src
In MacOs/Linux:

# or install binaries...
python -m pip install OpenVisusNoGui openvisuspy
```bash

# test import
python -c "import OpenVisus"
python -c "import openvisuspy"
python3 -m venv .venv
source .venv/Scripts/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt

# (OPTIONAL) save the output for the future
# pip freeze
# install the latest version of OpenVisus
python3 -m pip install --upgrade OpenVisusNoGui openvisuspy
```

## Run Dashboards

## Dashboards

Change path and script as needed:
In Windows:

```bash
.venv\Scripts\activate
python.exe -m panel serve ./app --dev --args ./json/dashboards.json
```

# set PYTHONPATH=C:\projects\OpenVisus\build\RelWithDebInfo;.\src
In MacOs/Linux:

set BOKEH_ALLOW_WS_ORIGIN=*
set BOKEH_LOG_LEVEL=debug
set VISUS_CPP_VERBOSE=1
set VISUS_NETSERVICE_VERBOSE=1
set VISUS_VERBOSE_DISKACCESS=0
set VISUS_CACHE=c:/tmp/visus-cache
```bash
source .venv/bin/activate
python.exe -m panel serve ./app --dev --args ./json/dashboards.json
```

## Notebooks

python -m panel serve src/openvisuspy/dashboards --dev --args "D:/visus-datasets/david_subsampled/visus.idx"
python -m panel serve src/openvisuspy/dashboards --dev --args "D:/visus-datasets/2kbit1/zip/hzorder/visus.idx"
In Windows:

# not sure why I cannot cache in arco an IDX that is NON arco
python -m panel serve src/openvisuspy/dashboards --dev --args "https://atlantis.sci.utah.edu/mod_visus?dataset=david_subsampled&cached=idx"
python -m panel serve src/openvisuspy/dashboards --dev --args "https://atlantis.sci.utah.edu/mod_visus?dataset=2kbit1&cached=idx"
```bash
.venv\Scripts\activate
jupyter lab ./notebooks
```

## Chess demos
In MacOs/Linux:

```bash
python -m panel serve src/openvisuspy/dashboards --dev --args "D:/visus-datasets/chess/nsdf-group/dashboards.json"
python -m panel serve src/openvisuspy/dashboards --dev --args "D:\visus-datasets\chess\nsdf-group\datasets\near-field-nexus\visus.idx"

python -m panel serve src/openvisuspy/dashboards --dev --args "https://raw.githubusercontent.com/nsdf-fabric/nsdf-slac/main/dashboards.json"
source .venv/bin/activate
jupyter lab ./notebooks
```

## Signal1d demos
Important: if Panel is not working you may have to do:

```bash
pskill python
jupyter nbconvert --clear-output --inplace notebooks/test-panel.ipynb
jupyter trust notebooks/test-panel.ipynb
```


python -m panel serve src/openvisuspy/dashboards --dev --args "D:/visus-datasets/signal1d/visus.idx"
python -m panel serve src/openvisuspy/dashboards --dev --args "D:/visus-datasets/signal1d_slac/visus.idx
python -m panel serve src/openvisuspy/dashboards --dev --args "https://maritime.sealstorage.io/api/v0/s3/utah/visus-datasets/signal1d_slac/visus.idx?cached=arco&access_key=any&secret_key=any&endpoint_url=https://maritime.sealstorage.io/api/v0/s3"

python -m panel serve src/openvisuspy/dashboards --dev --args c:\big\visus-datasets\signal1d_slac_max\visus.idx

python -m panel serve src/openvisuspy/dashboards --dev --args "https://maritime.sealstorage.io/api/v0/s3/utah/visus-datasets/signal1d_slac_max/visus.idx?cached=arco&access_key=any&secret_key=any&endpoint_url=https://maritime.sealstorage.io/api/v0/s3"
## Volume Rendering

# single NUMPY signals (NOTE: it's compunting min-max so it will be slow)
python -m panel serve src/openvisuspy/dashboards --dev --args "https://maritime.sealstorage.io/api/v0/s3/utah/supercdms-data/CDMS/UMN/R68/Raw/07180816_1648/07180816_1648_F0006/events/00135/banks/SCD0/data.npz?profile=sealstorage_ro&endpoint_url=https://maritime.sealstorage.io/api/v0/s3"
```bash
python test/test-pyvista.py
python test/test-vtkvolume.py
```

## Run notebooks
## Debug openvisuspy

### Setup Jupyter Lab
Debug mode in Windows

```bash
.venv\Scripts\activate

# check jupyter paths
where jupyter
jupyter kernelspec list
# Available kernels:
# python3 C:\projects\openvisuspy\.venv\share\jupyter\kernels\python3
# Check extensions: **all extensions should show `enabled ok...`**
# e.g you will need @bokeh/jupyter_bokeh for bokeh (installed by `jupyter_bokeh``)
# e.g you will need @pyviz/jupyterlab_pyviz for panel (installed by `pyviz_comms``)
# avoid any message `is not compatible with the current JupyterLab` message at the bottom
jupyter labextension list
# if `Build recommended`, or `needs to be included in build:
# @plotly/dash-jupyterlab needs to be included in build
pip install nodejs-bin[cmd]
jupyter lab clean --all
jupyter lab build
# rmdir /s /q C:\Users\scrgi\AppData\Local\Yarn
# Look also for additional extensions loaded from here
# dir .venv\share\jupyter\lab\extensions\*
jupyter labextension list
```
```bash
set PATH=c:\Python310;%PATH%

# empty all output cells
python scripts/run_command.py "jupyter nbconvert --clear-output --inplace {notebook}" "examples/notebooks/*.ipynb"
set BOKEH_ALLOW_WS_ORIGIN=*
set BOKEH_LOG_LEVEL=debug
set VISUS_CPP_VERBOSE=1
set VISUS_NETSERVICE_VERBOSE=1
set VISUS_VERBOSE_DISKACCESS=0
set VISUS_CACHE=c:/tmp/visus-cache

# trust notebook
python scripts/run_command.py "jupyter trust {notebook}" "examples/notebooks/*.ipynb"
set PYTHONPATH=C:\projects\OpenVisus\build\RelWithDebInfo;.\src

jupyter lab .
# dashboards
python.exe -m panel serve ./app --dev --args ./json/dashboards.debug.json

# [OK ] test-bokeh.ipynb
# [OK ] test-ipywidgets.ipynb
# [OK ] test-matplotlib.ipynb
# [OK ] test-panel.ipynb
# [OK ] test-pyvista.ipynb
# jupyter lab
python.exe -m jupyter lab notebooks/ov-dashboards.ipynb

# [OK ] ov-dashboards.ipynb
# [OK ] ov-retina-rabbit-matplot.ipynb
# [OK ] ov-signal.ipynb
# [ERR] ov-vr.ipynb **THIS DOES NOT WORK IN CHROME, problems with VTK?**
python.exe -m panel serve ./app --dev --args "https://atlantis.sci.utah.edu/mod_visus?action=readdataset&dataset=chess-intro&cached=arco" --probe
```

## (OPTIONAL) Test Volume rendering
Deploy binaries

```bash
# test pyvista
python examples/python/test-pyvista.py
./scripts/new_tag.sh

# test vtk volume
python examples/python/test-vtkvolume.py
# you may want to change the tag in docker-compose.yml too
```

## Developers only
Deploy new binaries

- **Update the `PROJECT_VERSION` inside `pyproject.toml`**
```bash
# source .venv/bin/activate
./scripts/new_tag.sh
```

23 changes: 0 additions & 23 deletions TODO.md

This file was deleted.

File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys
import logging
import base64
import json
import panel as pn

from openvisuspy import SetupLogger, Slice, ProbeTool,cbool


# ////////////////////////////////////////////////////////////////////////////
if __name__.startswith('bokeh'):

pn.extension(
"ipywidgets",
"floatpanel",
"codeeditor",
log_level="DEBUG",
notifications=True,
sizing_mode="stretch_width"
)

query_params = {k: v for k,v in pn.state.location.query_params.items()}

log_filename = os.environ.get("OPENVISUSPY_DASHBOARDS_LOG_FILENAME", "/tmp/openvisuspy-dashboards.log")
logger = SetupLogger(log_filename=log_filename, logging_level=logging.DEBUG)

slice = Slice()
slice.load(sys.argv[1])

# load a whole scene
if "load" in query_params:
body = json.loads(base64.b64decode(query_params['load']).decode("utf-8"))
slice.setBody(body)

# select from list of choices
elif "dataset" in query_params:
scene_name = query_params["dataset"]
slice.scene.value = scene_name

main_layout = slice.getMainLayout()
main_layout.servable()

File renamed without changes.
File renamed without changes.
Binary file removed data/ironProt.vtk
Binary file not shown.
Loading

0 comments on commit 12cf281

Please sign in to comment.