Skip to content

Commit 2aa3eed

Browse files
authored
Merge pull request #32 from ssl-hep/feat/eos_pathfinder
Adding autocomplete URL resolution to eos paths for ATLAS CMS and Ope…
2 parents 9369560 + a3631ff commit 2aa3eed

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

servicex_analysis_utils/dataset_resolver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ def ds_type_resolver(
7272
elif ds_name.startswith("root://") and ds_name.endswith("*"):
7373
return dataset.XRootD(ds_name)
7474

75+
elif ds_name.startswith("/eos/"):
76+
if "/eos/opendata/" in ds_name:
77+
return dataset.FileList([f"root://eospublic.cern.ch/{ds_name}"])
78+
elif "/eos/atlas/" in ds_name:
79+
return dataset.FileList([f"root://eosatlas.cern.ch/{ds_name}"])
80+
elif "/eos/cms/" in ds_name:
81+
return dataset.FileList([f"root://eoscms.cern.ch/{ds_name}"])
82+
else:
83+
raise ValueError(
84+
f"Unable to determine the correct EOS instance for the provided path: {ds_name}."
85+
"Please provide the full root:// URL. Cannot be a user path."
86+
)
87+
7588
elif re.match(r"^root://", ds_name):
7689
return dataset.FileList(ds_name)
7790

tests/test_dataset_resolver.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@
4545
def test_find_dataset(input_ds, expected_type):
4646
dataset = ds_type_resolver(input_ds)
4747
assert isinstance(dataset, expected_type)
48+
49+
50+
@pytest.mark.parametrize(
51+
"eos_path, prefix",
52+
[
53+
("/eos/opendata/atlas/rucio/somefile.root", "root://eospublic.cern.ch/"),
54+
("/eos/opendata/cms/rucio/somefile.root", "root://eospublic.cern.ch/"),
55+
("/eos/atlas/atlascerngroupdisk/somefile.root", "root://eosatlas.cern.ch/"),
56+
("/eos/cms/store/somefile.root", "root://eoscms.cern.ch/"),
57+
],
58+
)
59+
def test_eos_url_parsing(eos_path, prefix):
60+
ds_out = ds_type_resolver(eos_path)
61+
assert isinstance(ds_out, dataset.FileList)
62+
assert ds_out.files[0] == prefix + eos_path

0 commit comments

Comments
 (0)