From 8c87c3d2e130b1d3bf3f3e764b31c1ddd096470d Mon Sep 17 00:00:00 2001 From: Douglas Thain Date: Thu, 11 Feb 2021 16:51:19 -0500 Subject: [PATCH] Update wq example to work with current libraries: - uproot4 -> uproot - awkward1 -> awkward - drop flatten and nano options - register behaviors within process method. --- docs/source/wq-example.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/source/wq-example.py b/docs/source/wq-example.py index 66d997a5b..6b44fa723 100644 --- a/docs/source/wq-example.py +++ b/docs/source/wq-example.py @@ -20,13 +20,13 @@ # Sample processor class given in the Coffea manual. ############################################################### -import uproot4 +import uproot from coffea.nanoevents import NanoEventsFactory, BaseSchema # https://github.com/scikit-hep/uproot4/issues/122 -uproot4.open.defaults["xrootd_handler"] = uproot4.source.xrootd.MultithreadedXRootDSource +uproot.open.defaults["xrootd_handler"] = uproot.source.xrootd.MultithreadedXRootDSource -import awkward1 as ak +import awkward as ak from coffea import hist, processor # register our candidate behaviors @@ -49,6 +49,11 @@ def accumulator(self): return self._accumulator def process(self, events): + + # Note: This is required to ensure that behaviors are registered + # when running this code in a remote task. + ak.behavior.update(candidate.behavior) + output = self.accumulator.identity() dataset = events.metadata['dataset'] @@ -117,9 +122,7 @@ def postprocess(self, accumulator): work_queue_executor_args = { # Options are common to all executors: - 'flatten': True, 'compression': 1, - 'nano' : False, 'schema' : BaseSchema, 'skipbadfiles': False, # Note that maxchunks only works if this is false.