Skip to content

Commit

Permalink
Merge pull request #1047 from CoffeaTeam/fix-uproot-530-changes
Browse files Browse the repository at this point in the history
fix: adjust to breaking changes in form mapping interface
  • Loading branch information
lgray committed Feb 24, 2024
2 parents 1d09909 + 3f62918 commit de8f220
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -38,7 +38,7 @@ classifiers = [
]
dependencies = [
"awkward>=2.5.2",
"uproot>=5.2.2",
"uproot>=5.3.0",
"dask[array]<2024.2.0,>=2023.4.0",
"dask-awkward>=2024.2.0",
"dask-histogram>=2024.2.0",
Expand Down
21 changes: 20 additions & 1 deletion src/coffea/nanoevents/factory.py
Expand Up @@ -121,7 +121,16 @@ def __call__(self, form):
self,
)

def load_buffers(self, tree, keys, start, stop, interp_options):
def load_buffers(
self,
tree,
keys,
start,
stop,
decompression_executor,
interpretation_executor,
interp_options,
):
from functools import partial

from coffea.nanoevents.util import tuple_to_key
Expand All @@ -139,6 +148,8 @@ def load_buffers(self, tree, keys, start, stop, interp_options):
cache={},
access_log=None,
use_ak_forth=True,
decompression_executor=decompression_executor,
interpretation_executor=interpretation_executor,
)
mapping.preload_column_source(partition_key[0], partition_key[1], tree)
buffer_key = partial(self._key_formatter, tuple_to_key(partition_key))
Expand Down Expand Up @@ -219,6 +230,8 @@ def from_root(
use_ak_forth=True,
delayed=True,
known_base_form=None,
decompression_executor=None,
interpretation_executor=None,
):
"""Quickly build NanoEvents from a root file
Expand Down Expand Up @@ -256,6 +269,10 @@ def from_root(
Nanoevents will use dask as a backend to construct a delayed task graph representing your analysis.
known_base_form:
If the base form of the input file is known ahead of time we can skip opening a single file and parsing metadata.
decompression_executor (None or Executor with a ``submit`` method):
see: https://github.com/scikit-hep/uproot5/blob/main/src/uproot/_dask.py#L109
interpretation_executor (None or Executor with a ``submit`` method):
see: https://github.com/scikit-hep/uproot5/blob/main/src/uproot/_dask.py#L113
"""

if treepath is not uproot._util.unset and not isinstance(
Expand Down Expand Up @@ -304,6 +321,8 @@ def from_root(
filter_branch=_remove_not_interpretable,
steps_per_file=steps_per_file,
known_base_form=known_base_form,
decompression_executor=decompression_executor,
interpretation_executor=interpretation_executor,
**uproot_options,
)

Expand Down
20 changes: 17 additions & 3 deletions src/coffea/nanoevents/mapping/uproot.py
Expand Up @@ -102,9 +102,23 @@ class UprootSourceMapping(BaseSourceMapping):
_fix_awkward_form_of_iter = False

def __init__(
self, fileopener, start, stop, cache=None, access_log=None, use_ak_forth=False
self,
fileopener,
start,
stop,
cache=None,
access_log=None,
use_ak_forth=False,
decompression_executor=None,
interpretation_executor=None,
):
super().__init__(fileopener, start, stop, cache, access_log, use_ak_forth)
self.decompression_executor = (
decompression_executor or uproot.source.futures.TrivialExecutor()
)
self.interpretation_executor = (
interpretation_executor or uproot.source.futures.TrivialExecutor()
)

@classmethod
def _extract_base_form(cls, tree, iteritems_options={}):
Expand Down Expand Up @@ -195,8 +209,8 @@ def extract_column(
interp,
entry_start=start,
entry_stop=stop,
decompression_executor=uproot.source.futures.TrivialExecutor(),
interpretation_executor=uproot.source.futures.TrivialExecutor(),
decompression_executor=self.decompression_executor,
interpretation_executor=self.interpretation_executor,
)

if allow_missing:
Expand Down

0 comments on commit de8f220

Please sign in to comment.