Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Deprecate process IDs (#118)
Browse files Browse the repository at this point in the history
* deprecate process IDs

* remove README
  • Loading branch information
malmans2 authored Nov 13, 2024
1 parent 0b31dc5 commit c4f3c77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
13 changes: 0 additions & 13 deletions cads_api_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 10 additions & 3 deletions cads_api_client/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_test_20_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
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


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(
Expand Down

0 comments on commit c4f3c77

Please sign in to comment.