Skip to content

Commit b523e99

Browse files
committed
[DF] Test distributed FromSpec.
1 parent 7602703 commit b523e99

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
import ROOT
4+
5+
import DistRDF
6+
7+
class TestFromSpec:
8+
9+
def test_fromspec(self, payload):
10+
"""
11+
Test usage of FromSpec function
12+
"""
13+
14+
jsonfile = "../data/ttree/spec.json"
15+
connection, _ = payload
16+
df = ROOT.RDF.Experimental.FromSpec(jsonfile, executor=connection, npartitions=2)
17+
18+
df_filt = df.Filter("b1 > 42")
19+
20+
nentries = 1000
21+
22+
assert df_filt.Count().GetValue() == nentries
23+
assert df_filt.Mean("b1").GetValue() == 50
24+
25+
26+
if __name__ == "__main__":
27+
pytest.main(args=[__file__])

python/distrdf/backends/test_all.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from check_cloned_actions import *
77
from check_distribute_cppcode import *
88
from check_definepersample import *
9+
from check_fromspec import *
910
from check_explicit_api import *
1011
from check_friend_trees_alignment import *
1112
from check_friend_trees import *

python/distrdf/data/ttree/_create_datasets.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ def create_cloned_actions():
136136
t.FlushBaskets()
137137
t.Fill()
138138
f.WriteObject(t, t.GetName())
139+
140+
def create_fromspec():
141+
# Create a test file for processing
142+
treename = "tree"
143+
filename = "distrdf_roottest_check_fromspec.root"
144+
nentries = 1000
145+
opts = ROOT.RDF.RSnapshotOptions()
146+
opts.fAutoFlush = 5000
147+
ROOT.RDataFrame(nentries).Define("b1", "50").Snapshot(treename, filename, ["b1"], opts)
5.45 KB
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"samples": {
3+
"sample1": {
4+
"trees": [
5+
"tree"
6+
],
7+
"files": [
8+
"../data/ttree/distrdf_roottest_check_rungraphs.root"
9+
],
10+
"metadata": {
11+
"data_or_mc": "data"
12+
}
13+
},
14+
"sample2": {
15+
"trees": [
16+
"tree"
17+
],
18+
"files": [
19+
"../data/ttree/distrdf_roottest_check_fromspec.root"
20+
],
21+
"metadata": {
22+
"data_or_mc": "mc"
23+
}
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)