Skip to content
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

Updating to napari YAML plugin format with category-specific menu definitions. #47

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link

This message was generated by git-bob (version: 0.14.0, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

The napari-segment-blobs-and-things-with-membranes repository has been updated to use napari's YAML plugin definition format. A new napari.yaml file was created to statically define plugin contributions, transforming the previously used @ register_function decorators into this format. This involved creating command entries for each function and properly categorizing them under the correct menus based on their functionality, such as segmentation, filtering, or transformation.

closes #45

@haesleinhuepf
Copy link
Owner

@jni could you please take a look at this PR? Is there anything npe2-related missing?

@jni
Copy link

jni commented Nov 13, 2024

(1) yes, in addition to commands, each of those commands produces a widget (right?), which needs to be added in a new section (same level as commands). Documentation including example here: https://napari.org/stable/plugins/technical_references/contributions.html#contributions-widgets We do plan to add "pure" command support, but that's not yet working (if I remember correctly).
(2) napari/layers/enhance doesn't exist. 😉
(3) (optional) we can nitpick a bit about the categorisation... For example, I would put threshold_otsu under segmentation, and skeletonization under transform. But I will let you decide on these things as you prefer.
(4) as a follow-up to adding napari.yaml, you probably should remove the npe1 decorators from functions. But that can happen later if you prefer.

@haesleinhuepf
Copy link
Owner

I'm not sure if I understand the concept of commands and widgets. Obviously all the menu entries discussed here create function widgets. Why do we need commands then?

git-bob comment

Copy link
Author

This message was generated by git-bob (version: 0.14.0, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

The changes in the napari.yaml file appear to align with the discussion topics. The static definition of plugin contributions has been successfully transformed, with each function defined as a command under contributions/commands.

However, as per @ jni's comments, it seems necessary to also add widgets for each command under a new section, since napari expects widgets to accompany commands as per the current framework limitations. This might require further adjustments to the napari.yaml file.

Regarding the categorization, it is up to your discretion, but it might indeed be beneficial to reconsider some placements such as moving threshold_otsu under segmentation and skeletonize under transform, as suggested by @ jni.

Additionally, the mention of napari/layers/enhance in the menus without it existing may need clarification or correction.

Finally, consider removing the npe1 decorators from functions as a follow-up for completing the conversion to the new plugin format.

@jni
Copy link

jni commented Nov 14, 2024

The vapid answer above perfectly illustrates why I remain unimpressed with AI.

@haesleinhuepf

I'm not sure if I understand the concept of commands and widgets.

A command is a function that gets called under some circumstances. But napari doesn't know what the function does. For example, in the hopefully-near future, we could add functions that are mouse event callbacks (napari/npe2#153). So even though currently all commands are widgets, that will not be true forever, so you have to in a separate place say, we are contributing widgets, and the widgets are created by these commands.

I realise the manifest structure is a bit cumbersome — we hope to improve it in the future. Here is the issue where we are discussing simplification ideas: napari/napari#6227

But for now, to reiterate, you need the widgets section to say, these commands are actually generating widgets, which helps napari understand what to do when they are called.

@haesleinhuepf
Copy link
Owner

The vapid answer above perfectly illustrates why I remain unimpressed with AI.

Consider blaming the humans involved in the discussion, too. For example: I was misleadingly asking the model to review this PR under the hood. This is a bug that can be fixed. No big deal.

Also I must admit, that I am as confused about napari.yaml as the LLM might be. For example, you said we cannot contribute to napari/layers/context. Why is exactly this then used as example on the page titled "NAP-6 — Contributable Menus" and a sentence "Currently, the only napari menu to which items can be contributed in this way is the layer context menu"? If I was an LLM, I would act accordingly.

I may give this another try with the next version of napari, its yaml documentation and the next version of git-bob. For now, I enjoyed this experiment! Thanks for joining the discussion @jni 🙌

@jni
Copy link

jni commented Nov 18, 2024

Why is exactly this then used as example on the page titled "NAP-6 — Contributable Menus" and a sentence "Currently, the only napari menu to which items can be contributed in this way is the layer context menu"? If I was an LLM, I would act accordingly.

But as a human, you can understand when I say "the documentation matches an earlier implementation that was since changed, and it is out of date. Here are the new instructions." And you can act accordingly. Based on my comment above, I believe there is a very clear and low-effort path forward (actually, npe2 convert will give you everything you need except the menus, and for the menus, you can just grab what git-bob gave you). But instead, you seem to have this newly learned helplessness that if git-bob doesn't solve a thing, it's not worth solving?

@haesleinhuepf
Copy link
Owner

git-bob would retrieve this info if it was a github link:

Documentation including example here: https://napari.org/...

I just blocked links outside github for copyright reasons. E.g. in case of the napari website it says: "Copyright 2024, The napari team", a phrase technically peventing others from re-using contens on the website. I may reconsider this very general block. I think US ans EU lawsuits recently argued that breaking copyright for AI research is ok. But I need to read a little more.

you seem to have this newly learned helplessness that if git-bob doesn't solve a thing, it's not worth solving?

It's possible to solve this, either by adding new info to the discussion or by starting from scratch. This is similar to how humans interact with complicated isssues.

But as a human, you can understand when I say "the documentation matches an earlier implementation that was since changed, and it is out of date.

That' should possible with LLMs, too. Worth a try:

Let's forget the entire discussion above.

git-bob implement a new "jokes.py" with a function containing a print statement that prints out a joke about programmers in a bar. Again, ignore the technical details discussed above and focus on the joke and please add the new function to the napari.yaml

Copy link
Author

This message was generated by git-bob (version: 0.14.0, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

The project has been updated to incorporate a new function to tell a programmer joke, which was added to the _bia_bob_plugins.py file. In addition, the napari.yaml file has been modified to include a new widgets section where each command is now also contributing as a widget to the plugin, aligning with napari's plugin format requirements.

@haesleinhuepf
Copy link
Owner

Well almost. And funny 😁 It is maybe a good strategy to start a new discussion. 😄

@jni
Copy link

jni commented Nov 21, 2024

@haesleinhuepf the docs have been updated:

napari/docs#525

Let me know if you want to try again.

btw one motivation for me pushing you here is that we would like to throw out npe1 ASAP. We would like to make sure that the tools-menu ecosystem can effectively migrate to layers menu. For that, I need you (and other tools menu users) to tell us whether there's missing pigeonholes and you really really can't fit some of your tools into the layers menu.

(Edit: And this is something where I suspect you need to exercise your human brain and not leave the answer to the LLM...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to napari-yaml plugin definition
2 participants