What should file opening behavior be when multiple plugins are available? #4111
Replies: 3 comments 5 replies
-
trying to summarize what I think was just said in meeting:
not discussed in the meeting, but i think i'd propose: |
Beta Was this translation helpful? Give feedback.
-
This is a little redundant with @tlambert03's response, but here are my answers.
Yes. The viewer should display the dialog in the ambiguous case. The command line should not and it should not require command line input either.
No. Because I wouldn't expect the behavior of a function call to change based on where it's being called from.
I don't know. In principle, folders/directories can have an extension (in that their name can have a
I think my favorite option right now is if there's exactly one plugin then use it, otherwise (if there are None or multiple) raise, just because it's fairly simple. But I wouldn't block some sensible default and warn option either.
Probably not, just because it makes the logic harder to understand. I also think there's a slightly bigger question lurking here. Does I don't have an answer, but I lean towards making A related question is if public API function calls should depend on the Python environment. For example, if a plugin package is installed, should the behavior of |
Beta Was this translation helpful? Give feedback.
-
One other point that I missed when first thinking about this, but is obvious in retrospect, is that |
Beta Was this translation helpful? Give feedback.
-
Pre-npe2 file opening behavior with plugins proceeded in a cascading manner, trying plugins until one was successful, or all failed. Users had control over this behavior by way of the plugin hook sorter in preferences - they could disable and reorder reader plugins to ensure their plugin was tried first/certain plugins weren't tried at all/etc.
However, this cascading behavior was an artifact of using
pluggy
as the base for ournapari-plugin-engine
, and is not being replicated in npe2. To initially address the issue that users would not be able to select their plugin for reading a particular file, we introduced the reader dialog in #3799, which popped up if and only if multiple plugins were available for reading a file. The dialog also allows for saving preferences for file extensions, so that you're not asked about the same file over and over. We made no decisions about saving preferences for folders.#3799 only affected GUI users however, as users calling
viewer.open
at the command line could pass in their desiredplugin
and therefore had some semblance of control. This has (of course) led to inconsistent behavior for users, as evidenced in this zulip thread where saved preferences were not respected usingviewer.open
, and in this thread whereFile -> Open
wasn't popping up the file dialog (or respecting preferences for that matter).To Reproduce
A simple example of these inconsistencies:
napari-tifffile
tif
into the viewer - the reader dialog will pop up. Selectbuiltins
and leave the checkbox ticked.viewer.open()
napari-tifffile
despite saved preference forbuiltins
Expected behavior
We have not yet, as a group, defined what we want expected behavior to be when users try to open a file and multiple plugins are available for reading, and whether this is different from the command line as opposed to the viewer.
Considerations:
napari-plugin-engine
to avoid throwing errors when plugins are available?Example
An example PR for how we could address this inconsistency is #4102 which introduces a
select_reader_helper
parameter toviewer.open
. To summarize this discussion, it's "what do you think should happen after this line?". However, it's unlikely we'll know what the code should look like until we define what we want the behavior to be.Beta Was this translation helpful? Give feedback.
All reactions