brisvag / blik

Python tool for visualising and interacting with cryo-ET and subtomogram averaging data.
https://brisvag.github.io/blik/
GNU General Public License v3.0
23 stars 8 forks source link

remove edge_width for points layer #167

Closed McHaillet closed 5 months ago

McHaillet commented 5 months ago

While trying the nightly build I got the following bug when trying to open blik:

napari -w blik -- manual_annotation/tomo_particles_tm.star manual_annotation/tomos/*
Traceback (most recent call last):
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1471, in _add_layer_from_data
    layer = add_method(data, **(meta or {}))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: add_points() got an unexpected keyword argument 'edge_width'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1280, in _open_or_raise_error
    added = self._add_layers_with_plugins(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1398, in _add_layers_with_plugins
    added.extend(self._add_layer_from_data(*_data))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1476, in _add_layer_from_data
    raise TypeError(
TypeError: _add_layer_from_data received an unexpected keyword argument ('edge_width') for layer type points

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/_qt/qt_viewer.py", line 985, in _qt_open
    self.viewer.open(
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1180, in open
    layers = self._open_or_raise_error(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/components/viewer_model.py", line 1289, in _open_or_raise_error
    raise ReaderPluginError(
napari.errors.reader_errors.ReaderPluginError: Tried opening with blik, but failed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/marten/miniconda3/envs/blik_nightly/bin/napari", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/__main__.py", line 574, in main
    _run()
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/__main__.py", line 344, in _run
    viewer._window._qt_viewer._qt_open(
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/_qt/qt_viewer.py", line 993, in _qt_open
    handle_gui_reading(
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/_qt/dialogs/qt_reader_dialog.py", line 190, in handle_gui_reading
    readers = prepare_remaining_readers(paths, plugin_name, error)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marten/miniconda3/envs/blik_nightly/lib/python3.12/site-packages/napari/_qt/dialogs/qt_reader_dialog.py", line 245, in prepare_remaining_readers
    raise ReaderPluginError(
napari.errors.reader_errors.ReaderPluginError: Tried to read [manual_annotation/tomo_particles_tm.star, ...] with plugin blik, because it was associated with that file extension/because it is the only plugin capable of reading that path, but it gave an error. Try associating a different plugin or installing a different plugin for this kind of file.

The traceback suggested that edge_width is not an available keyword for the points layer in napari (I guess changed in latest napari?), so I made a fork and removed it. This fixes the issue for me and therefore made a pr in case you want to merge it.

I didn't look into what changed in Napari or whether the option is fully removed or changed name.

brisvag commented 5 months ago

Thanks for writing here! Yeah, it changed name to border_width along with a few other kwargs that referenced edge; I actually have these changes locally, but haven't pushed ^^' You can change to border_width if you like, and then I'll merge! Otherwise, I can close this and open another :)

McHaillet commented 5 months ago

Sure, I can update it!

McHaillet commented 5 months ago

Updated!

McHaillet commented 5 months ago

Clashes with the napari version in the tests it seems :/

brisvag commented 5 months ago

Right, this will fail with anything below napari==0.5.0... We need a little version guard like the one for the projection mode: https://github.com/brisvag/blik/blob/bf6f5373f43867e541d50a276f923655057494e8/src/blik/reader.py#L49

except it should pass a different key depending on the version!

McHaillet commented 5 months ago

I understand. Is it the exact same version (0.5.0a) as for the projection mode?

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 42.00%. Comparing base (753bc79) to head (b051cf4). Report is 8 commits behind head on main.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #167 +/- ## ======================================= Coverage 42.00% 42.00% ======================================= Files 10 10 Lines 500 500 ======================================= Hits 210 210 Misses 290 290 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

brisvag commented 5 months ago

Thanks, looks good! :)

McHaillet commented 5 months ago

Great!