Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(draft): add report= argument to uproot.dask; triggers report collection for failed reads #1050

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 56 additions & 18 deletions src/uproot/_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def dask(
allow_missing=False,
open_files=True,
form_mapping=None,
report=None,
**options,
):
"""
Expand Down Expand Up @@ -259,6 +260,7 @@ def dask(
interp_options,
form_mapping,
steps_per_file,
report,
)
else:
return _get_dak_array_delay_open(
Expand All @@ -274,6 +276,7 @@ def dask(
interp_options,
form_mapping,
steps_per_file,
report,
)
else:
raise NotImplementedError()
Expand Down Expand Up @@ -946,6 +949,15 @@ def mock(self) -> AwkArray:
behavior=self.form_mapping_info.behavior,
)

def mock_empty(self, backend) -> AwkArray:
awkward = uproot.extras.awkward()
return awkward.to_backend(
self.expected_form.length_zero_array(highlevel=False),
backend=backend,
highlevel=True,
behavior=self.form_mapping_info.behavior,
)

def prepare_for_projection(self) -> tuple[AwkArray, TypeTracerReport, dict]:
awkward = uproot.extras.awkward()
dask_awkward = uproot.extras.dask_awkward()
Expand Down Expand Up @@ -1151,6 +1163,7 @@ def _get_dak_array(
interp_options,
form_mapping,
steps_per_file,
report,
):
dask_awkward = uproot.extras.dask_awkward()
awkward = uproot.extras.awkward()
Expand Down Expand Up @@ -1306,15 +1319,27 @@ def real_filter_branch(branch):
else:
expected_form, form_mapping_info = form_mapping(base_form)

fn = _UprootRead(
ttrees,
common_keys,
interp_options,
base_form=base_form,
expected_form=expected_form,
form_mapping_info=form_mapping_info,
)

if report is not None:
return dask_awkward.from_map(
fn,
partition_args,
divisions=tuple(divisions),
label="from-uproot",
empty_on_raise=(OSError,),
empty_backend="cpu",
)

return dask_awkward.from_map(
_UprootRead(
ttrees,
common_keys,
interp_options,
base_form=base_form,
expected_form=expected_form,
form_mapping_info=form_mapping_info,
),
fn,
partition_args,
divisions=tuple(divisions),
label="from-uproot",
Expand All @@ -1334,6 +1359,7 @@ def _get_dak_array_delay_open(
interp_options,
form_mapping,
steps_per_file,
report,
):
dask_awkward = uproot.extras.dask_awkward()
awkward = uproot.extras.awkward()
Expand Down Expand Up @@ -1396,17 +1422,29 @@ def _get_dak_array_delay_open(
else:
expected_form, form_mapping_info = form_mapping(base_form)

fn = _UprootOpenAndRead(
custom_classes,
allow_missing,
real_options,
common_keys,
interp_options,
base_form=base_form,
expected_form=expected_form,
form_mapping_info=form_mapping_info,
)

if report is not None:
return dask_awkward.from_map(
fn,
partition_args,
divisions=None if divisions is None else tuple(divisions),
label="from-uproot",
empty_on_raise=(OSError,),
empty_backend="cpu",
)

return dask_awkward.from_map(
_UprootOpenAndRead(
custom_classes,
allow_missing,
real_options,
common_keys,
interp_options,
base_form=base_form,
expected_form=expected_form,
form_mapping_info=form_mapping_info,
),
fn,
partition_args,
divisions=None if divisions is None else tuple(divisions),
label="from-uproot",
Expand Down
Loading