Skip to content

[ntuple][python][ATLAS experiment] Re-Implement context management pr…#22432

Open
rybkine wants to merge 1 commit into
root-project:masterfrom
rybkine:master-ntuple-python-ctx-mgr
Open

[ntuple][python][ATLAS experiment] Re-Implement context management pr…#22432
rybkine wants to merge 1 commit into
root-project:masterfrom
rybkine:master-ntuple-python-ctx-mgr

Conversation

@rybkine
Copy link
Copy Markdown

@rybkine rybkine commented May 29, 2026

…otocol for RNTupleReader/Writer

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py: add __enter__ method - returns self (an instance of RNTupleReader/RNTupleWriter), __exit__ method - calls RNTupleReader/RNTupleWriter destructor (if not destructed yet).
tree/ntuple/test/ntuple_basics.py: update tests

This Pull request:

Changes or fixes:

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #22431

@rybkine rybkine force-pushed the master-ntuple-python-ctx-mgr branch from fcff6da to c4e56cb Compare May 29, 2026 21:08
@ferdymercury ferdymercury requested a review from silverweed May 30, 2026 13:05
…otocol for RNTupleReader/Writer

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py: add __enter__ method - returns self (an instance of RNTupleReader/RNTupleWriter), __exit__ method - calls RNTupleReader/RNTupleWriter destructor (if not destructed yet).
tree/ntuple/test/ntuple_basics.py: update tests
@rybkine rybkine force-pushed the master-ntuple-python-ctx-mgr branch from c4e56cb to 52bc377 Compare May 30, 2026 17:36
@jblomer
Copy link
Copy Markdown
Contributor

jblomer commented Jun 1, 2026

@vepadulano @silverweed Your reviews would be useful

@rybkine
Copy link
Copy Markdown
Author

rybkine commented Jun 1, 2026

Perhaps, to say the obvious - the proposed implementation is virtually the same as that of the Python file object. And this is exactly what is needed here.

Copy link
Copy Markdown
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the feature request, but I'm not sure deleting the current implementation is the right approach. This PR is modifying quite a few tests which were present before, which is a sign of major changes and thus need to be carefully evaluated. I believe @jblomer and ultimately @silverweed should say whether/how the feature request should be addressed.

@rybkine
Copy link
Copy Markdown
Author

rybkine commented Jun 1, 2026

It is not a feature request - it is rather an alternative implementation proposed, which closely follows the implementation in the Python file object. Hence, the changes made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In Python, RNTupleReader no longer iterable

3 participants