Refactoring metadata classes#68
Conversation
…er's metadata. Instead, now the metadata from the widget modifies the layer directly. Also added custom widgets to enable horizontal and vertical display. Added an inheritance module to allow copying of axes metadata between layers. This breaks most of the other capabilities of the plugin such as the reader, writer and saving of the modified metadata. This needs to be addressed with future updates. This version will not allow the saving of the metadata until the saving of the layer.units and other properties into the ome-tiff of zarr formats
…t is shared. Missing connections then done.
…rr/napari-metadata into refactoring-metadata-classes
|
Thanks so much for this massive update! This plugin was written a long time ago and for some very specific goals, so it makes sense that it would need some big changes. I'm mostly checking in to make sure that you're not waiting on me for a review here, since I transferred this to the napari organization (see #67 for details). I'm no longer a napari core developer and I'm not planning to maintain this particular plugin either. |
|
Hi @andy-sweet , thanks for stopping by! |
|
@TimMonko : thanks for clarifying! Feel free to mention me on issues and PRs if there's any specific feedback anyone needs. Hope you feel better soon! |
While starting to review #68, I felt the pain of CI / package metadata not being set up to modern norms. Here's a few things this PR does, and I'll make a note if I think we should consider doing this as a follow up. Question: **This does not, and should not, change anything about python functionality. All python code touched is from ruff format and check, which I suppose we _could_ do as a follow-up, especially because it might be annoying to merge into #68 -- thoughts?** 1. drops setup.cfg, moves package data entirely to pyproject. 2. modernizes pyproject, including new license format, newer pythons, dependency-groups, 3. moves to ruff (see above question) -- and thus updates to modern typing 4. updates pre-commit to be identical to what is used in napari-template, using ruff 5. adds dependabot 6. updates CI (and tox) for modern python, dropping npe2 validation, adding uv setup, and adding hynek/build-and-inspect, and using modern deploy actions --------- Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
|
@carlosmariorr, I merged the changes after #69 in, so the package is now modernized and ready to go, in that sense. I also deleted vestigial test files, but my brain power is running out on fixing up My initial goal is complete, wherein I just wanted to b e in a ready place to review this, will all the other things sorted and out of the way. Now that such is done, I'll start working on reviewing the code changes. Most of the files removed make sense, but I am a bit concerned about moving some of the logic out of other modules and all into The widget does work when I play with it, as much as I can. A few UI quirks, but UX seems ok. So for that matter, I think the goal now is to just clean anything that's a big sore thumb out of the way, and then get this properly tested so we can merge this. After that we can follow up on quirks / refactor / etc. Great work so far! |
|
Thank you a lot @TimMonko I'm back from my holidays and ready to dive into this again. |
|
Brief notes from community meeting today
Plan is that both Carlos and I will push on this. I'll start by refactoring widget.py a bit, and then building up some unit tests. Carlos is going to look at his todo list from 2025-11-27/28 meeting, which I'm going to copy here:
|
…ntainer out of the _widget.py file
… old rotated button class.
|
Okay, I think the Horizontal and Vertical containers are fixed now with proper scroll areas and I also put them into separate files so that the _widget.py file is not saturated with classes. The old vertical and horizontal container classes were deleted too. I think the GUI layout and buttons should be very close to the final form I envisioned. I'll show them in tomorrow community meeting for comments. Following this I'll go ahead and tackle the Inheritance widget and system (The checkboxes and labels and selection indicators). Hopefully completed tomorrow so we can focus on the tests to complete the alpha. I'll make the issue with the TO DO list later so we know what's next in following PRs. |
|
Great work @carlosmariorr !!! The refactor looks great so far. 🥳 💯 The scrolling and properly inheriting theme colors is 🔥 When opening the widget prior to adding any layers, the widget does not obviously contain the inheritance boxes, but does scroll nicely! I don't think this is a big deal though because it didn't break anything. It's really just an issue with the float slider, I think. In fact, it seems to be an issue with the napari Something I want to think about is how we should actually label the axes. This just looks a bit off to me Horizontal container is scrollable vertically, but I dont see a scroll bar so its not intuitive. I wonder if we should set the size policy by default to fit the full view of the containers, but allow them to be squished like you've done with teh scroll bars. I'll probably crack on this a bit in about 12 hours too, at the least I want to move tests to root and start organizing them. I didn't want to previously because the merge conflict would make me 🤮 |
|
@TimMonko thanks~ I'll not be able to work on this until I'm done with lab work tomorrow but I'll keep the commits short so we can track progress easy. About the following:
There's nothing we can do about it. Those labels are literally the property labels that napari assigns to the layers when it can't read or there's no data about dimension labels. This is literally the correct thing to do for now. We don't want to display different labels than what is in the layer and we definitely don't want to just change the labels by just opening the plugin. I know that some people commented on this but personally I think it is the correct way of displaying just because it is the way that dimensions are ordered in the multidimension array of the data. So yes, the "-" stands for the minus indexing of the array. If we want to change those defaults, we need to change the layers defaults in napari, And about this:
Yeah, that was my mistake, because the horizontal is a copy of the vertical containers, I didn't update the entire behaviour of the QWidgets that actually have the contents. My goal was this: -Vertical widget vertical scrolling is controlled by the main container (Individual sections don't do vertical scrolling). I thought that would be the optimal way of scrolling but I'm not sure if you have other thoughts... |
|
@carlosmariorr, I took the liberty to combine your beautiful collapsible containers into one class because I was realizing how much was duplicated. Even then, with having to case things for horizontal vs vertical, for me it was easier to compare this way. I'm giving you the option of accepting this, or you can just revert my commit completely 😁 |
|
I responded on the napari issue about the negative axis labels: |
@TimMonko I was just about to tell you that this needed to happen because I was just testing and they're simple copy paste of each other with small logic changes that can be passed as flags or something. Thanks! |
|
I just changed the inheritance widget to its own file, upgraded the components to be more legible and moved some of the logic to the _model.py when I thought it made sense (For connecting the events and getting the layers, etc. etc.) I am missing only two things for this to get to my goal:
I'll do that tomorrow's morning. |
TimMonko
left a comment
There was a problem hiding this comment.
I just changed the inheritance widget to its own file, upgraded the components to be more legible and moved some of the logic to the _model.py when I thought it made sense (For connecting the events and getting the layers, etc. etc.)
Its looking good! I like the new translations
I am missing only two things for this to get to my goal:
1. connect the appearance of the checkboxes to the expanded/collapsed state of the inheritance widget.
What's your idea / urgency for this? it works for me as is pretty much. I mean we do need some kind of pointer about the purposes of the check boxes, but your idea sounds like it could be a follow-up to me!
Going to start working on tests. I want to refactor, but we can do that in the future. Unless the unit test becomes too busy without abstracting, then I'll make changes. I think we can really focus on getting this done soon, so that we can get an alpha ready
| ) | ||
| self._different_dims_label.setVisible(False) | ||
|
|
||
| self._apply_button = QPushButton('Apply') |
There was a problem hiding this comment.
| self._apply_button = QPushButton('Apply') | |
| self._apply_button = QPushButton('Inherit Checked Metadata') |
How about something like this phrase? This way it lets users know the purposes of the checkboxes. Also, the more general "checked metadata" helps us be flexible to renaming things so that its not just "Inherit Axes Checked Metadata" for example
|
@TimMonko Yes, right now I'm not going to implement the checkbox states. Right now the only thing missing is to reconnect the apply function of the inheritance widget. It got a bit more complicated that just moving the function but I had the commit 90% done. I'm very busy this afternoon so I won't be able to finish it after I get back home. I'll push it tonight and I think that's all we need for the alpha right? |
Sounds great! I think so too. Double check I didn't break anything though. I had a pretty derpy refactor of However, I don't think we should delay on that, I just wanted proof to myself we can get tests going again. Going to delete I'm going to message you on Zulip, and we can talk about making the alpha and look through things together. Perhaps you could even make the release. Not sure where the release state is with the changeover -- might need to update pypi and such. But, we might as well learn together :) |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #68 +/- ##
===========================================
- Coverage 94.38% 43.02% -51.37%
===========================================
Files 20 10 -10
Lines 1586 1871 +285
===========================================
- Hits 1497 805 -692
- Misses 89 1066 +977 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…Also moved protocols to own file.
|
Ok, I just reconnected the apply inheritance function to the inheritance widget. I tested by myself for a little and it is working fine. I did encounter a bug with the new template layer selection method (Combobox method) I did create a new file called _protocols.py The function of apply inheritance currently only works with the current layer. This is OK because of how the GUI is implemented but for the future we probably want to set it up so that you can pass the template and inheriting layer. Should be easy but that moves to a future PR probably.
Great! I'll be waiting for the message. Thanks @TimMonko !!! |
|
We are aware that the files have not been fully tested. But we are merging in order to make an alpha and start trying to integrate into napari for pre-releases |




Refactoring the metadata widget
Background
The current version of the metadata widget creates a user-generated entry in the metadata parameter of the napari layer. As the layer parameters evolve, the metadata can now be set directly to the layer without the necessity of the user-generated entry.
Objective
Refactor the code so that the metadata is manipulated by the plugin widget and set directly to the layer parameters.
Brief summary of the changes:
Removed code (Yanking galore):
Added code:
Sacrifices
The plugin has some readers/writers and example metadata that can no longer be used. They were great implementations but probably need to move them to another plugin / rework them.