From d8b03e704cc92df7d38ca439040d5a1ebddf0f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez?= Date: Fri, 3 Nov 2023 17:23:30 -0600 Subject: [PATCH 1/6] v2.15.1 Adding limit_response --- scaleapi/__init__.py | 15 +++++++++++++-- scaleapi/_version.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index b687268..5115a51 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -272,6 +272,9 @@ def tasks(self, **kwargs) -> Tasklist: include_attachment_url (bool): If true, returns a pre-signed s3 url for the attachment used to create the task. + + limited_response (bool): + If true, returns limited task response. next_token (str): Can be use to fetch the next page of tasks @@ -293,6 +296,7 @@ def tasks(self, **kwargs) -> Tasklist: "updated_after", "unique_id", "include_attachment_url", + "limited_response" } for key in kwargs: @@ -329,6 +333,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 @@ -391,10 +396,13 @@ def get_tasks( include_attachment_url (bool): If true, returns a pre-signed s3 url for the attachment used to create the task. + + limited_response (bool): + If true, returns limited task response. Yields: - Generator[Task]: + Generator[Task]: Yields Task objects, can be iterated. """ @@ -416,6 +424,7 @@ def get_tasks( created_before, tags, include_attachment_url, + limited_response, ) while has_more: @@ -424,7 +433,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 @@ -545,6 +553,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 = { @@ -563,6 +572,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: diff --git a/scaleapi/_version.py b/scaleapi/_version.py index 74c7b31..704e352 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.15.0" +__version__ = "2.15.1" __package_name__ = "scaleapi" From ea4f09d5a791386b6ebeb2d8464493c4f48e767b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez?= Date: Fri, 3 Nov 2023 17:52:30 -0600 Subject: [PATCH 2/6] v2.15.1 Adding limit_response --- scaleapi/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 5115a51..9fabef8 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -272,7 +272,7 @@ def tasks(self, **kwargs) -> Tasklist: include_attachment_url (bool): If true, returns a pre-signed s3 url for the attachment used to create the task. - + limited_response (bool): If true, returns limited task response. @@ -296,7 +296,7 @@ def tasks(self, **kwargs) -> Tasklist: "updated_after", "unique_id", "include_attachment_url", - "limited_response" + "limited_response", } for key in kwargs: @@ -396,13 +396,13 @@ def get_tasks( include_attachment_url (bool): If true, returns a pre-signed s3 url for the attachment used to create the task. - + limited_response (bool): If true, returns limited task response. Yields: - Generator[Task]: + Generator[Task]: Yields Task objects, can be iterated. """ @@ -553,7 +553,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 + limited_response: bool = None, ): """Generates args for /tasks endpoint.""" tasks_args = { From 1e86a479b7859713c5bb02d1d194104b36006163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez?= Date: Mon, 6 Nov 2023 09:39:37 -0600 Subject: [PATCH 3/6] Adding comments and information on Readme --- README.rst | 4 +++- scaleapi/__init__.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index e3d554e..4d90ad6 100644 --- a/README.rst +++ b/README.rst @@ -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 receive the following attributes: ``_id``, ``status``, ``metadata``, ``project``, ``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. diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 9fabef8..205ed5f 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -274,7 +274,8 @@ def tasks(self, **kwargs) -> Tasklist: attachment used to create the task. limited_response (bool): - If true, returns limited task response. + If true, returns limited task response of the following fields: + _id, status, metadata, project, otherVersion. next_token (str): Can be use to fetch the next page of tasks @@ -398,7 +399,8 @@ def get_tasks( attachment used to create the task. limited_response (bool): - If true, returns limited task response. + If true, returns limited task response of the following fields: + _id, status, metadata, project, otherVersion. Yields: From d3118d1b074ee5ea006a1b295ce0706707172264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez?= Date: Mon, 6 Nov 2023 09:44:28 -0600 Subject: [PATCH 4/6] Adding comments and information on Readme --- scaleapi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 205ed5f..31eb3bc 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -274,7 +274,7 @@ def tasks(self, **kwargs) -> Tasklist: attachment used to create the task. limited_response (bool): - If true, returns limited task response of the following fields: + If true, returns limited task response of the following fields: _id, status, metadata, project, otherVersion. next_token (str): @@ -399,7 +399,7 @@ def get_tasks( attachment used to create the task. limited_response (bool): - If true, returns limited task response of the following fields: + If true, returns limited task response of the following fields: _id, status, metadata, project, otherVersion. From 5c236c61eb6301794694bb5734b065f06e3c0f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20L=C3=B3pez?= Date: Mon, 6 Nov 2023 09:53:03 -0600 Subject: [PATCH 5/6] Fixing lint line too long --- scaleapi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 31eb3bc..1f6ddab 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -274,7 +274,7 @@ def tasks(self, **kwargs) -> Tasklist: attachment used to create the task. limited_response (bool): - If true, returns limited task response of the following fields: + If true, returns task response of the following fields: _id, status, metadata, project, otherVersion. next_token (str): @@ -399,7 +399,7 @@ def get_tasks( attachment used to create the task. limited_response (bool): - If true, returns limited task response of the following fields: + If true, returns task response of the following fields: _id, status, metadata, project, otherVersion. From ae5f76504cfbe233a67ee69827e37952932374e0 Mon Sep 17 00:00:00 2001 From: Fatih Kurtoglu Date: Mon, 6 Nov 2023 12:27:19 -0800 Subject: [PATCH 6/6] nit comment changes --- README.rst | 2 +- scaleapi/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 4d90ad6..6003390 100644 --- a/README.rst +++ b/README.rst @@ -171,7 +171,7 @@ 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 receive the following attributes: ``_id``, ``status``, ``metadata``, ``project``, ``otherVersion``. +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 ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/scaleapi/__init__.py b/scaleapi/__init__.py index 1f6ddab..ae96c64 100644 --- a/scaleapi/__init__.py +++ b/scaleapi/__init__.py @@ -275,7 +275,7 @@ def tasks(self, **kwargs) -> Tasklist: limited_response (bool): If true, returns task response of the following fields: - _id, status, metadata, project, otherVersion. + task_id, status, metadata, project, otherVersion. next_token (str): Can be use to fetch the next page of tasks @@ -400,7 +400,7 @@ def get_tasks( limited_response (bool): If true, returns task response of the following fields: - _id, status, metadata, project, otherVersion. + task_id, status, metadata, project, otherVersion. Yields: