Skip to content

Enhance asset metadata handling#142

Open
sduncan4 wants to merge 1 commit into
fema-ffrd:mainfrom
sduncan4:feature/ras-plan-asset-metadata
Open

Enhance asset metadata handling#142
sduncan4 wants to merge 1 commit into
fema-ffrd:mainfrom
sduncan4:feature/ras-plan-asset-metadata

Conversation

@sduncan4
Copy link
Copy Markdown

@sduncan4 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.
Comment thread .vscode/settings.json
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't track this file

"""Return extra fields."""
# boilerplate here, but overwritten in subclasses
return self._extra_fields

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Comment thread hecstac/hms/assets.py

@GenericAsset.extra_fields.getter
def extra_fields(self):
# @GenericAsset.extra_fields.getter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out line

Comment thread hecstac/hms/assets.py
def extra_fields(self):
# @GenericAsset.extra_fields.getter
def populate_extra_fields(self) -> dict:
# def extra_fields(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out line

Comment thread hecstac/hms/assets.py
# 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}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function needs to set self.extra_fields. Update type hinting so this returns None, and set the extra fields value in the function.

Comment thread hecstac/ras/assets.py
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. Do the HMS assets like this

Comment thread .gitignore
data/
launch.json No newline at end of file
launch.json
test_changes.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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.

2 participants