Skip to content

Dev 2.0.5 #36

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 4 commits into from
May 4, 2021
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
31 changes: 29 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ __ https://docs.scale.com/reference
.. code-block:: python

from scaleapi.tasks import TaskType
from scaleapi.exceptions import ScaleDuplicateTask

payload = dict(
project = "test_project",
Expand Down Expand Up @@ -98,6 +99,28 @@ __ https://docs.scale.com/reference#retrieve-tasks
print(task.status) # Task status ("pending", "completed", "error", "canceled")
print(task.response) # If task is complete


Task Attributes
^^^^^^^^^^^^^^^

The older ``param_dict`` attribute is now replaced with a method ``as_dict()`` to return a task's all attributes as a dictionary (JSON).

First-level attributes of Task are accessible with ``.`` annotation as the following:

.. code-block :: python

task.status # same as task.as_dict()["status"]
task.params["geometries"] # same as task.as_dict()["params"]["geometries"]
task.response["annotations"] # same as task.as_dict()["response"]["annotations"]


Accessing ``task.params`` child objects directly at task level is **deprecated**. Instead of ``task.attribute``, you should use ``task.params["attribute"]`` for accessing objects under `params`.

.. code-block :: python

task.params["geometries"] # task.geometries is DEPRECATED
task.params["attachment"] # task.attachment is DEPRECATED

List Tasks
^^^^^^^^^^

Expand Down Expand Up @@ -209,7 +232,9 @@ __ https://docs.scale.com/reference#batch-retrieval

.. code-block:: python

client.get_batch(batch_name = "batch_name_01_07_2021")
batch = client.get_batch(batch_name = "batch_name_01_07_2021")

The older ``param_dict`` attribute is now replaced with a method ``batch.as_dict()`` to return a batch's all attributes as a dictionary (JSON).

List Batches
^^^^^^^^^^^^
Expand Down Expand Up @@ -277,7 +302,9 @@ __ https://docs.scale.com/reference#project-retrieval

.. code-block:: python

client.get_project(project_name = "test_project")
project = client.get_project(project_name = "test_project")

The older ``param_dict`` attribute is now replaced with a method ``project.as_dict()`` to return a project's all attributes as a dictionary (JSON).

List Projects
^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ batch.tasks_canceled # batch.canceled

### Enabled Auto-Retry

SDK now supports auto-retry in case of a `TimeOut(504)` or `TooManyRequests(429)` error occurs.
SDK now supports auto-retry in case of a `408`, `429` or `5xx` error occurs.

### New Exceptions

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.0.4"
__version__ = "2.0.5"
__package_name__ = "scaleapi"
14 changes: 1 addition & 13 deletions scaleapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@
# Parameters for HTTP retry
HTTP_TOTAL_RETRIES = 3 # Number of total retries
HTTP_RETRY_BACKOFF_FACTOR = 2 # Wait 1, 2, 4 seconds between retries
HTTP_STATUS_FORCE_LIST = [
429,
500,
502,
503,
504,
520,
521,
522,
523,
524,
525,
] # Status codes to force retry
HTTP_STATUS_FORCE_LIST = [408, 429] + list(range(500, 531))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the range ;)

HTTP_RETRY_ALLOWED_METHODS = frozenset({"GET", "POST"})


Expand Down