-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Improve RSample I/O for distributed RDataFrame usage #22749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vepadulano
merged 3 commits into
root-project:master
from
vepadulano:df-distributed-improve-rsample-io
Jul 3, 2026
+332
−181
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
57 changes: 57 additions & 0 deletions
57
roottest/python/distrdf/backends/test_standalone_fromspec.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import shlex | ||
| import sys | ||
|
|
||
| import pytest | ||
| import ROOT | ||
|
|
||
|
|
||
| class TestFromSpec: | ||
| # RDataFrame is reading files containing CMSSW classes in this test, which will trigger a warning from TClass about | ||
| # missing class dictionaries. The warning is only triggered once for the entire duration of the process. Within the | ||
| # same process, we may be running the same test multiple times (once per parametrized backend in use). So we can't | ||
| # use programmatic warning catching e.g. with pytest.warns because it would always fail on consecutive runs of this | ||
| # test. We filter out that warning specifically instead | ||
| @pytest.mark.filterwarnings("ignore:no dictionary for class") | ||
| def test_fromspec_different_trees(self, payload): | ||
| """ | ||
| Test usage of FromSpec function when each sample has different trees | ||
| """ | ||
|
|
||
| connection, _ = payload | ||
|
|
||
| jsonfile = "../data/ttree/spec_differenttrees.json" | ||
|
|
||
| df = ROOT.RDF.Experimental.FromSpec(jsonfile, executor=connection) | ||
| df_checkfilt = df.FilterAvailable("nElectron").Filter("nElectron > 2") | ||
| df_new = df.DefinePerSample("lum", 'rdfsampleinfo_.GetD("lum")') | ||
| df_filtered = df_new.Filter("lum == 100.") | ||
| df_filtered_two = df_new.Filter("lum == 200.") | ||
|
|
||
| df_local = ROOT.RDF.Experimental.FromSpec(jsonfile) | ||
| df_new_local = df_local.DefinePerSample("lum", 'rdfsampleinfo_.GetD("lum")') | ||
| df_filtered_local = df_new_local.Filter("lum == 100.") | ||
| df_filtered_two_local = df_new_local.Filter("lum == 200.") | ||
|
|
||
| df_checkfilt_count = df_checkfilt.Count() | ||
| df_filtered_count = df_filtered.Count() | ||
| df_filtered_local_count = df_filtered_local.Count() | ||
| df_filtered_two_count = df_filtered_two.Count() | ||
| df_filtered_two_local_count = df_filtered_two_local.Count() | ||
|
|
||
| assert df_checkfilt_count.GetValue() == 1683 | ||
| assert df_filtered_count.GetValue() == 11000 | ||
| assert df_filtered_count.GetValue() == df_filtered_local_count.GetValue() | ||
|
|
||
| assert df_filtered_two_count.GetValue() == 13020 | ||
| assert df_filtered_two_local_count.GetValue() == df_filtered_two_local_count.GetValue() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # The call to sys.exit is needed otherwise CTest would just ignore the | ||
| # results returned by pytest, even in case of errors. | ||
| # We ignore ResourceWarning about unclosed socket because of https://issues.apache.org/jira/browse/SPARK-38659 which | ||
| # has been fixed by https://github.com/apache/spark/pull/53200 and https://github.com/apache/spark/pull/53203 which | ||
| # may not be available in all test runner configurations | ||
| sys.exit( | ||
| pytest.main(args=shlex.split(f'{__file__} -x -vvv -Werror -Wignore:"unclosed <socket.socket":ResourceWarning')) | ||
| ) |
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.
Uh oh!
There was an error while loading. Please reload this page.