Skip to content

Commit

Permalink
Dev 2.0.5 (#36)
Browse files Browse the repository at this point in the history
* extend retry to all 5xx error codes

* readme fixes

* readme updates

* version bumped
  • Loading branch information
fatihkurtoglu authored May 4, 2021
1 parent 41a883c commit 8094e65
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
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))
HTTP_RETRY_ALLOWED_METHODS = frozenset({"GET", "POST"})


Expand Down

0 comments on commit 8094e65

Please sign in to comment.