Skip to content

Dict-like metadata interface & private metadata#260

Open
yfukai wants to merge 4 commits intoroyerlab:mainfrom
yfukai:private_metadata3
Open

Dict-like metadata interface & private metadata#260
yfukai wants to merge 4 commits intoroyerlab:mainfrom
yfukai:private_metadata3

Conversation

@yfukai
Copy link
Contributor

@yfukai yfukai commented Feb 17, 2026

Solves #192

This pull request refactors the metadata API for graph backends, introducing a new MetadataView class to provide a dictionary-like interface for metadata that synchronizes mutations directly with the graph.

Metadata API udpate:

  • Introduced the MetadataView class in src/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 previous metadata() and update_metadata() methods.
  • Refactored the BaseGraph class and its subclasses to expose metadata via the metadata property (public) and _private_metadata property (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:

  • Added strict validation and separation of public and private metadata keys, preventing accidental modification of internal metadata from public APIs and providing a dedicated _private_metadata property 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:

  • Updated src/tracksdata/graph/__init__.py to export MetadataView and reflect the new API, ensuring consistent imports and usage across the package.
  • Adjusted logging and documentation strings to reference the new property-based metadata API.

@yfukai yfukai mentioned this pull request Feb 17, 2026
8 tasks
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 71.91011% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.87%. Comparing base (e10d8c3) to head (68b01d4).

Files with missing lines Patch % Lines
src/tracksdata/graph/_base_graph.py 69.44% 20 Missing and 2 partials ⚠️
src/tracksdata/graph/_graph_view.py 66.66% 2 Missing ⚠️
src/tracksdata/nodes/_regionprops.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   88.18%   87.87%   -0.32%     
==========================================
  Files          56       56              
  Lines        4308     4378      +70     
  Branches      749      758       +9     
==========================================
+ Hits         3799     3847      +48     
- Misses        319      339      +20     
- Partials      190      192       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Comments