From 0ab9cce88e9a47b2ff22ad3e0f5b7968ff6657a2 Mon Sep 17 00:00:00 2001 From: rodsca Date: Tue, 23 May 2023 21:41:29 +0000 Subject: [PATCH 1/5] exclude_archived option added to batches retrieval --- .pre-commit-config.yaml | 2 +- scaleapi/__init__.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bb7b03..384798f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: rev: 20.8b1 hooks: - id: black -- repo: https://gitlab.com/pycqa/flake8 +- repo: https://github.com/PyCQA/flake8 rev: 3.8.4 hooks: - id: flake8 diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index b3fc179..63864c8 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -689,6 +689,9 @@ def batches(self, **kwargs) -> Batchlist: The maximum value of `created_at` in UTC timezone ISO format: 'YYYY-MM-DD HH:MM:SS.mmmmmm' + exclude_archived (bool): + A flag to exclude archived batches if True + status (str): Status to filter batches by @@ -710,6 +713,7 @@ def batches(self, **kwargs) -> Batchlist: allowed_kwargs = { "start_time", "end_time", + "exclude_archived" "status", "project", "limit", @@ -739,6 +743,7 @@ def get_batches( batch_status: BatchStatus = None, created_after: str = None, created_before: str = None, + exclude_archived: bool = False ) -> Generator[Batch, None, None]: """`Generator` method to yield all batches with the given parameters. @@ -761,6 +766,9 @@ def get_batches( The maximum value of `created_at` in UTC timezone ISO format: 'YYYY-MM-DD HH:MM:SS.mmmmmm' + exclude_archived (bool): + A flag to exclude archived batches if True + Yields: Generator[Batch]: Yields Batch, can be iterated. @@ -777,6 +785,9 @@ def get_batches( "offset": offset, } + if exclude_archived: + batches_args["exclude_archived"] = True + if batch_status: batches_args["status"] = batch_status.value From 7aa56e42b879a73fc10afe0b6bb3100770b8edf1 Mon Sep 17 00:00:00 2001 From: rodsca Date: Wed, 24 May 2023 16:01:16 +0000 Subject: [PATCH 2/5] version bump --- scaleapi/__init__.py | 5 ++--- scaleapi/_version.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 63864c8..5a36d5a 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -713,8 +713,7 @@ def batches(self, **kwargs) -> Batchlist: allowed_kwargs = { "start_time", "end_time", - "exclude_archived" - "status", + "exclude_archived" "status", "project", "limit", "offset", @@ -743,7 +742,7 @@ def get_batches( batch_status: BatchStatus = None, created_after: str = None, created_before: str = None, - exclude_archived: bool = False + exclude_archived: bool = False, ) -> Generator[Batch, None, None]: """`Generator` method to yield all batches with the given parameters. diff --git a/scaleapi/_version.py b/scaleapi/_version.py index 6875128..6984877 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.14.1" +__version__ = "2.14.2" __package_name__ = "scaleapi" From f482160bce691c2deb42aba24ff4fb0ecd94d176 Mon Sep 17 00:00:00 2001 From: rodsca Date: Wed, 24 May 2023 16:08:10 +0000 Subject: [PATCH 3/5] fix args --- scaleapi/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 5a36d5a..18e5f19 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -713,7 +713,8 @@ def batches(self, **kwargs) -> Batchlist: allowed_kwargs = { "start_time", "end_time", - "exclude_archived" "status", + "exclude_archived", + "status", "project", "limit", "offset", From 26a04f75493a4729f8c536e478db55ed8136f2cd Mon Sep 17 00:00:00 2001 From: Rodrigo Soriano <115799717+rodsca@users.noreply.github.com> Date: Tue, 30 May 2023 18:00:28 -0300 Subject: [PATCH 4/5] Update scaleapi/__init__.py Co-authored-by: Fatih Kurtoglu --- scaleapi/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 18e5f19..5503a1c 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -783,6 +783,7 @@ def get_batches( "end_time": created_before, "project": project_name, "offset": offset, + "exclude_archived": exclude_archived, } if exclude_archived: From 12e196513fef07c739436466bca19f9ab2df859b Mon Sep 17 00:00:00 2001 From: Rodrigo Soriano <115799717+rodsca@users.noreply.github.com> Date: Tue, 30 May 2023 18:00:37 -0300 Subject: [PATCH 5/5] Update scaleapi/__init__.py Co-authored-by: Fatih Kurtoglu --- scaleapi/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 5503a1c..f0a14d9 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -786,9 +786,6 @@ def get_batches( "exclude_archived": exclude_archived, } - if exclude_archived: - batches_args["exclude_archived"] = True - if batch_status: batches_args["status"] = batch_status.value