From c4f3c7791e4f0ea66be8f59e3f675fa59dc97a83 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Wed, 13 Nov 2024 09:03:32 +0100 Subject: [PATCH] Deprecate process IDs (#118) * deprecate process IDs * remove README --- cads_api_client/api_client.py | 13 ------------- cads_api_client/processing.py | 13 ++++++++++--- tests/integration_test_20_processing.py | 8 ++++---- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/cads_api_client/api_client.py b/cads_api_client/api_client.py index c8bd622..1458e43 100644 --- a/cads_api_client/api_client.py +++ b/cads_api_client/api_client.py @@ -364,19 +364,6 @@ def get_processes( limit: int | None = None, sortby: Literal[None, "id", "-id"] = None, ) -> cads_api_client.Processes: - """Retrieve available processes. - - Parameters - ---------- - limit: int or None - Number of processes per page. - sortby: {None, 'id', '-id'} - Field to sort results by. - - Returns - ------- - cads_api_client.Processes - """ params = { k: v for k, v in zip(["limit", "sortby"], [limit, sortby]) if v is not None } diff --git a/cads_api_client/processing.py b/cads_api_client/processing.py index f1d0a88..b86fb4a 100644 --- a/cads_api_client/processing.py +++ b/cads_api_client/processing.py @@ -286,12 +286,19 @@ def prev(self) -> Self | None: @attrs.define class Processes(ApiResponsePaginated): - """A class to interact with available processes.""" + @property + def collection_ids(self) -> list[str]: + """Available collection IDs.""" + return [proc["id"] for proc in self._json_dict["processes"]] @property def process_ids(self) -> list[str]: - """Available process IDs.""" - return [proc["id"] for proc in self._json_dict["processes"]] + warnings.warn( + "`.process_ids` has been deprecated, and in the future will raise an error." + " Please use `.collection_ids` from now on.", + DeprecationWarning, + ) + return self.collection_ids @attrs.define diff --git a/tests/integration_test_20_processing.py b/tests/integration_test_20_processing.py index 4886960..26dc732 100644 --- a/tests/integration_test_20_processing.py +++ b/tests/integration_test_20_processing.py @@ -9,7 +9,7 @@ def test_processig_processes_limit(api_anon_client: ApiClient) -> None: processes = api_anon_client.get_processes(limit=1) assert isinstance(processes, Processes) - assert len(processes.process_ids) == 1 + assert len(processes.collection_ids) == 1 next_processes = processes.next assert next_processes is not None assert len(next_processes.process_ids) == 1 @@ -17,11 +17,11 @@ def test_processig_processes_limit(api_anon_client: ApiClient) -> None: def test_processing_processes_sortby(api_anon_client: ApiClient) -> None: processes = api_anon_client.get_processes(sortby="id") - assert len(processes.process_ids) > 1 - assert processes.process_ids == sorted(processes.process_ids) + assert len(processes.collection_ids) > 1 + assert processes.collection_ids == sorted(processes.collection_ids) processes = api_anon_client.get_processes(sortby="-id") - assert processes.process_ids == sorted(processes.process_ids, reverse=True) + assert processes.collection_ids == sorted(processes.collection_ids, reverse=True) def test_processing_process(