Skip to content

Commit

Permalink
Refactor dash_vtk.util to import vtkmodules instead of vtk (#21)
Browse files Browse the repository at this point in the history
* Update vtk.py

* vtk -> vtkmodules import

* Fix vtk to 8.* in demos requirements.txt

* vtk==8.* -> vtk>=8.2.*

* Add vtk to root requirements.txt

* Add try-except for vtkmodules importing

* Relax requirements

* Relax base requirement

* Change circleci caching behavior

* Update requirements

* dash[dev] >= 1.15.0

* oops

* Add message about using vtkmodules

* Update pip version
  • Loading branch information
Xing Han Lu authored Feb 8, 2021
1 parent f93d4a2 commit 5dd3238
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- checkout

- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}-{{ checksum "demos/requirements.txt" }}

- run:
name: Create virtualenv
Expand All @@ -23,6 +23,7 @@ jobs:
name: Install requirements
command: |
. venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt --quiet
pip install -r tests/requirements.txt --quiet
Expand All @@ -33,7 +34,7 @@ jobs:
npm i
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}-{{ checksum "demos/requirements.txt" }}
paths:
- node_modules

Expand All @@ -57,7 +58,7 @@ jobs:
- checkout

- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}-{{ checksum "demos/requirements.txt" }}

- run:
name: Create virtualenv
Expand All @@ -68,11 +69,12 @@ jobs:
name: Install requirements
command: |
. venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt --quiet
pip install -r tests/requirements.txt --quiet
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}
key: deps1-{{ .Branch }}-{{ checksum "tests/requirements.txt" }}-{{ checksum "requirements.txt" }}-{{ checksum "demos/requirements.txt" }}
paths:
- "venv"

Expand Down
12 changes: 9 additions & 3 deletions dash_vtk/utils/vtk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import dash_vtk

from vtk.util.numpy_support import vtk_to_numpy
from vtk.vtkFiltersGeometry import vtkGeometryFilter
try:
# v9 and above
from vtkmodules.util.numpy_support import vtk_to_numpy
from vtkmodules.vtkFiltersGeometry import vtkGeometryFilter
except:
# v8.1.2 and below
print("Can't import vtkmodules. Falling back to importing vtk.")
from vtk.util.numpy_support import vtk_to_numpy
from vtk.vtkFiltersGeometry import vtkGeometryFilter

# Numpy to JS TypedArray
to_js_type = {
Expand Down
1 change: 1 addition & 0 deletions demos/pyvista-point-cloud/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
dash-vtk
pyvista
numpy
vtk
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# dash is required to call `build:py`
dash[dev]>=1.15.0
-e .
-e .
vtk

0 comments on commit 5dd3238

Please sign in to comment.