Dict-like metadata interface & private metadata#260
Dict-like metadata interface & private metadata#260yfukai wants to merge 6 commits intoroyerlab:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #260 +/- ##
==========================================
- Coverage 88.18% 87.87% -0.32%
==========================================
Files 56 56
Lines 4308 4395 +87
Branches 749 761 +12
==========================================
+ Hits 3799 3862 +63
- Misses 319 340 +21
- Partials 190 193 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| td_metadata = self.metadata().copy() | ||
| td_metadata = self.metadata.copy() | ||
| td_metadata.pop("geff", None) # avoid geff being written multiple times |
There was a problem hiding this comment.
Private metadata is lost during conversion to geff. Is this correct?
Wouldn't it make sense to keep it?
There was a problem hiding this comment.
Oh yeah, thanks for notifying this. It should survive.
There was a problem hiding this comment.
Done! I used _private_metadata_for_copy so that the backends can decide which metadata to send, since SQLGraph will use the private metadata to persistently store the AttrSchema, which should not be used when creating the graph by from_other etc., and thus should be excluded to avoid confusion. I'd be happy to hear your opinion.
Solves #192
This pull request refactors the metadata API for graph backends, introducing a new
MetadataViewclass to provide a dictionary-like interface for metadata that synchronizes mutations directly with the graph.Metadata API udpate:
MetadataViewclass insrc/tracksdata/graph/_base_graph.py, which provides a dictionary-like interface for metadata and ensures that updates, removals, and other mutations are synchronized with the graph backend. This replaces the previousmetadata()andupdate_metadata()methods.BaseGraphclass and its subclasses to expose metadata via themetadataproperty (public) and_private_metadataproperty (private), with enforced validation to prevent accidental modification of private metadata from public APIs. Backend-specific methods for updating and removing metadata are now internal (_update_metadata,_remove_metadata).Private metadata handling and validation:
_private_metadataproperty for internal use. A new test ensures that private metadata is hidden from public APIs and that validation errors are raised for improper access.API and import changes:
src/tracksdata/graph/__init__.pyto exportMetadataViewand reflect the new API, ensuring consistent imports and usage across the package.