Skip to content

Commit c666e03

Browse files
committed
#8 Raise value errors for empty inputs in to_awk. Added related tests
1 parent 5232031 commit c666e03

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

servicex_analysis_utils/materialization.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ def to_awk(deliver_dict, dask=False, iterator=False, **kwargs):
4747
dict: keys are sample names and values are awkward arrays, uproot generator objects or dask-awkward arrays.
4848
"""
4949

50+
if not deliver_dict:
51+
raise ValueError("Input dict from servicex.deliver cannot be empty.")
52+
5053
awk_arrays = {}
5154

5255
for sample, paths in deliver_dict.items():
56+
if not paths:
57+
raise ValueError(f"ServiceX result path list for {sample} cannot be empty.")
5358
# Check file type
5459
f_type = str(paths[0])
5560
if ".root" in f_type:

tests/test_materialization.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,19 @@ def test_unsupported_file_format():
159159
match=r"Unsupported file format: 'invalid_file.txt'\. Files must be ROOT \(.*\) or Parquet \(.*\)",
160160
):
161161
to_awk(fake_paths)
162+
163+
164+
def test_empty_deliver_dict():
165+
empty_dict = {}
166+
with pytest.raises(
167+
ValueError, match="Input dict from servicex.deliver cannot be empty."
168+
):
169+
to_awk(empty_dict)
170+
171+
172+
def test_deliver_dict_empty_paths():
173+
empty_dict = {"empty-Sample": []}
174+
with pytest.raises(
175+
ValueError, match="ServiceX result path list for empty-Sample cannot be empty."
176+
):
177+
to_awk(empty_dict)

0 commit comments

Comments
 (0)