diff --git a/README.rst b/README.rst index 6003390..8d655e1 100644 --- a/README.rst +++ b/README.rst @@ -178,7 +178,7 @@ Retrieve List of Tasks Retrieve a list of `Task` objects, with filters for: ``project_name``, ``batch_name``, ``type``, ``status``, ``review_status``, ``unique_id``, ``completed_after``, ``completed_before``, ``updated_after``, ``updated_before``, -``created_after``, ``created_before``, ``tags`` and ``limited_response``. +``created_after``, ``created_before``, ``tags``, ``limited_response`` and ``limit``. ``get_tasks()`` is a **generator** method and yields ``Task`` objects. diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 26523a7..53d232f 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -335,6 +335,7 @@ def get_tasks( tags: Union[List[str], str] = None, include_attachment_url: bool = True, limited_response: bool = None, + limit: int = None, ) -> Generator[Task, None, None]: """Retrieve all tasks as a `generator` method, with the given parameters. This methods handles pagination of @@ -402,6 +403,9 @@ def get_tasks( If true, returns task response of the following fields: task_id, status, metadata, project, otherVersion. + limit (int): + Determines the task count per request (1-100) + For large sized tasks, use a smaller limit Yields: Generator[Task]: @@ -429,6 +433,9 @@ def get_tasks( limited_response, ) + if limit: + tasks_args["limit"] = limit + while has_more: tasks_args["next_token"] = next_token diff --git a/scaleapi/_version.py b/scaleapi/_version.py index a7a9859..96ef07b 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.15.5" +__version__ = "2.15.6" __package_name__ = "scaleapi" diff --git a/tests/test_client.py b/tests/test_client.py index fd6d65b..672fc4f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -406,6 +406,7 @@ def test_get_tasks(): for task in client.get_tasks( project_name=TEST_PROJECT_NAME, batch_name=batch.name, + limit=1, ): assert task.id in task_ids