New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor dash_vtk.util to import vtkmodules instead of vtk #21
Conversation
dash_vtk/utils/vtk.py
Outdated
@@ -1,6 +1,6 @@ | |||
import dash_vtk | |||
|
|||
from vtk.util.numpy_support import vtk_to_numpy | |||
from vtkmodules.util.numpy_support import vtk_to_numpy | |||
from vtk.vtkFiltersGeometry import vtkGeometryFilter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the same here
from vtkmodules.vtkFiltersGeometry import vtkGeometryFilter
Seems like the py-3.6 tests are failing:
@jourdain does |
You are still using vtk@5.8? I would think so... |
Let me upgrade the vtk dependencies |
All the tests failed:
|
Wow, seems like circleci for python-3.6 can't even find vtk==9.0.1 on pypi 🤦
|
I feel we should go with a try/except when it comes to importing the library, this way if vtkmodules are not available it falls back to vtk. For try:
# v9 and above
from vtkmodules.util.numpy_support import vtk_to_numpy
from vtkmodules.vtkFiltersGeometry import vtkGeometryFilter
except:
# v8.1.2 and below
from vtk.util.numpy_support import vtk_to_numpy
from vtk.vtkFiltersGeometry import vtkGeometryFilter Thoughts? @jourdain |
Sounds good
…On Sat, Feb 6, 2021 at 14:01 Xing Han Lu ***@***.***> wrote:
I feel we should go with a try/except when it comes to importing the
library, this way if vtkmodules are not available it falls back to vtk. For
dash_vtk/utils/vtk.py, it'd be something like that:
try:
from vtkmodules.util.numpy_support import vtk_to_numpy
from vtkmodules.vtkFiltersGeometry import vtkGeometryFilterexcept:
from vtk.util.numpy_support import vtk_to_numpy
from vtk.vtkFiltersGeometry import vtkGeometryFilter
Thoughts? @jourdain <https://github.com/jourdain>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACH45UXLS3ZSYM6FY4QLFTS5WU4HANCNFSM4XDYDOHA>
.
|
@jourdain I don't think See the logs from a test heroku app that imports
|
Arg... I guess you may have to do the patching if you can like Jcr was talking about... |
Do you have the full stack? I'm not sure why we get |
Unfortunately heroku truncates the full stack :/ |
I'm not sure how to patch a library inside dash-vtk's |
I don't know if there is a post-setup or something that can be executed once vtk get installed to edit/patch it. |
Seems like the deployment works: https://dash-docs-pr-1091.herokuapp.com/ |
If still needed, this could be done at the end of import sysconfig
site_packages_dir = sysconfig.get_paths()['purelib']
vtk_init_py = site_packages_dir + "/vtk/__init__.py"
print("Patching %s" % vtk_init_py)
has_openglkit_import = False
updated_lines = []
with open(vtk_init_py, "r") as myfile:
for line in myfile.readlines():
if line != "from .vtkOpenGLKit import *\n":
updated_lines.append(line)
else:
has_openglkit_import = True
if has_openglkit_import:
with open(vtk_init_py, "w") as myfile:
myfile.writelines(updated_lines)
print("Patching %s [%s]" % (vtk_init_py, "done" if has_openglkit_import else "skipped")) |
Logic would have to be tweaked based to be more robust and gracefully skip in the case of vtk 9 ... |
This should work for 9.0.1 but I feel this approach might be very brittle and would require a lot of error catching since there's a lot of variables (people uninstalling/reinstalling vtk, someone installing dash-vtk alongside vtk but uses vtk for other purposes and finds out they can't import libgl anymore, etc.). In the end it could create more friction. I'd like to backtrack on the reasons why this PR was started and my various attempts at bypassing libgl. I feel it might be better to write instructions in the EDIT: *In the end we agreed to keep the |
@jourdain I think this is ready to be merged |
Yes LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
See: plotly/dash-docs#1091
import vtkmodules
avoid importing the libGL library in vtk v9.0.1, as opposed toimport vtk
which always loads (thus requires) libglAbout
Description of changes
Pre-Merge checklist
npm run build
.Reference Issues
Closes #[issue number]
Other comments