Skip to content

Commit e57e588

Browse files
author
acordeir
committed
kwargs for parquet filter
1 parent 91cb4a8 commit e57e588

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

servicex_analysis_utils/materialization.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
import dask_awkward as dak
3131
import logging
3232

33-
def to_awk(deliver_dict, dask=False, **uproot_kwargs):
33+
def to_awk(deliver_dict, dask=False, **kwargs):
3434
"""
3535
Load an awkward array from the deliver() output with uproot or uproot.dask.
3636
3737
Parameters:
3838
deliver_dict (dict): Returned dictionary from servicex.deliver()
3939
(keys are sample names, values are file paths or URLs).
4040
dask (bool): Optional. Flag to load as dask-awkward array. Default is False
41-
**uproot_kwargs : Optional. Additional keyword arguments passed to uproot.dask or uproot.iterate
41+
**kwargs : Optional. Additional keyword arguments passed to uproot.dask, uproot.iterate and from_parquet
4242
4343
4444
Returns:
@@ -62,19 +62,19 @@ def to_awk(deliver_dict, dask=False, **uproot_kwargs):
6262
if dask:
6363
if is_root==True:
6464
# Use uproot.dask to handle URLs and local paths lazily
65-
awk_arrays[sample] = uproot.dask(paths, library="ak", **uproot_kwargs)
65+
awk_arrays[sample] = uproot.dask(paths, library="ak", **kwargs)
6666
else:
6767
#file is parquet
68-
awk_arrays[sample] = dak.from_parquet(paths)
68+
awk_arrays[sample] = dak.from_parquet(paths, **kwargs)
6969
else:
7070
if is_root==True:
7171
# Use uproot.iterate to handle URLs and local paths files in chunks
72-
tmp_arrays = list(uproot.iterate(paths, library="ak", **uproot_kwargs))
72+
tmp_arrays = list(uproot.iterate(paths, library="ak", **kwargs))
7373
# Merge arrays
7474
awk_arrays[sample] = ak.concatenate(tmp_arrays)
7575
else:
7676
#file is parquet
77-
awk_arrays[sample] = ak.from_parquet(paths)
77+
awk_arrays[sample] = ak.from_parquet(paths, **kwargs)
7878

7979

8080
except Exception as e:

tests/test_parquet.py renamed to tests/test_materialization_parquet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_to_awk_collection(build_test_samples):
5959
assert ak.all(arr1['branch2'] == ak.from_numpy(np.zeros(100)))
6060
assert ak.all(arr2['branch1'] == ak.from_numpy(np.ones(10)))
6161

62-
# Checking kwargs (Expressions equivalent in Parquet)
63-
result_filtered = to_awk(sx_dict, filter_name="branch1") # Now using filter_name instead of expressions
62+
# Checking kwargs
63+
result_filtered = to_awk(sx_dict, columns="branch1")
6464
arr1_filtered = result_filtered["Test-Sample1"]
6565
assert ak.fields(arr1_filtered) == ['branch1'] # branch2 should be filtered out

0 commit comments

Comments
 (0)