Fix: Expose timestamp as native Python datetime.datetime in metadata (#1315)#1322
Merged
haixuanTao merged 2 commits intodora-rs:mainfrom Jan 20, 2026
Merged
Conversation
…stamp - Convert uhlc::Timestamp to Python datetime.datetime in metadata_to_pydict() - Use standard get_time().to_system_time() pattern - Return timezone-aware UTC datetime (ready to use) - Fixes issue where timestamp was not exposed to Python users
…pydict() - Removed unnecessary blank lines to enhance code clarity - Streamlined the import and usage of Python's datetime module - Maintained functionality while improving code aesthetics
Contributor
Author
|
Thanks for the review and merge! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1315
Problem
The timestamp from Rust metadata (
uhlc::Timestamp) was not exposed to Python users when callingdora.Node.next(). Users need access to timestamps for recording teleoperation data (leader positions, follower positions, camera images, etc.) with timestamps for later model training.Requirement: Return the timestamp as a native Python
datetime.datetimeobject (not string or float) with UTC timezone.Solution
This PR fixes
metadata_to_pydict()inapis/python/operator/src/lib.rsto:get_time().to_system_time()patterndatetime.datetimeobject using Python's datetime module"timestamp"keyChanges
apis/python/operator/src/lib.rsmetadata_to_pydict()Comparison with Alternative Approach
float(Unix timestamp)datetime.datetimeobject ✅get_time().to_system_time()✅Testing
✅ Tested locally with minimal dataflow:
event["metadata"]["timestamp"]datetime.datetimeTest output:
