Skip to content

v2.15.1 Adding limit_response to get_tasks method #80

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 6 commits into from
Nov 6, 2023
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
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ Accessing ``task.params`` child objects directly at task level is **deprecated**
task.params["geometries"] # task.geometries is DEPRECATED
task.params["attachment"] # task.attachment is DEPRECATED

If you use the ``limited_response = True`` filter in ``get_tasks()``, you will only receive the following attributes: ``task_id``, ``status``, ``metadata``, ``project`` and ``otherVersion``.

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`` and ``tags``.
``created_after``, ``created_before``, ``tags`` and ``limited_response``.

``get_tasks()`` is a **generator** method and yields ``Task`` objects.

Expand Down
15 changes: 14 additions & 1 deletion scaleapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ def tasks(self, **kwargs) -> Tasklist:
If true, returns a pre-signed s3 url for the
attachment used to create the task.

limited_response (bool):
If true, returns task response of the following fields:
task_id, status, metadata, project, otherVersion.

next_token (str):
Can be use to fetch the next page of tasks
"""
Expand All @@ -293,6 +297,7 @@ def tasks(self, **kwargs) -> Tasklist:
"updated_after",
"unique_id",
"include_attachment_url",
"limited_response",
}

for key in kwargs:
Expand Down Expand Up @@ -329,6 +334,7 @@ def get_tasks(
created_before: str = None,
tags: Union[List[str], str] = None,
include_attachment_url: bool = True,
limited_response: bool = None,
) -> Generator[Task, None, None]:
"""Retrieve all tasks as a `generator` method, with the
given parameters. This methods handles pagination of
Expand Down Expand Up @@ -392,6 +398,10 @@ def get_tasks(
If true, returns a pre-signed s3 url for the
attachment used to create the task.

limited_response (bool):
If true, returns task response of the following fields:
task_id, status, metadata, project, otherVersion.


Yields:
Generator[Task]:
Expand All @@ -416,6 +426,7 @@ def get_tasks(
created_before,
tags,
include_attachment_url,
limited_response,
)

while has_more:
Expand All @@ -424,7 +435,6 @@ def get_tasks(
tasks = self.tasks(**tasks_args)
for task in tasks.docs:
yield task

next_token = tasks.next_token
has_more = tasks.has_more

Expand Down Expand Up @@ -545,6 +555,7 @@ def _process_tasks_endpoint_args(
created_before: str = None,
tags: Union[List[str], str] = None,
include_attachment_url: bool = True,
limited_response: bool = None,
):
"""Generates args for /tasks endpoint."""
tasks_args = {
Expand All @@ -563,6 +574,8 @@ def _process_tasks_endpoint_args(

if status:
tasks_args["status"] = status.value
if limited_response:
tasks_args["limited_response"] = limited_response
if task_type:
tasks_args["type"] = task_type.value
if review_status:
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.0"
__version__ = "2.15.1"
__package_name__ = "scaleapi"