-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Streamline album attributes modification behaviour and allow override via CLI #4823
Conversation
Hi @sampsyo we talked about this a couple of months ago and agreed that it would make sense to have the same behaviour of inheritance of album-mods no matter if fixed or flex attr #4742 (reply in thread) Now before I add documentation and changelog to this PR I would like to discuss a usability thing: I just added a capital option of BTW I realised that there is one use-case I'm facing quite often myself where a |
Thanks for getting this started! At a very high level, I think it may make more sense to make the "inheritance" happen when making the change on the model, not when calling This could happen either in Line 633 in 0c3f428
Or in the |
My initial reaction was to agree with you, but after a brief glance at the code, I'm not so sure anymore: |
Hmm; you're right about that—I hadn't thought that through completely (that |
Well, thanks to both of you for clarifying @sampsyo @wisp3rwind. I have to admit that @sampsyo's first suggestion confused me a little, but no worries, I'm glad we seem to be back on track :-) Good, before I move on to wrapping my head around all the tests that are failing now, any other suggestions if there is a better way than passing a kwarg through a few levels to make this "configurable"? Also any opinions on whether or not it makes sense to add an additional |
@JOJ0 I thought |
The main way would be to make this a proper beets configuration option (i.e., make it appear in |
Hmm, yes that's true but actually I thought that its not problem to have the same letter for a different subcommand. But yeah if you guys can think of a different letter I'm up for suggestions.
|
If it does not conflict, I am fine with |
Sorry for being unclear with my question. I used the word configurable but put it in double quotes because I was trying to say something like: ....any better way...to implement this? Well, you did kind of answered to that as well. A regular beets config option which a cli option overrides, is probably a typicial form of implementing this. Now my initial idea was to have a config option but after thinking this through a couple of times I came to the conclusion that actually I don't consider it necessary. If I want to modify something, then a consistent default should be used - which we finally achieve with these changes. Finally album mods propagate to items for flex attrs as well (not touching the current behaviour for fixed attrs). If this is not what the user wants, they can use this new cli option to modify. That were my thoughts, also trying to keep this change minimal. We can certainly discuss it. Maybe having an option does not hurt.... Any suggestions where an option like this would "live" in config_default.yaml? Ideas:
And now, if we would add such an option it would further be required to have a second cli option that can alter the behaviour. Suggestion: If user config option set to
If user config option set to
Thoughts welcome! Thanks! |
I prefer: modify:
inherit: yes I am also thinking that the default behavior should be to inherit attributes. |
Aha! FWIW, I think it is totally fine to have this not be configurable, i.e., to have "propagation" be the default and not be overridable. If we do have a config option, it would also be OK to leave it undocumented, just as an "escape hatch" for people who really need the old behavior for some reason. In that case, I'd argue it should be a top-level option, not under a |
015aa2e
to
049bd06
Compare
Guys! @sampsyo @wisp3rwind I'm a little lost here and need some brainstorming on how to proceed. A lot of tests are failing now. I've just looked into some of them yet. First of, these two: Lines 226 to 246 in b19b961
fail like this:
After a lot of debugging I realized that the So I fixed it like this: I'm not sure if this is what we want. High level question: I would say the 'id' field should always be prevented to propagate from album mods to items? If yes, there might be other fields that should always not be inherited. I could put a CONSTANT somewhere that collects these fields. Would that be the right way? |
Next up is this test: Lines 1025 to 1030 in b19b961
Failing like so:
It seems like change of artist (of the album) intentionally is not propagated to items which this check proves. I could easily fix this test by passing but is this what we want in general? Should editing of artist perhaps never propagate to items? On the other hand editing of an albumartist (of an album) is checked whether it successfully propagates to items with this test: Lines 1017 to 1023 in b19b961
|
Good question. Yes, absolutely; we would never ever want the
It seems like this test was expressly meant to "lock in" the old behavior, which we are now changing. I think what seems reasonable here is that we should split this into two tests: one with |
16b4f03
to
0a96d3c
Compare
0a96d3c
to
190fd26
Compare
0f884a8
to
d30ac60
Compare
d30ac60
to
a5f801e
Compare
a5f801e
to
018910d
Compare
Ready for a final review @sampsyo, maybe have a look at the docs I wrote, I also reworded existing stuff for I left the check for ìd`simply inline with the if-statement. An extra GLOBAL_NEVER_INHERIT_THIS_FIELD or something like that felt overkill: 7313fe1 As a final step I tried to clarify and extend docstring and comments in this function. Nitpicking appreciated, since it is a very core-thing everybody who comes across, should have the chance to understand quickly. Does that make sense? a6937f0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!! This is looking great. I have just a couple of small suggestions, but I think we are basically in business!
beets/library.py
Outdated
track_updates = {} | ||
track_deletes = set() | ||
for key in self._dirty: | ||
if key in self.item_keys: | ||
if key in self.item_keys and inherit: # Fixed attr | ||
track_updates[key] = self[key] | ||
elif key not in self: | ||
elif key not in self and inherit: # Fixed or flex attr | ||
track_deletes.add(key) | ||
elif key != 'id' and inherit: # Could be a flex attr or id (fixed) | ||
track_updates[key] = self[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you alluded to this in the main comment thread, but this could be a little easier to read if we put the entire stanza under a if inherit:
condition. That would make it clear to the reader that nothing happens here when inherit=False
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I changed it to this: https://github.com/beetbox/beets/pull/4823/files#diff-d6c57a8deb6bf406de08bd231833fafb4515c984bf0d854a50a0e6cb3dcd3d1fR1386-R1392
as suggested by @sampsyo. Co-authored-by: Adrian Sampson <adrian@radbox.org>
It seems that _deleting_ flex attrs from an album already propagate to items. Now also _modifications_ of album flex attrs propagate to items.
Adds a cli option to the modify command that prevents inheriting `modify -a` changes to album-tracks.
excluding 'id' fields when storing within the Album model.
by adding (inherit=True) to fit with the new behaviour of the store() method and add a second test that checks the opposite.
by using store(inherit=False) for the creation of a new "ipfs album" as well as when test_ipfs creates album+items to compare with. Or put differently: Make ipfs and test_ipfs keep the old store() behaviour for which the plugin initially was built for.
and further clarify `mod -a` docs: Even though e39dcfc and the linked discussion already does a very good job on clarifying what is actually happening when `mod -a` is issued, this commit adds further details about the difference between the album query and what is actually modified.
explaining the inherit flag, fixed/flex attrs and the strict exclusion of the id field.
as suggested by @sampsyo. Co-authored-by: Adrian Sampson <adrian@radbox.org>
cc3c700
to
d7b7d60
Compare
That was a tough one but I think it was worth it. Thanks @sampsyo for all the guidance! |
as suggested by @sampsyo. Co-authored-by: Adrian Sampson <adrian@radbox.org>
Description
--noinherit/-I
that prevents inheriting to album-tracks, which allows changing fixed/flexible attributes on an album only.To Do