From 343d490f128c9f9c9801fad0a28eb93dfc21e737 Mon Sep 17 00:00:00 2001 From: Austin Noto-Moniz Date: Fri, 27 Feb 2026 13:58:11 -0500 Subject: [PATCH] Deprecation removals. --- .../predictors/chemical_formula_featurizer.py | 6 +-- src/citrine/jobs/job.py | 39 ++++++------------- tests/jobs/test_deprecations.py | 39 ------------------- tests/jobs/test_job_status.py | 30 ++++++++++++++ 4 files changed, 43 insertions(+), 71 deletions(-) delete mode 100644 tests/jobs/test_deprecations.py create mode 100644 tests/jobs/test_job_status.py diff --git a/src/citrine/informatics/predictors/chemical_formula_featurizer.py b/src/citrine/informatics/predictors/chemical_formula_featurizer.py index f595732e2..40f77d9b1 100644 --- a/src/citrine/informatics/predictors/chemical_formula_featurizer.py +++ b/src/citrine/informatics/predictors/chemical_formula_featurizer.py @@ -1,4 +1,4 @@ -from warnings import warn +from deprecation import deprecated from citrine._rest.resource import Resource from citrine._serialization import properties @@ -153,11 +153,9 @@ def __init__(self, self.powers = powers if powers is not None else [1.0] @property + @deprecated(deprecated_in="4.0.0", removed_in="5.0.0", details="Use 'powers' instead.") def powers_as_float(self) -> list[float]: """Powers when computing generalized weighted means of element properties.""" - warn("'powers_as_float' is deprecated as of v4.0.0 in favor of 'powers', and will be " - "removed in v5.0.0", - DeprecationWarning) return self.powers def __str__(self): diff --git a/src/citrine/jobs/job.py b/src/citrine/jobs/job.py index 79215c142..e6af018fe 100644 --- a/src/citrine/jobs/job.py +++ b/src/citrine/jobs/job.py @@ -2,7 +2,6 @@ from logging import getLogger from time import time, sleep from uuid import UUID -from warnings import warn from citrine._rest.resource import Resource from citrine._serialization.properties import Set as PropertySet, String, Object @@ -51,20 +50,13 @@ class TaskNode(Resource['TaskNode']): """:str: if a task has failed, the failure reason will be in this parameter""" @property - def status(self) -> JobStatus | str: + def status(self) -> JobStatus: """The last reported status of this particular task.""" - if resolved := JobStatus.from_str(self._status, exception=False): - return resolved - else: - return self._status + return JobStatus.from_str(self._status, exception=False) @status.setter def status(self, value: JobStatus | str) -> None: - if JobStatus.from_str(value, exception=False) is None: - warn( - f"{value} is not a recognized JobStatus; this will become an error as of v4.0.0.", - DeprecationWarning - ) + JobStatus.from_str(value, exception=True) self._status = value @@ -84,27 +76,18 @@ class JobStatusResponse(Resource['JobStatusResponse']): """:dict[str, str] | None: job output properties and results""" @property - def status(self) -> JobStatus | str: + def status(self) -> JobStatus: """The last reported status of this particular task.""" - if resolved := JobStatus.from_str(self._status, exception=False): - return resolved - else: - return self._status + return JobStatus.from_str(self._status, exception=False) @status.setter def status(self, value: JobStatus | str) -> None: - if resolved := JobStatus.from_str(value, exception=False): - if resolved not in [JobStatus.RUNNING, JobStatus.SUCCESS, JobStatus.FAILURE]: - warn( - f"{value} is not a valid JobStatus for a JobStatusResponse; " - f"this will become an error as of v4.0.0.", - DeprecationWarning - ) - else: - warn( - f"{value} is not a recognized JobStatus; this will become an error as of v4.0.0.", - DeprecationWarning - ) + if resolved := JobStatus.from_str(value, exception=True): + valid = [JobStatus.RUNNING, JobStatus.SUCCESS, JobStatus.FAILURE] + if resolved not in valid: + raise ValueError(f"{value} is not a valid JobStatus for a JobStatusResponse; " + f"valid choices are {[x for x in valid]}") + self._status = value diff --git a/tests/jobs/test_deprecations.py b/tests/jobs/test_deprecations.py deleted file mode 100644 index af0b870ee..000000000 --- a/tests/jobs/test_deprecations.py +++ /dev/null @@ -1,39 +0,0 @@ -from citrine.jobs.job import JobStatus, JobStatusResponse, TaskNode -import pytest -import warnings - -from tests.utils.factories import TaskNodeDataFactory, JobStatusResponseDataFactory - -def test_status_response_status(): - status_response = JobStatusResponse.build(JobStatusResponseDataFactory(failure=True)) - assert status_response.status == JobStatus.FAILURE - - with pytest.deprecated_call(): - status_response.status = 'Failed' - with warnings.catch_warnings(): - warnings.simplefilter("error") - assert not isinstance(status_response.status, JobStatus) - - with pytest.deprecated_call(): - status_response.status = JobStatus.PENDING - with warnings.catch_warnings(): - warnings.simplefilter("error") - assert status_response.status == JobStatus.PENDING - - with warnings.catch_warnings(): - warnings.simplefilter("error") - status_response.status = JobStatus.SUCCESS - assert status_response.status == JobStatus.SUCCESS - -def test_task_node_status(): - status_response = TaskNode.build(TaskNodeDataFactory(failure=True)) - assert status_response.status == JobStatus.FAILURE - - with pytest.deprecated_call(): - status_response.status = 'Failed' - assert not isinstance(status_response.status, JobStatus) - - with warnings.catch_warnings(): - warnings.simplefilter("error") - status_response.status = JobStatus.SUCCESS - assert status_response.status == JobStatus.SUCCESS diff --git a/tests/jobs/test_job_status.py b/tests/jobs/test_job_status.py new file mode 100644 index 000000000..7bbbba264 --- /dev/null +++ b/tests/jobs/test_job_status.py @@ -0,0 +1,30 @@ +from citrine.jobs.job import JobStatus, JobStatusResponse, TaskNode +import pytest + +from tests.utils.factories import TaskNodeDataFactory, JobStatusResponseDataFactory + +def test_status_response_status(): + status_response = JobStatusResponse.build(JobStatusResponseDataFactory(failure=True)) + assert status_response.status == JobStatus.FAILURE + + with pytest.raises(ValueError): + status_response.status = 'Failed' + assert isinstance(status_response.status, JobStatus) + + with pytest.raises(ValueError): + status_response.status = JobStatus.PENDING + assert status_response.status != JobStatus.PENDING + + status_response.status = JobStatus.SUCCESS + assert status_response.status == JobStatus.SUCCESS + +def test_task_node_status(): + status_response = TaskNode.build(TaskNodeDataFactory(failure=True)) + assert status_response.status == JobStatus.FAILURE + + with pytest.raises(ValueError): + status_response.status = 'Failed' + assert isinstance(status_response.status, JobStatus) + + status_response.status = JobStatus.SUCCESS + assert status_response.status == JobStatus.SUCCESS