Skip to content

Commit e9cd5a6

Browse files
authored
Safeguard against version numbers in tree names
* New version of uproot/awkward returns the version number for tree keys - but can't handle them in an `uproot.open`. Strip off the version number if it is there. * Classic example of VMS living on! * Revise default configuration for backend name to reflect how ServiceX is usually configured, moving from `atlasxaod` to `atlasr21`. Fixes #326
1 parent c61bdad commit e9cd5a6

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"AOD's",
1111
"asyncio",
1212
"atlasxaod",
13+
"autopep",
1314
"awks",
1415
"AZNLOCTEQ",
1516
"backend's",
@@ -50,6 +51,7 @@
5051
"miniouser",
5152
"mino",
5253
"myfile",
54+
"mypy",
5355
"nargs",
5456
"ncols",
5557
"ndarray",
@@ -65,6 +67,10 @@
6567
"protomolecule",
6668
"ptetaphi",
6769
"pyarrow",
70+
"pycodestyle",
71+
"pydocstyle",
72+
"Pylance",
73+
"pylint",
6874
"pypa",
6975
"pypi",
7076
"pytest",
@@ -95,7 +101,8 @@
95101
"unittests",
96102
"URL's",
97103
"xaod",
98-
"xrootd"
104+
"xrootd",
105+
"yapf"
99106
],
100107
"python.analysis.typeCheckingMode": "basic",
101108
"python.testing.pytestArgs": [

servicex/config_default.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ default_return_data: parquet
3131
backend_types:
3232
- type: xaod
3333
return_data: root-file
34-
codegen: atlasxaod
34+
codegen: atlasr21
3535
- type: uproot
3636
return_data: parquet
3737
codegen: uproot

servicex/data_conversions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ def do_the_work(file: Path) -> ak.Array:
154154

155155
with uproot.open(file) as f_in: # type: ignore
156156
tree_name = f_in.keys()[0]
157+
# If `tree_name` ends with a ";NN", (where NN is a number
158+
# left over from VMS file versioning!), remove everything from the
159+
# ';' on
160+
tree_name = tree_name.split(";")[0]
157161

158162
if hasattr(uproot, "lazy"):
159163
return uproot.lazy(f"{file}:{tree_name}") # type: ignore

servicex/servicex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def __init__(
198198
Arguments
199199
200200
dataset Name of a dataset from which queries will be selected.
201-
backend_name The type of backend. Used only if we need to find an
201+
backend_name The name of backend. Used only if we need to find an
202202
end-point. If we do not have a `servicex_adaptor` then this
203203
will default to xaod, unless you have any endpoint listed
204204
in your servicex file. It will default to best match there,

servicex/servicex_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_default_returned_datatype(
4444
4545
Args:
4646
backend_name (Optional[str]): The backend type string (`xaod`, `uproot`, etc)
47+
backend_name (Optional[str]): Override the backend type
4748
4849
Returns:
4950
str: The backend datatype, like `root` or `parquet`.
@@ -171,6 +172,7 @@ def _get_backend_info(
171172

172173
# Now, extract the type and see if we can figure out any defaults from the
173174
# `backend_types` info. Skip this if we have a type we are passed in.
175+
override_backend_info = backend_type is not None
174176
type_lookup = (
175177
backend_type
176178
if backend_type is not None
@@ -185,7 +187,7 @@ def _get_backend_info(
185187
for bd in backend_defaults:
186188
if bd["type"].as_str_expanded() == type_lookup:
187189
for k in bd.keys():
188-
if k not in config:
190+
if override_backend_info or (k not in config):
189191
config[k] = str(bd[k].as_str_expanded())
190192

191193
# Finally, a default return type

tests/test_servicex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ async def test_codegen_default_by_backend(mocker, good_awkward_file_data):
13871387
await ds.get_data_rootfiles_async("(valid qastle string)")
13881388

13891389
called = mock_servicex_adaptor.query_json
1390-
assert called["codegen"] == "atlasxaod"
1390+
assert called["codegen"] == "atlasr21"
13911391

13921392

13931393
@pytest.mark.asyncio

0 commit comments

Comments
 (0)