Enhance asset metadata handling#142
Conversation
sduncan4
commented
May 4, 2026
- Added methods to manage extra fields in GenericAsset and its subclasses.
- Updated populate_extra_fields method to directly modify extra_fields.
- Added methods to manage extra fields in GenericAsset and its subclasses. - Updated populate_extra_fields method to directly modify extra_fields.
| """Return extra fields.""" | ||
| # boilerplate here, but overwritten in subclasses | ||
| return self._extra_fields | ||
|
|
There was a problem hiding this comment.
Do we need these methods to access the extra_fields dict? In other words, could you achieve the same functionality by calling
item.extra_fields[field_name] = value
or
del item.extra_fields[field_name]
|
|
||
| @GenericAsset.extra_fields.getter | ||
| def extra_fields(self): | ||
| # @GenericAsset.extra_fields.getter |
| def extra_fields(self): | ||
| # @GenericAsset.extra_fields.getter | ||
| def populate_extra_fields(self) -> dict: | ||
| # def extra_fields(self): |
| # def extra_fields(self): | ||
| """Return extra fields with added dynamic keys/values.""" | ||
| basin_file = self.href.split(".")[0] + ".basin" | ||
| return {"associated_basin_file": basin_file} |
There was a problem hiding this comment.
This function needs to set self.extra_fields. Update type hinting so this returns None, and set the extra fields value in the function.
| self._extra_fields[QUASI_UNSTEADY_FLOW_FILES] = self.file.quasi_unsteady_flow_files | ||
| self._extra_fields[UNSTEADY_FLOW_FILES] = self.file.unsteady_flow_files | ||
| return self._extra_fields | ||
| self.extra_fields[CURRENT_PLAN] = self.file.plan_current |
There was a problem hiding this comment.
This is correct. Do the HMS assets like this
| data/ | ||
| launch.json No newline at end of file | ||
| launch.json | ||
| test_changes.py |
There was a problem hiding this comment.
I like to avoid gitignore for these one-off files. If we all did this, it would bloat the gitignore quick.
My approach is often to make a dev/ folder where I store files like these. I then add dev/ to my local gitignore. If it's my own repo, I commit dev/ to the gitignore, but if it's a communal one, I sometimes don't commit it.
Could you remove these changes?