Skip to content

Commit

Permalink
Make project optional for get_tasks_count (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihkurtoglu authored Aug 27, 2024
1 parent e3c2d05 commit 54c3b3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions scaleapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def get_tasks(

def get_tasks_count(
self,
project_name: str,
project_name: str = None,
batch_name: str = None,
task_type: TaskType = None,
status: TaskStatus = None,
Expand All @@ -470,7 +470,7 @@ def get_tasks_count(
"""Returns number of tasks with given filters.
Args:
project_name (str):
project_name (str, optional):
Project Name
batch_name (str, optional):
Expand Down Expand Up @@ -529,6 +529,11 @@ def get_tasks_count(
Returns number of tasks
"""

if not project_name and not batch_name:
raise ValueError(
"At least one of project_name or batch_name must be provided."
)

tasks_args = self._process_tasks_endpoint_args(
project_name,
batch_name,
Expand Down
2 changes: 1 addition & 1 deletion scaleapi/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.15.12"
__version__ = "2.15.13"
__package_name__ = "scaleapi"
7 changes: 7 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,13 @@ def test_get_tasks_count():
assert tasks_count == get_tasks_count


def test_get_tasks_count_with_only_batch():
batch = create_a_batch()
tasks_count = client.tasks(batch=batch.name).total
get_tasks_count = client.get_tasks_count(batch_name=batch.name)
assert tasks_count == get_tasks_count


def test_finalize_batch():
batch = create_a_batch()
batch = client.finalize_batch(batch.name)
Expand Down

0 comments on commit 54c3b3f

Please sign in to comment.