class_docstr: Utility class for inspecting the state of a cluster dump
  
  .. code-block:: python
  
      dump = DumpArtefact.from_url("dump.msgpack.gz")
      memory_tasks = dump.scheduler_tasks("memory")
      executing_tasks = dump.worker_tasks("executing")
class_docstr_tok: ["Utility","class","for","inspecting","the","state","of","a","cluster","dump","..","code-block",":",":","python","dump","=","DumpArtefact.from_url","(","``","dump.msgpack.gz","''",")","memory_tasks","=","dump.scheduler_tasks","(","``","memory","''",")","executing_tasks","=","dump.worker_tasks","(","``","executing","''",")"]
docstr: Parameters
  ----------
  state : optional, str
      If provided, only tasks in the given state are returned.
      Otherwise, all tasks are returned.
  
  Returns
  -------
  tasks : list
      The list of worker tasks in ``state``
docstr_tok: ["Parameters","--","--","--","--","--","state",":","optional",",","str","If","provided",",","only","tasks","in","the","given","state","are","returned",".","Otherwise",",","all","tasks","are","returned",".","Returns","--","--","--","-","tasks",":","list","The","list","of","worker","tasks","in","``","state","``"]
code: def worker_tasks_in_state(self, state: str | None = None) -> list:
      """
      Parameters
      ----------
      state : optional, str
          If provided, only tasks in the given state are returned.
          Otherwise, all tasks are returned.
  
      Returns
      -------
      tasks : list
          The list of worker tasks in ``state``
      """
      tasks = []
  
      for worker_dump in self.dump["workers"].values():
          if isinstance(worker_dump, dict) and "tasks" in worker_dump:
              tasks.extend(
                  self._extract_tasks(state, worker_dump["tasks"])
              )
  
      return tasks
  
imports: from __future__ import annotations
  import asyncio
  from collections import defaultdict
  from collections.abc import Awaitable, Callable, Collection, Mapping
  from pathlib import Path
  from typing import IO, Any, Literal
  import msgpack
  from dask.typing import Key
  from distributed._stories import scheduler_story
  from distributed._stories import worker_story
label_desc: Use image node_id 8 for calling the DumpArtefact obj's underlying member method code with example usage: obj.worker_tasks_in_state(state) and returns: tasks