From e89afadfc90f414bec3c9d4db5923359f3543337 Mon Sep 17 00:00:00 2001 From: Sait Cakmak Date: Tue, 17 Feb 2026 13:48:07 -0800 Subject: [PATCH] Replace deprecated abstractproperty with @property + @abstractmethod Summary: `abc.abstractproperty` has been deprecated since Python 3.3 in favor of stacking `property` and `abstractmethod` decorators. This replaces all remaining usages across 4 files in the Ax codebase. Differential Revision: D93279592 --- ax/core/base_trial.py | 14 +++++++++----- ax/core/parameter.py | 5 +++-- ax/storage/registry_bundle.py | 11 +++++++---- ax/utils/common/result.py | 11 +++++++---- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ax/core/base_trial.py b/ax/core/base_trial.py index c06fc2ce7d5..23a20065467 100644 --- a/ax/core/base_trial.py +++ b/ax/core/base_trial.py @@ -8,7 +8,7 @@ from __future__ import annotations -from abc import ABC, abstractmethod, abstractproperty +from abc import ABC, abstractmethod from collections.abc import Callable from copy import deepcopy from datetime import datetime, timedelta @@ -133,19 +133,22 @@ def __init__( # might be getting deployed to. self._properties: dict[str, Any] = {} - @abstractproperty + @property + @abstractmethod def arms(self) -> list[Arm]: """All arms associated with this trial.""" pass - @abstractproperty + @property + @abstractmethod def arms_by_name(self) -> dict[str, Arm]: """A mapping of from arm names, to all arms associated with this trial. """ pass - @abstractproperty + @property + @abstractmethod def abandoned_arms(self) -> list[Arm]: """All abandoned arms, associated with this trial.""" pass @@ -473,7 +476,8 @@ def active_arms(self) -> list[Arm]: """All non abandoned arms associated with this trial.""" return [arm for arm in self.arms if arm not in self.abandoned_arms] - @abstractproperty + @property + @abstractmethod def generator_runs(self) -> list[GeneratorRun]: """All generator runs associated with this trial.""" pass diff --git a/ax/core/parameter.py b/ax/core/parameter.py index e396c792677..cfb024f4e1b 100644 --- a/ax/core/parameter.py +++ b/ax/core/parameter.py @@ -9,7 +9,7 @@ from __future__ import annotations import math -from abc import ABCMeta, abstractmethod, abstractproperty +from abc import ABCMeta, abstractmethod from copy import deepcopy from enum import Enum from logging import Logger @@ -283,7 +283,8 @@ def _base_repr(self) -> str: return ret_val - @abstractproperty + @property + @abstractmethod def domain_repr(self) -> str: """Returns a string representation of the domain.""" pass diff --git a/ax/storage/registry_bundle.py b/ax/storage/registry_bundle.py index 433142afcea..40ed81500d6 100644 --- a/ax/storage/registry_bundle.py +++ b/ax/storage/registry_bundle.py @@ -7,7 +7,7 @@ from __future__ import annotations -from abc import ABC, abstractproperty +from abc import ABC, abstractmethod from collections import ChainMap from collections.abc import Callable from functools import cached_property @@ -129,15 +129,18 @@ def class_encoder_registry(self) -> dict[type, Callable[[Any], dict[str, Any]]]: def class_decoder_registry(self) -> dict[str, Callable[[dict[str, Any]], Any]]: return self._json_class_decoder_registry - @abstractproperty + @property + @abstractmethod def sqa_config(self) -> SQAConfig: pass - @abstractproperty + @property + @abstractmethod def encoder(self) -> Encoder: pass - @abstractproperty + @property + @abstractmethod def decoder(self) -> Decoder: pass diff --git a/ax/utils/common/result.py b/ax/utils/common/result.py index 63dbe349032..da250d99458 100644 --- a/ax/utils/common/result.py +++ b/ax/utils/common/result.py @@ -8,7 +8,7 @@ from __future__ import annotations import traceback -from abc import ABC, abstractmethod, abstractproperty +from abc import ABC, abstractmethod from collections.abc import Callable from functools import reduce from typing import Any, cast, Generic, NoReturn, TypeVar @@ -35,15 +35,18 @@ def is_ok(self) -> bool: def is_err(self) -> bool: pass - @abstractproperty + @property + @abstractmethod def ok(self) -> T | None: pass - @abstractproperty + @property + @abstractmethod def err(self) -> E | None: pass - @abstractproperty + @property + @abstractmethod def value(self) -> T | E: pass