Skip to content

Non-Ordered TGB Timestamp Remap - #69

Merged
Jacob-Chmura merged 5 commits into
mainfrom
dev/time_id_remap
Jul 2, 2025
Merged

Non-Ordered TGB Timestamp Remap #69
Jacob-Chmura merged 5 commits into
mainfrom
dev/time_id_remap

Conversation

@Jacob-Chmura

@Jacob-Chmura Jacob-Chmura commented Jun 26, 2025

Copy link
Copy Markdown
Member

Purpose

The purpose of this PR is to add the logic for remapping temporal timestamps when the user specifies a non-ordered time delta type that conflicts with tgb-native time units.

For simplicity, I have forwarded the custom time_delta directly into DGData.from_any() so that future data sources (e.g. #35) can re-use this logic without polluting kwargs dict.

Key Changes

  • Time delta logic is more straightforward in the DGraph constructor. We forward the argument and handle all conversions in DGData before initializing the storage
  • The DGData.from_any() explicitly takes an optional custom time_delta which is used to remap timestamps in the appropriate class constructor (currently only TGB)
  • Made DGraph.time_delta a private attribute with a getter to make it clear that the user should not set a new time_delta on the graph (this won't reflect an update in the storage and hence is a bad state).

Things to keep in mind

  • When working with custom datasets, we do not remap timestamps, as they lack native semantics. Instead, we just assign the time delta to the time tensor.
  • We don't support changing the time delta on an underlying storage. This keeps with the read-only semantics. The alternative is to create a deep copy (Time Coarsening Skeleton #67), but hopefully, we don't need this.
    We throw a ValueError when trying to coarsen a graph. This requires either merging events (Time Coarsening Skeleton #67) and/or having float-timestamps with is currently not expected behaviour. We should revisit this to ensure it is not necessary.

Relevant Prs

Close #40

Out of scope

@Jacob-Chmura Jacob-Chmura self-assigned this Jun 26, 2025
@Jacob-Chmura
Jacob-Chmura marked this pull request as ready for review June 26, 2025 14:44

@shenyangHuang shenyangHuang left a comment

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.

to discuss at meeting

Comment thread test/test_data.py
custom_td = TimeDeltaDG('s')
mock_td = {'tgbn-foo': TimeDeltaDG('Y')}
with patch.dict('tgm.timedelta.TGB_TIME_DELTAS', mock_td):
data = DGData.from_tgb(name='tgbn-foo', time_delta=custom_td, split=split)

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.

so here we overwrite the default time delta from tgb

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 basically behaves like temporal coarsening? the timestamps would be remapped? might be good to chat about this

Comment thread tgm/data.py

# TODO: int conversion may need some thought
time_factor = int(tgb_time_delta.convert(time_delta))
timestamps *= time_factor

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.

the timestamps will become float after this point?
timestamps should always be integers if possible.
let's discuss this

@codecov

codecov Bot commented Jul 2, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@Jacob-Chmura
Jacob-Chmura merged commit 4c92e65 into main Jul 2, 2025
6 checks passed
@Jacob-Chmura
Jacob-Chmura deleted the dev/time_id_remap branch July 2, 2025 19:25
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.

Temporal Coarsening Time ID Remape

2 participants