Skip to content

Instantly share code, notes, and snippets.

@oshadura
Created June 17, 2024 19:24
Show Gist options
  • Save oshadura/df21fcdf12c8ad9bac6b759ca164064c to your computer and use it in GitHub Desktop.
Save oshadura/df21fcdf12c8ad9bac6b759ca164064c to your computer and use it in GitHub Desktop.
%%time
# execute
((out, report),) = dask.compute(tasks) # feels strange that this is a tuple-of-tuple
print(f"total time spent in uproot reading data (or some related metric?): {ak.sum([v['duration'] for v in report.values()]):.2f} s")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File <timed exec>:2
File /usr/local/lib/python3.10/site-packages/dask/base.py:661, in compute(traverse, optimize_graph, scheduler, get, *args, **kwargs)
658 postcomputes.append(x.__dask_postcompute__())
660 with shorten_traceback():
--> 661 results = schedule(dsk, keys, **kwargs)
663 return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
File /usr/local/lib/python3.10/site-packages/uproot/_dask.py:1316, in __call__()
1314 call_time = time.time_ns()
1315 try:
-> 1316 (result, counters), duration = with_duration(self._call_impl)(
1317 file_path, object_path, i_step_or_start, n_steps_or_stop, is_chunk
1318 )
1319 return (
1320 result,
1321 _report_success(
(...)
1329 ),
1330 )
1331 except self.allowed_exceptions as err:
File /usr/local/lib/python3.10/site-packages/uproot/_dask.py:1154, in wrapper()
1151 @functools.wraps(f)
1152 def wrapper(*args, **kwargs):
1153 start = time.monotonic()
-> 1154 result = f(*args, **kwargs)
1155 stop = time.monotonic()
1156 return result, (stop - start)
File /usr/local/lib/python3.10/site-packages/uproot/_dask.py:1298, in _call_impl()
1292 start, stop = min((i_step_or_start * events_per_step), num_entries), min(
1293 (i_step_or_start + 1) * events_per_step, num_entries
1294 )
1296 assert start <= stop
-> 1298 return self.read_tree(
1299 ttree,
1300 start,
1301 stop,
1302 )
File /usr/local/lib/python3.10/site-packages/uproot/_dask.py:985, in read_tree()
980 nplike = Numpy.instance()
982 # The remap implementation should correctly populate the generated
983 # buffer mapping in __call__, such that the high-level form can be
984 # used in `from_buffers`
--> 985 mapping = self.form_mapping_info.load_buffers(
986 tree,
987 self.common_keys,
988 start,
989 stop,
990 self.decompression_executor,
991 self.interpretation_executor,
992 self.interp_options,
993 )
995 # Populate container with placeholders if keys aren't required
996 # Otherwise, read from disk
997 container = {}
File /usr/local/lib/python3.10/site-packages/coffea/nanoevents/factory.py:157, in load_buffers()
151 partition_key = (
152 str(tree.file.uuid),
153 tree.object_path,
154 f"{start}-{stop}",
155 )
156 uuidpfn = {partition_key[0]: tree.file.file_path}
--> 157 arrays = tree.arrays(
158 keys,
159 entry_start=start,
160 entry_stop=stop,
161 ak_add_doc=interp_options["ak_add_doc"],
162 decompression_executor=decompression_executor,
163 interpretation_executor=interpretation_executor,
164 how=dict,
165 )
166 source_arrays = {
167 k: _OnlySliceableAs(v, slice(start, stop)) for k, v in arrays.items()
168 }
169 mapping = PreloadedSourceMapping(
170 PreloadedOpener(uuidpfn), start, stop, access_log=None
171 )
File /usr/local/lib/python3.10/site-packages/uproot/behaviors/TBranch.py:823, in arrays()
820 ranges_or_baskets.append((branch, basket_num, range_or_basket))
822 interp_options = {"ak_add_doc": ak_add_doc}
--> 823 _ranges_or_baskets_to_arrays(
824 self,
825 ranges_or_baskets,
826 branchid_interpretation,
827 entry_start,
828 entry_stop,
829 decompression_executor,
830 interpretation_executor,
831 library,
832 arrays,
833 False,
834 interp_options,
835 )
837 # no longer needed; save memory
838 del ranges_or_baskets
File /usr/local/lib/python3.10/site-packages/uproot/behaviors/TBranch.py:3105, in _ranges_or_baskets_to_arrays()
3102 pass
3104 elif isinstance(obj, tuple) and len(obj) == 3:
-> 3105 uproot.source.futures.delayed_raise(*obj)
3107 else:
3108 raise AssertionError(obj)
File /usr/local/lib/python3.10/site-packages/uproot/source/futures.py:38, in delayed_raise()
34 def delayed_raise(exception_class, exception_value, traceback):
35 """
36 Raise an exception from a background thread on the main thread.
37 """
---> 38 raise exception_value.with_traceback(traceback)
File /usr/local/lib/python3.10/site-packages/uproot/behaviors/TBranch.py:3026, in chunk_to_basket()
3024 try:
3025 cursor = uproot.source.cursor.Cursor(chunk.start)
-> 3026 basket = uproot.models.TBasket.Model_TBasket.read(
3027 chunk,
3028 cursor,
3029 {"basket_num": basket_num},
3030 hasbranches._file,
3031 hasbranches._file,
3032 branch,
3033 )
3034 original_index = range_original_index[(chunk.start, chunk.stop)]
3035 if update_ranges_or_baskets:
File /usr/local/lib/python3.10/site-packages/uproot/model.py:854, in read()
852 forth_obj.add_node(forth_stash)
853 forth_obj.push_active_node(forth_stash)
--> 854 self.read_members(chunk, cursor, context, file)
855 if forth_obj is not None:
856 forth_obj.pop_active_node()
File /usr/local/lib/python3.10/site-packages/uproot/models/TBasket.py:227, in read_members()
217 assert isinstance(self._parent, uproot.behaviors.TBranch.TBranch)
218 self._basket_num = context.get("basket_num")
220 (
221 self._members["fNbytes"],
222 self._key_version,
223 self._members["fObjlen"],
224 self._members["fDatime"],
225 self._members["fKeylen"],
226 self._members["fCycle"],
--> 227 ) = cursor.fields(chunk, _tbasket_format1, context)
229 # skip the class name, name, and title
230 cursor.move_to(
231 self._cursor.index + self._members["fKeylen"] - _tbasket_format2.size - 1
232 )
File /usr/local/lib/python3.10/site-packages/uproot/source/cursor.py:201, in fields()
199 if move:
200 self._index = stop
--> 201 return format.unpack(chunk.get(start, stop, self, context))
File /usr/local/lib/python3.10/site-packages/uproot/source/chunk.py:446, in get()
424 """
425 Args:
426 start (int): Seek position of the first byte to include.
(...)
443 already.
444 """
445 if (start, stop) in self:
--> 446 self.wait(insist=stop)
447 local_start = start - self._start
448 local_stop = stop - self._start
File /usr/local/lib/python3.10/site-packages/uproot/source/chunk.py:388, in wait()
377 """
378 Args:
379 insist (bool or int): If True, raise an OSError if ``raw_data`` does
(...)
385 :ref:`uproot.source.chunk.Chunk.future` completes).
386 """
387 if self._raw_data is None:
--> 388 self._raw_data = numpy.frombuffer(self._future.result(), dtype=self._dtype)
389 if insist is True:
390 requirement = len(self._raw_data) == self._stop - self._start
TypeError: a bytes-like object is required, not 'ServerDisconnectedError'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment