Skip to content

Commit 12d1721

Browse files
v2.15.1 Adding limit_response to get_tasks method (#80)
* v2.15.1 Adding limit_response * v2.15.1 Adding limit_response * Adding comments and information on Readme * Adding comments and information on Readme * Fixing lint line too long * nit comment changes --------- Co-authored-by: Fatih Kurtoglu <fatih.kurtoglu@scale.com>
1 parent b5815c3 commit 12d1721

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@ Accessing ``task.params`` child objects directly at task level is **deprecated**
171171
task.params["geometries"] # task.geometries is DEPRECATED
172172
task.params["attachment"] # task.attachment is DEPRECATED
173173
174+
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``.
175+
174176
Retrieve List of Tasks
175177
^^^^^^^^^^^^^^^^^^^^^^
176178

177179
Retrieve a list of `Task` objects, with filters for: ``project_name``, ``batch_name``, ``type``, ``status``,
178180
``review_status``, ``unique_id``, ``completed_after``, ``completed_before``, ``updated_after``, ``updated_before``,
179-
``created_after``, ``created_before`` and ``tags``.
181+
``created_after``, ``created_before``, ``tags`` and ``limited_response``.
180182

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

scaleapi/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ def tasks(self, **kwargs) -> Tasklist:
273273
If true, returns a pre-signed s3 url for the
274274
attachment used to create the task.
275275
276+
limited_response (bool):
277+
If true, returns task response of the following fields:
278+
task_id, status, metadata, project, otherVersion.
279+
276280
next_token (str):
277281
Can be use to fetch the next page of tasks
278282
"""
@@ -293,6 +297,7 @@ def tasks(self, **kwargs) -> Tasklist:
293297
"updated_after",
294298
"unique_id",
295299
"include_attachment_url",
300+
"limited_response",
296301
}
297302

298303
for key in kwargs:
@@ -329,6 +334,7 @@ def get_tasks(
329334
created_before: str = None,
330335
tags: Union[List[str], str] = None,
331336
include_attachment_url: bool = True,
337+
limited_response: bool = None,
332338
) -> Generator[Task, None, None]:
333339
"""Retrieve all tasks as a `generator` method, with the
334340
given parameters. This methods handles pagination of
@@ -392,6 +398,10 @@ def get_tasks(
392398
If true, returns a pre-signed s3 url for the
393399
attachment used to create the task.
394400
401+
limited_response (bool):
402+
If true, returns task response of the following fields:
403+
task_id, status, metadata, project, otherVersion.
404+
395405
396406
Yields:
397407
Generator[Task]:
@@ -416,6 +426,7 @@ def get_tasks(
416426
created_before,
417427
tags,
418428
include_attachment_url,
429+
limited_response,
419430
)
420431

421432
while has_more:
@@ -424,7 +435,6 @@ def get_tasks(
424435
tasks = self.tasks(**tasks_args)
425436
for task in tasks.docs:
426437
yield task
427-
428438
next_token = tasks.next_token
429439
has_more = tasks.has_more
430440

@@ -545,6 +555,7 @@ def _process_tasks_endpoint_args(
545555
created_before: str = None,
546556
tags: Union[List[str], str] = None,
547557
include_attachment_url: bool = True,
558+
limited_response: bool = None,
548559
):
549560
"""Generates args for /tasks endpoint."""
550561
tasks_args = {
@@ -563,6 +574,8 @@ def _process_tasks_endpoint_args(
563574

564575
if status:
565576
tasks_args["status"] = status.value
577+
if limited_response:
578+
tasks_args["limited_response"] = limited_response
566579
if task_type:
567580
tasks_args["type"] = task_type.value
568581
if review_status:

scaleapi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "2.15.0"
1+
__version__ = "2.15.1"
22
__package_name__ = "scaleapi"

0 commit comments

Comments
 (0)