Skip to content

save_3d_views crashes because javascript's window.viewer.ui doesn't have required attrs #449

@mvdoc

Description

@mvdoc

I'm not sure if the problem is in the javascript viewer or the python code. Even adding a 5s pause after the first error doesn't really solve the problem. Anyone has ideas on why this is happening?

For now the solution is to re-run the code until it works...which is far from being optimal.

Example error:

Started server on port 55502
{'camera.azimuth': 180, 'camera.altitude': 180, 'camera.target': [0, -100, 0], 'surface.{subject}.unfold': 0.5, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 10, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 32}
waiting for camera.altitude 179.9 -> 180
{'camera.azimuth': 0, 'camera.altitude': 90, 'camera.target': [0, 0, 0], 'surface.{subject}.unfold': 0.5, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 10, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 32}
{'camera.azimuth': 180, 'camera.altitude': 90, 'camera.target': [0, 0, 0], 'surface.{subject}.unfold': 0.5, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 10, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 32}
{'camera.azimuth': 180, 'camera.altitude': 0, 'camera.target': [0, 0, 0], 'surface.{subject}.unfold': 1, 'surface.{subject}.pivot': 180, 'surface.{subject}.shift': 0, 'surface.{subject}.specularity': 0, 'surface.{subject}.sampler': 'nearest', 'surface.{subject}.layers': 32}
Traceback (most recent call last):
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/export/save_views.py", line 115, in save_3d_views
    handle._set_view(**this_view_params)
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/webgl/view.py", line 488, in _set_view
    subject_list = self.ui.surface._folders.attrs.keys()
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/webgl/serve.py", line 329, in __getattr__
    raise KeyError(f"Attribute '{attr}' not found in {self}")
KeyError: "Attribute 'surface' not found in <JS: window.viewer.ui>"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "202205-plot-flatmap-inflated-figures.py", line 86, in <module>
    fig = cortex.export.plot_panels(vol, **params, layers=32, sleep=sleep)
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/export/panels.py", line 109, in plot_panels
    layers=layers,
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/export/save_views.py", line 119, in save_3d_views
    handle._set_view(**this_view_params)
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/webgl/view.py", line 491, in _set_view
    vw_props = copy.copy(self.view_props)
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/webgl/view.py", line 471, in view_props
    _camera_props = ['camera.%s'%k for k in self.ui.camera._controls.attrs.keys()]
  File "/home/jlg/mvdoc/gbox/github/pycortex/cortex/webgl/serve.py", line 329, in __getattr__
    raise KeyError(f"Attribute '{attr}' not found in {self}")
KeyError: "Attribute 'camera' not found in <JS: window.viewer.ui>"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions