-
Notifications
You must be signed in to change notification settings - Fork 28
Added optional metadata_file_path to get_metadata #1448
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1448 +/- ##
==========================================
+ Coverage 87.04% 87.06% +0.01%
==========================================
Files 145 145
Lines 9681 9692 +11
==========================================
+ Hits 8427 8438 +11
Misses 1254 1254
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
I am against this. I think this makes our codebase more complicated (see the size of the PR) for not a lot of gain (saving some lines). I also think that that the behavior of implicitly doing a dict deep update when loading the data is a non-obvious side effect that will cause bad surprises to some of our users. Explicit is better than implicit. |
If we really want to move forward with this feature, perhaps we should refine our method naming to be more explicit and avoid mixing behaviors. Some of the current behaviors include:
Currently,
The proposed method: This seems like too many responsibilities for a single method. Maybe we could consider designing a better framework that supports composition of the above behavior and then offer this desired functionality as a wrapper function. That way, the method name can be more explicit about what it actually does and the internal behavior more explicitly documented by functions. |
I'm happy with splitting up metadata into source and default (although, I think that would take significantly more work to untangle the two different types from our current get_metadata methods). But I really don't see what's wrong with packaging that up into a high-level get_metadata function. For example, def get_metadata(self, metadata_file_path: FilePath | None):
default_metadata = self.get_default_metadata()
source_metadata = self.get_source_metadata()
metadata = dict_deep_update(default_metadata, source_metadata)
if metadata_file_path is not None:
file_metadata = load_dict_from_file(metadata_file_path)
metadata = dict_deep_update(metadata, file_metadata)
return metadata |
Packing it up on a high-level function with lots of bells and whistle is OK. But I think there should be a function that performs the basic function that has a clear name, no side-effect and does not have a lot of complexity. For example, we have both Now perfect should not be the enemy of done when adding features but I don't think this features is ... that important. As I mentioned above, it is only saving the user from writing a couple of lines. But overall, fair, maybe
I don't think this should be on you. |
Fixes #541