Skip to content

Commit

Permalink
Update wq example to work with current libraries:
Browse files Browse the repository at this point in the history
- uproot4 -> uproot
- awkward1 -> awkward
- drop flatten and nano options
- register behaviors within process method.
  • Loading branch information
dthain committed Feb 11, 2021
1 parent 5465597 commit 8c87c3d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/source/wq-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 8c87c3d

Please sign in to comment.