From c1a26fadde00d97748b2ed898faead4c2bf36f9a Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Sat, 25 Oct 2025 20:58:39 -0500 Subject: [PATCH 1/6] attempt 3.14 support --- .github/workflows/ci.yml | 2 +- pyproject.toml | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8aacf756..4bb4c9bc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: os: [ubuntu-latest, ubuntu-24.04-arm, macOS-latest, windows-latest] java-version: [17] java-distribution: ["corretto"] - python-version: ["3.9", "3.13"] + python-version: ["3.9", "3.13", "3.14"] dask-client: ["with", "without"] name: Test (${{ matrix.os }}) - py ${{ matrix.python-version }}, JDK${{ matrix.java-version }}, ${{ matrix.dask-client }} dask diff --git a/pyproject.toml b/pyproject.toml index b7d7c312b..9db7b96ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,12 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Mathematics", @@ -48,7 +54,8 @@ dependencies = [ "correctionlib>=2.6.0", "pyarrow>=6.0.0", "matplotlib>=3", - "numba>=0.58.1", + "numba>=0.58.1; python_version<'3.14'", + "numba>=0.63.0b1; python_version>='3.14'", "numpy>=1.22", "scipy>=1.1.0", "tqdm>=4.27.0", From 0872a5d37a1cfd6394a4849d07f7fdeb4dab6ec2 Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Sat, 25 Oct 2025 21:11:02 -0500 Subject: [PATCH 2/6] add llvmlite --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9db7b96ce..c29d1f240 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ dependencies = [ "matplotlib>=3", "numba>=0.58.1; python_version<'3.14'", "numba>=0.63.0b1; python_version>='3.14'", + "llvmlite>=0.46.0b1; python_version>='3.14'", "numpy>=1.22", "scipy>=1.1.0", "tqdm>=4.27.0", From 2cc46e15a0850ce1bb11f54710cebbc0997ee2a2 Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Sat, 25 Oct 2025 21:26:18 -0500 Subject: [PATCH 3/6] we need lz4 from master --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c29d1f240..0f63241da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dependencies = [ "numpy>=1.22", "scipy>=1.1.0", "tqdm>=4.27.0", - "lz4", + "lz4 @ https://github.com/python-lz4/python-lz4.git", "cloudpickle>=1.2.3", "toml>=0.10.2", "mplhep>=0.1.18", @@ -122,6 +122,7 @@ dev = [ [tool.hatch] version.source = "vcs" build.hooks.vcs.version-file = "src/coffea/_version.py" +metadata.allow-direct-references = true [tool.pytest.ini_options] minversion = "6.0" From b2a539f6fbab17b76bb1d177fde2971233f00aa4 Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Mon, 3 Nov 2025 23:14:04 -0600 Subject: [PATCH 4/6] lz4 now has a 314 release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 66352f753..4183579d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ dependencies = [ "numpy>=1.22", "scipy>=1.1.0", "tqdm>=4.27.0", - "lz4 @ https://github.com/python-lz4/python-lz4.git", + "lz4", "cloudpickle>=1.2.3", "toml>=0.10.2", "mplhep>=0.1.18", From 3b0fe0ecc622d6cb2ed1c95892092e4201ad10ca Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Mon, 10 Nov 2025 17:21:11 -0600 Subject: [PATCH 5/6] drop 3.9, support 3.14 --- .github/workflows/ci.yml | 18 +++++++++--------- pyproject.toml | 4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a3183515..29be5ad42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: - python-version: "3.13" + python-version: "3.14" - uses: pre-commit/action@v3.0.1 with: extra_args: --hook-stage manual --all-files @@ -36,7 +36,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, ubuntu-24.04-arm, macOS-latest, windows-latest] - python-version: ["3.9", "3.13", "3.14"] + python-version: ["3.10", "3.14"] dask-client: ["with", "without"] name: Test (${{ matrix.os }}) - py ${{ matrix.python-version }}, ${{ matrix.dask-client }} dask @@ -108,21 +108,21 @@ jobs: run: | python -m pytest --cov-report=xml --cov=coffea --deselect=test_taskvine -m "dask_client" - name: Upload codecov - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.13 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14 uses: codecov/codecov-action@v5 - name: Install graphviz - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.13 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14 uses: ts-graphviz/setup-graphviz@v2 - name: Install pandoc - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.13 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14 uses: r-lib/actions/setup-pandoc@v2 - name: Build documentation - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.13 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14 run: | cd docs && make html touch build/html/.nojekyll # - name: Deploy documentation - # if: github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == 3.13 + # if: github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14 # uses: crazy-max/ghaction-github-pages@v4 # with: # target_branch: gh-pages @@ -135,7 +135,7 @@ jobs: needs: pre-commit strategy: matrix: - python-version: ["3.13"] + python-version: ["3.14"] name: test coffea-taskvine steps: - uses: actions/checkout@v5 @@ -194,7 +194,7 @@ jobs: contents: read strategy: matrix: - python-version: ["3.13"] + python-version: ["3.14"] name: deploy release steps: diff --git a/pyproject.toml b/pyproject.toml index 4183579d1..157c8ec2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "coffea" description = "Basic tools and wrappers for enabling not-too-alien syntax when running columnar Collider HEP analysis." readme = "README.rst" license = {text = "BSD-3-Clause"} -requires-python = ">=3.9" +requires-python = ">=3.10" authors = [ { name = "Lindsey Gray", email = "lagray@fnal.gov" }, { name = "Nick Smith", email = "ncsmith@fnal.gov" }, @@ -31,7 +31,6 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -121,7 +120,6 @@ dev = [ [tool.hatch] version.source = "vcs" build.hooks.vcs.version-file = "src/coffea/_version.py" -metadata.allow-direct-references = true [tool.pytest.ini_options] minversion = "6.0" From 006d346e8d0790f4a98c5e826901ba8806b76cb1 Mon Sep 17 00:00:00 2001 From: Iason Krommydas Date: Mon, 10 Nov 2025 17:29:39 -0600 Subject: [PATCH 6/6] py310+ typing --- .pre-commit-config.yaml | 2 +- docs/source/ParticleNet.py | 4 +- src/coffea/dataset_tools/apply_processor.py | 4 +- src/coffea/dataset_tools/manipulations.py | 3 +- src/coffea/dataset_tools/preprocess.py | 4 +- src/coffea/ml_tools/torch_wrapper.py | 5 +- src/coffea/ml_tools/triton_wrapper.py | 5 +- src/coffea/ml_tools/xgboost_wrapper.py | 9 +- src/coffea/nanoevents/methods/base.py | 11 ++- src/coffea/nanoevents/trace.py | 2 +- src/coffea/processor/accumulator.py | 6 +- src/coffea/processor/executor.py | 103 ++++++++++---------- src/coffea/processor/taskvine_executor.py | 23 +++-- src/coffea/util.py | 4 +- 14 files changed, 86 insertions(+), 99 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 798749367..efe1a48ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,7 @@ repos: rev: v3.21.0 hooks: - id: pyupgrade - args: ["--py39-plus"] + args: ["--py310-plus"] - repo: https://github.com/asottile/setup-cfg-fmt rev: v3.1.0 diff --git a/docs/source/ParticleNet.py b/docs/source/ParticleNet.py index 959e95159..807e52838 100644 --- a/docs/source/ParticleNet.py +++ b/docs/source/ParticleNet.py @@ -1,5 +1,3 @@ -from typing import Optional - import numpy as np import torch import torch.nn as nn @@ -216,7 +214,7 @@ def forward(self, points, features, mask): points *= mask features *= mask coord_shift = (mask == 0) * 1e9 - counts: Optional[torch.Tensor] = None + counts: torch.Tensor | None = None if self.use_counts: counts = mask.float().sum(dim=-1) counts = torch.max(counts, torch.ones_like(counts)) # >=1 diff --git a/src/coffea/dataset_tools/apply_processor.py b/src/coffea/dataset_tools/apply_processor.py index 5ce6c77f4..753983ba1 100644 --- a/src/coffea/dataset_tools/apply_processor.py +++ b/src/coffea/dataset_tools/apply_processor.py @@ -1,8 +1,8 @@ from __future__ import annotations import copy -from collections.abc import Hashable -from typing import Any, Callable, Union +from collections.abc import Callable, Hashable +from typing import Any, Union import awkward import dask.base diff --git a/src/coffea/dataset_tools/manipulations.py b/src/coffea/dataset_tools/manipulations.py index 96286b26a..ee5de1ad0 100644 --- a/src/coffea/dataset_tools/manipulations.py +++ b/src/coffea/dataset_tools/manipulations.py @@ -1,7 +1,8 @@ from __future__ import annotations import copy -from typing import Any, Callable +from collections.abc import Callable +from typing import Any import awkward import numpy diff --git a/src/coffea/dataset_tools/preprocess.py b/src/coffea/dataset_tools/preprocess.py index 1592e3352..a158f0453 100644 --- a/src/coffea/dataset_tools/preprocess.py +++ b/src/coffea/dataset_tools/preprocess.py @@ -4,10 +4,10 @@ import hashlib import math import warnings -from collections.abc import Hashable +from collections.abc import Callable, Hashable from dataclasses import dataclass from functools import partial -from typing import Any, Callable +from typing import Any import awkward import dask diff --git a/src/coffea/ml_tools/torch_wrapper.py b/src/coffea/ml_tools/torch_wrapper.py index 882e7f1e4..f14e27437 100644 --- a/src/coffea/ml_tools/torch_wrapper.py +++ b/src/coffea/ml_tools/torch_wrapper.py @@ -1,5 +1,4 @@ import warnings -from typing import Optional import numpy @@ -54,9 +53,7 @@ class torch_wrapper(nonserializable_attribute, numpy_call_wrapper): be ignored in the operation. """ - def __init__( - self, torch_jit: str, expected_output_shape: Optional[tuple[int]] = None - ): + def __init__(self, torch_jit: str, expected_output_shape: tuple[int] | None = None): if _torch_import_error is not None: warnings.warn( "Users should make sure the torch package is installed before proceeding!\n" diff --git a/src/coffea/ml_tools/triton_wrapper.py b/src/coffea/ml_tools/triton_wrapper.py index 6e8769b71..bacbde140 100644 --- a/src/coffea/ml_tools/triton_wrapper.py +++ b/src/coffea/ml_tools/triton_wrapper.py @@ -1,6 +1,5 @@ # For python niceties import warnings -from typing import Optional import numpy @@ -57,9 +56,7 @@ class triton_wrapper(nonserializable_attribute, numpy_call_wrapper): batch_size_fallback = 10 # Fall back should batch size not be determined. http_client_concurrency = 12 # TODO: check whether this value is optimum - def __init__( - self, model_url: str, client_args: Optional[dict] = None, batch_size=-1 - ): + def __init__(self, model_url: str, client_args: dict | None = None, batch_size=-1): if _triton_import_error is not None: warnings.warn( "Users should make sure the tritonclient package is installed before proceeding!\n" diff --git a/src/coffea/ml_tools/xgboost_wrapper.py b/src/coffea/ml_tools/xgboost_wrapper.py index f1db6b9c0..9d261fc98 100644 --- a/src/coffea/ml_tools/xgboost_wrapper.py +++ b/src/coffea/ml_tools/xgboost_wrapper.py @@ -1,5 +1,4 @@ import warnings -from typing import Optional import numpy @@ -45,8 +44,8 @@ def _create_xgbooster(self) -> "xgboost.Booster": def validate_numpy_input( self, data: numpy.ndarray, - dmat_args: Optional[dict] = None, - predict_args: Optional[dict] = None, + dmat_args: dict | None = None, + predict_args: dict | None = None, ): """ Check that the arguments to be passed into the actual xgboost inference @@ -84,8 +83,8 @@ def validate_numpy_input( def numpy_call( self, data: numpy.ndarray, - dmat_args: Optional[dict] = None, - predict_args: Optional[dict] = None, + dmat_args: dict | None = None, + predict_args: dict | None = None, ): """ Pass the numpy array data as-is to the construction of an diff --git a/src/coffea/nanoevents/methods/base.py b/src/coffea/nanoevents/methods/base.py index d1d953733..a21275bf6 100644 --- a/src/coffea/nanoevents/methods/base.py +++ b/src/coffea/nanoevents/methods/base.py @@ -2,8 +2,9 @@ import re from abc import abstractmethod +from collections.abc import Callable from functools import partial -from typing import Any, Callable, Union +from typing import Any import awkward import dask_awkward @@ -18,7 +19,7 @@ def _add_systematic_wrapper( self, name: str, kind: str, - what: Union[str, list[str], tuple[str]], + what: str | list[str] | tuple[str], varying_function: Callable, ): self.add_systematic(name, kind, what, varying_function) @@ -105,7 +106,7 @@ def systematics(self): def _build_variations( self, name: str, - what: Union[str, list[str], tuple[str]], + what: str | list[str] | tuple[str], varying_function: Callable, ): """ @@ -141,7 +142,7 @@ def add_systematic( self, name: str, kind: str, - what: Union[str, list[str], tuple[str]], + what: str | list[str] | tuple[str], varying_function: Callable, ): """ @@ -218,7 +219,7 @@ def add_systematic( dask_array, name: str, kind: str, - what: Union[str, list[str], tuple[str]], + what: str | list[str] | tuple[str], varying_function: Callable, ): dask_array._ensure_systematics() diff --git a/src/coffea/nanoevents/trace.py b/src/coffea/nanoevents/trace.py index aba1ac7f0..e3d97c284 100644 --- a/src/coffea/nanoevents/trace.py +++ b/src/coffea/nanoevents/trace.py @@ -1,8 +1,8 @@ from __future__ import annotations import warnings +from collections.abc import Callable from functools import partial -from typing import Callable import awkward as ak diff --git a/src/coffea/processor/accumulator.py b/src/coffea/processor/accumulator.py index 759e0e163..c6036cbec 100644 --- a/src/coffea/processor/accumulator.py +++ b/src/coffea/processor/accumulator.py @@ -3,7 +3,7 @@ from abc import ABCMeta, abstractmethod from collections import defaultdict from collections.abc import Iterable, MutableMapping, MutableSet -from typing import Optional, TypeVar, Union +from typing import TypeVar, Union try: from typing import Protocol, runtime_checkable # type: ignore @@ -88,8 +88,8 @@ def iadd(a: Accumulatable, b: Accumulatable) -> Accumulatable: def accumulate( - items: Iterable[Optional[Accumulatable]], accum: Optional[Accumulatable] = None -) -> Optional[Accumulatable]: + items: Iterable[Accumulatable | None], accum: Accumulatable | None = None +) -> Accumulatable | None: gen = (x for x in items if x is not None) try: if accum is None: diff --git a/src/coffea/processor/executor.py b/src/coffea/processor/executor.py index 41dd8d1fb..c312fc5b2 100644 --- a/src/coffea/processor/executor.py +++ b/src/coffea/processor/executor.py @@ -8,7 +8,14 @@ import uuid import warnings from collections import defaultdict -from collections.abc import Awaitable, Generator, Iterable, Mapping, MutableMapping +from collections.abc import ( + Awaitable, + Callable, + Generator, + Iterable, + Mapping, + MutableMapping, +) from contextlib import ExitStack from dataclasses import dataclass, field from functools import partial @@ -16,10 +23,8 @@ from itertools import repeat from typing import ( Any, - Callable, Literal, Optional, - Union, ) import awkward @@ -172,7 +177,7 @@ class WorkItem: entrystart: int entrystop: int fileuuid: str - usermeta: Optional[dict] = field(default=None, compare=False) + usermeta: dict | None = field(default=None, compare=False) def __len__(self) -> int: return self.entrystop - self.entrystart @@ -345,8 +350,8 @@ class ExecutorBase: status: bool = True unit: str = "items" desc: str = "Processing" - compression: Optional[int] = 1 - function_name: Optional[str] = None + compression: int | None = 1 + function_name: str | None = None def __call__( self, @@ -368,7 +373,7 @@ def _watcher( FH: _FuturesHolder, executor: ExecutorBase, merge_fcn: Callable, - pool: Optional[Callable] = None, + pool: Callable | None = None, ) -> Accumulatable: with rich_bar() as progress: p_id = progress.add_task(executor.desc, total=FH.running, unit=executor.unit) @@ -558,20 +563,16 @@ class FuturesExecutor(ExecutorBase): Number of retries for failed tasks (default: 3) """ - pool: Union[ - Callable[..., concurrent.futures.Executor], concurrent.futures.Executor - ] = concurrent.futures.ProcessPoolExecutor # fmt: skip - mergepool: Optional[ - Union[ - Callable[..., concurrent.futures.Executor], - concurrent.futures.Executor, - bool, - ] - ] = None + pool: ( + Callable[..., concurrent.futures.Executor] | concurrent.futures.Executor + ) = concurrent.futures.ProcessPoolExecutor # fmt: skip + mergepool: None | ( + Callable[..., concurrent.futures.Executor] | concurrent.futures.Executor | bool + ) = None recoverable: bool = False - merging: Union[bool, tuple[int, int, int]] = False + merging: bool | tuple[int, int, int] = False workers: int = 1 - tailtimeout: Optional[int] = None + tailtimeout: int | None = None retries: int = 3 def __post_init__(self): @@ -686,7 +687,7 @@ class DaskExecutor(ExecutorBase): treereduction: int = 20 priority: int = 0 retries: int = 3 - heavy_input: Optional[bytes] = None + heavy_input: bytes | None = None use_dataframes: bool = False # secret options worker_affinity: bool = False @@ -867,12 +868,12 @@ class ParslExecutor(ExecutorBase): Number of retries for failed tasks (default: 3) """ - tailtimeout: Optional[int] = None + tailtimeout: int | None = None config: Optional["parsl.config.Config"] = None # noqa recoverable: bool = False - merging: Optional[Union[bool, tuple[int, int, int]]] = False - jobs_executors: Union[str, list] = "all" - merges_executors: Union[str, list] = "all" + merging: bool | tuple[int, int, int] | None = False + jobs_executors: str | list = "all" + merges_executors: str | list = "all" retries: int = 3 def __post_init__(self): @@ -1057,23 +1058,23 @@ class Runner: """ executor: ExecutorBase - pre_executor: Optional[ExecutorBase] = None + pre_executor: ExecutorBase | None = None chunksize: int = 100000 - maxchunks: Optional[int] = None - metadata_cache: Optional[MutableMapping] = None - skipbadfiles: Union[bool, tuple[type[BaseException], ...]] = False - xrootdtimeout: Optional[int] = 60 + maxchunks: int | None = None + metadata_cache: MutableMapping | None = None + skipbadfiles: bool | tuple[type[BaseException], ...] = False + xrootdtimeout: int | None = 60 align_clusters: bool = False savemetrics: bool = False - schema: Optional[schemas.BaseSchema] = schemas.NanoAODSchema + schema: schemas.BaseSchema | None = schemas.NanoAODSchema processor_compression: int = 1 - use_skyhook: Optional[bool] = False - skyhook_options: Optional[dict] = field(default_factory=dict) + use_skyhook: bool | None = False + skyhook_options: dict | None = field(default_factory=dict) format: str = "root" - checkpointer: Optional[CheckpointerABC] = None - cachestrategy: Optional[ - Union[Literal["dask-worker"], Callable[..., MutableMapping]] - ] = None + checkpointer: CheckpointerABC | None = None + cachestrategy: None | (Literal["dask-worker"] | Callable[..., MutableMapping]) = ( + None + ) @staticmethod def read_coffea_config(): @@ -1141,7 +1142,7 @@ def get_cache(cachestrategy): @staticmethod def automatic_retries( retries: int, - skipbadfiles: Union[bool, tuple[type[BaseException], ...]], + skipbadfiles: bool | tuple[type[BaseException], ...], func, *args, **kwargs, @@ -1425,9 +1426,7 @@ def _work_function( use_dataframes: bool, savemetrics: bool, item: WorkItem, - processor_instance: Union[ - ProcessorABC, Callable[[awkward.highlevel.Array], Any] - ], + processor_instance: ProcessorABC | Callable[[awkward.highlevel.Array], Any], uproot_options: dict, iteritems_options: dict, checkpointer: CheckpointerABC, @@ -1555,13 +1554,11 @@ def _work_function( def __call__( self, fileset: dict, - processor_instance: Union[ - ProcessorABC, Callable[[awkward.highlevel.Array], Any] - ], + processor_instance: ProcessorABC | Callable[[awkward.highlevel.Array], Any], *args, - treename: Optional[str] = None, - uproot_options: Optional[dict] = {}, - iteritems_options: Optional[dict] = {}, + treename: str | None = None, + uproot_options: dict | None = {}, + iteritems_options: dict | None = {}, ) -> Accumulatable: """Run the processor_instance on a given fileset @@ -1607,7 +1604,7 @@ def preprocess( self, fileset: dict, *args, - treename: Optional[str] = None, + treename: str | None = None, ) -> Generator: """Preprocess the fileset and generate work items @@ -1646,14 +1643,12 @@ def preprocess( def run( self, - fileset: Union[dict, str, list[WorkItem], Generator], - processor_instance: Union[ - ProcessorABC, Callable[[awkward.highlevel.Array], Any] - ], + fileset: dict | str | list[WorkItem] | Generator, + processor_instance: ProcessorABC | Callable[[awkward.highlevel.Array], Any], *args, - treename: Optional[str] = None, - uproot_options: Optional[dict] = {}, - iteritems_options: Optional[dict] = {}, + treename: str | None = None, + uproot_options: dict | None = {}, + iteritems_options: dict | None = {}, ) -> Accumulatable: """Run the processor_instance on a given fileset diff --git a/src/coffea/processor/taskvine_executor.py b/src/coffea/processor/taskvine_executor.py index 3addd1c6f..74a00109a 100644 --- a/src/coffea/processor/taskvine_executor.py +++ b/src/coffea/processor/taskvine_executor.py @@ -3,11 +3,10 @@ import os import re import signal -from collections.abc import Iterable +from collections.abc import Callable, Iterable from dataclasses import dataclass from multiprocessing.pool import ThreadPool from os.path import join -from typing import Callable, Optional from coffea.util import rich_bar @@ -135,31 +134,31 @@ class TaskVineExecutor(ExecutorBase): """ port: int = 9123 - manager_name: Optional[str] = None + manager_name: str | None = None status_display_interval: int = 5 ssl: bool = False filepath: str = "/tmp" - extra_input_files: Optional[list] = None - x509_proxy: Optional[str] = None - environment_file: Optional[str] = None + extra_input_files: list | None = None + x509_proxy: str | None = None + environment_file: str | None = None verbose: bool = False print_stdout: bool = False - password_file: Optional[str] = None + password_file: str | None = None treereduction: int = 20 cores: int = 1 - memory: Optional[int] = None - disk: Optional[int] = None - gpus: Optional[int] = None + memory: int | None = None + disk: int | None = None + gpus: int | None = None replicas: int = 1 disable_worker_transfers: bool = False resource_monitor: str = "off" resources_mode: str = "fixed" - fast_terminate_workers: Optional[int] = None + fast_terminate_workers: int | None = None retries: int = 3 split_on_exhaustion: bool = True checkpoint_proportion: float = 0.1 concurrent_reads: int = 2 - custom_init: Optional[Callable] = None + custom_init: Callable | None = None def __post_init__(self): if not vine: diff --git a/src/coffea/util.py b/src/coffea/util.py index 58247e1bd..cdc81e082 100644 --- a/src/coffea/util.py +++ b/src/coffea/util.py @@ -3,7 +3,7 @@ import base64 import gzip import hashlib -from typing import Any, Optional +from typing import Any import awkward import dask_awkward @@ -153,7 +153,7 @@ def _exception_chain(exc: BaseException) -> list[BaseException]: class SpeedColumn(ProgressColumn): """Renders human readable transfer speed.""" - def __init__(self, fmt: str = ".1f", table_column: Optional[Column] = None): + def __init__(self, fmt: str = ".1f", table_column: Column | None = None): self.fmt = fmt super().__init__(table_column=table_column)