Skip to content

Make project_name optional for get_tasks_count #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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