Skip to content

Commit 3e609b2

Browse files
committed
Rename XRootdFile to XRootdFiles and allow multiple files
1 parent fd74676 commit 3e609b2

6 files changed

+71
-12
lines changed

examples/config_databinder_func_adl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ General:
66

77
Sample:
88
- Name: ggH
9-
XRootdFile: DEF_ggH_input
9+
XRootDdFiles: DEF_ggH_input
1010
NFiles: 5
1111
Query: DEF_ttH_nominal_query
1212

examples/config_databinder_python.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Sample:
1717
Function: DEF_function1
1818

1919
- Name: ggH
20-
XRootdFile: DEF_ggH_input
20+
XRootdFiles: DEF_ggH_input
2121
Function: DEF_function2
2222

2323
Definition:

examples/python_codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_query(input_filenames=None):
5050
Sample=[
5151
Sample(
5252
Name="Python Codegen",
53-
XRootdFile="root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22/4lep/MC/mc_345060.ggH125_ZZ4lep.4lep.root",
53+
XRootDFiles="root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22/4lep/MC/mc_345060.ggH125_ZZ4lep.4lep.root",
5454
Function=run_query
5555
)
5656
]

examples/single_file_uproot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
Sample=[
5959
Sample(
6060
Name="mc_345060.ggH125_ZZ4lep.4lep",
61-
XRootdFile="root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22/4lep/MC/mc_345060.ggH125_ZZ4lep.4lep.root", # NOQA E501
61+
XRootDFiles="root://eospublic.cern.ch//eos/opendata/atlas/OutreachDatasets/2020-01-22/4lep/MC/mc_345060.ggH125_ZZ4lep.4lep.root", # NOQA E501
6262
Query=query
6363
)
6464
]

examples/stress_test.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2022, IRIS-HEP
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# * Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# * Neither the name of the copyright holder nor the names of its
15+
# contributors may be used to endorse or promote products derived from
16+
# this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
import asyncio
29+
30+
from servicex import ServiceXSpec, General, Sample
31+
from servicex.func_adl.func_adl_dataset import FuncADLQuery
32+
from servicex.servicex_client import deliver
33+
34+
print(f"Is it running {asyncio.get_event_loop().is_running()}")
35+
query = FuncADLQuery().Select(lambda e: {'el_pt': e['el_pt']})
36+
37+
spec = ServiceXSpec(
38+
General=General(
39+
ServiceX="servicex-uc-af",
40+
Codegen="uproot",
41+
OutputFormat="parquet",
42+
# Delivery="LocalCache"
43+
Delivery="SignedURLs"
44+
),
45+
Sample=[
46+
Sample(
47+
Name=f"bigger_uproot_{i}",
48+
RucioDID="user.kchoi:user.kchoi.fcnc_tHq_ML.ttH.v8",
49+
Tree="nominal",
50+
Query=query
51+
) for i in range(20)
52+
]
53+
)
54+
55+
result = deliver(spec)
56+
for k in result.keys():
57+
print(f"key: {k} values: {len(result[k])}")

servicex/databinder_models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Sample(BaseModel):
3737
Name: str
3838
Codegen: Optional[str]
3939
RucioDID: Optional[str]
40-
XRootdFile: Optional[Union[str, AnyUrl]]
40+
XRootDFiles: Optional[Union[str, list[str]]]
4141
NFiles: Optional[int] = Field(default=None)
4242
Function: Optional[Union[str, Callable]] = Field(default=None)
4343
Query: Optional[Union[str, func_adl_dataset.Query]] = Field(default=None)
@@ -51,8 +51,8 @@ class Config:
5151
def dataset_identifier(self):
5252
if self.RucioDID:
5353
return RucioDatasetIdentifier(self.RucioDID, num_files=self.NFiles or 0)
54-
elif self.XRootdFile:
55-
return FileListDataset(self.XRootdFile)
54+
elif self.XRootDFiles:
55+
return FileListDataset(self.XRootDFiles)
5656

5757
@root_validator
5858
def validate_did_xor_file(cls, values):
@@ -61,10 +61,10 @@ def validate_did_xor_file(cls, values):
6161
:param values:
6262
:return:
6363
"""
64-
if values['XRootdFile'] and values['RucioDID']:
65-
raise ValueError("Only specify one of XRootdFile or RucioDID, not both.")
66-
if not values['XRootdFile'] and not values['RucioDID']:
67-
raise ValueError("Must specify one of XRootdFile or RucioDID.")
64+
if values['XRootDFiles'] and values['RucioDID']:
65+
raise ValueError("Only specify one of XRootDFiles or RucioDID, not both.")
66+
if not values['XRootDFiles'] and not values['RucioDID']:
67+
raise ValueError("Must specify one of XRootDFiles or RucioDID.")
6868
return values
6969

7070
@root_validator
@@ -92,7 +92,9 @@ class DeliveryEnum(str, Enum):
9292

9393
ServiceX: str = Field(..., alias="ServiceX")
9494
Codegen: str
95-
OutputFormat: Union[OutputFormatEnum, constr(regex='^(parquet|root-file)$')] # NOQA F722
95+
OutputFormat: Union[OutputFormatEnum,
96+
constr(regex='^(parquet|root-file)$')] = Field(default=OutputFormatEnum.root) # NOQA F722
97+
9698
Delivery: Union[DeliveryEnum, constr(regex='^(LocalCache|SignedURLs)$')] # NOQA F722
9799

98100

0 commit comments

Comments
 (0)