Skip to content

Raw h5py.Dataset attribute access from lazy objects - #117

Draft
vinamarora8 wants to merge 7 commits into
mainfrom
vinam/control-autoresolve
Draft

Raw h5py.Dataset attribute access from lazy objects#117
vinamarora8 wants to merge 7 commits into
mainfrom
vinam/control-autoresolve

Conversation

@vinamarora8

@vinamarora8 vinamarora8 commented Mar 27, 2026

Copy link
Copy Markdown
Member

Adds a context manager: temporaldata.resolve_on_access(enabled):
This allows accessing the raw h5py.Dataset attributes of lazy objects without loading them into memory. Examples:

import temporaldata as td

data = td.Data.load("test.h5")

with td.resolve_on_access(False):
    x = data.spikes.timestamps  # <- this will be an `h5py.Dataset` and not materialized

x = data.spikes.timestamps # <- this gets auto-loaded into a numpy array into memory

Alternative names: autoresolve(False), raw_access(True)

Some considerations:

  • If the lazy object has pending lazy operations (slice, mask, etc.), then the return h5py.Dataset would not reflect those lazy ops, and a warning will be printed explaining this.

@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 686723ae-8b67-405c-a714-0634934e377c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vinam/control-autoresolve

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
temporaldata/arraydict.py 80.00% 1 Missing ⚠️
temporaldata/interval.py 80.00% 1 Missing ⚠️
temporaldata/regular_ts.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown

Benchmark comparison vs main

Baseline: origin/main
Target: HEAD

Running benchmarks for dedd91fa1d...
Running benchmarks for 29be9dea66...

  Benchmark                                     dedd91fa1d (µs)    29be9dea66 (µs)    Speedup
  --------------------------------------------------------------------------------------------
  Data.slice() (lazy, realistic)                       1880.361           1906.462      0.99x
  Data.slice() (in-memory)                              731.426            744.986      0.98x
  IrregularTimeSeries.slice()                            85.933             86.048      1.00x
  RegularTimeSeries.slice()                              43.526             43.789      0.99x
  Interval.slice()                                        9.316              9.339      1.00x
  Interval.__and__ (1k&single)                           50.179             50.096      1.00x
  Interval.__and__ (1k&100)                            1175.396           1176.341      1.00x
  Interval.__or__ (1k|100)                               65.322             64.240      1.02x
  Interval.difference (1k-100)                         5714.059           5736.926      1.00x
  ArrayDict.keys() x100k                                  1.812              1.780      1.02x
  LazyInterval access (10 attrs)                       2331.902           2327.398      1.00x

@vinamarora8 vinamarora8 changed the title Raw h5py.Dataset access API for lazy objects Raw h5py.Dataset attribute access from lazy objects Mar 27, 2026
@vinamarora8

Copy link
Copy Markdown
Member Author

CC: @ShivashriganeshMahato @divyansha1115 I remember you needed something like this for your projects. What do you think of this API?

@vinamarora8

Copy link
Copy Markdown
Member Author

Also, @milosobral would love your thoughts too!

@divyansha1115

Copy link
Copy Markdown
Contributor

CC: @ShivashriganeshMahato @divyansha1115 I remember you needed something like this for your projects. What do you think of this API?

Overall, this looks very useful, especially for large datasets. Regarding the API, passing a boolean feels a bit awkward and could easily lead to mistakes by end users. It might be more clear to provide two separate context managers instead (e.g., raw_access() and lazy_access()).

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