Skip to content

Commit 8094e65

Browse files
Dev 2.0.5 (#36)
* extend retry to all 5xx error codes * readme fixes * readme updates * version bumped
1 parent 41a883c commit 8094e65

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

README.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ __ https://docs.scale.com/reference
6262
.. code-block:: python
6363
6464
from scaleapi.tasks import TaskType
65+
from scaleapi.exceptions import ScaleDuplicateTask
6566
6667
payload = dict(
6768
project = "test_project",
@@ -98,6 +99,28 @@ __ https://docs.scale.com/reference#retrieve-tasks
9899
print(task.status) # Task status ("pending", "completed", "error", "canceled")
99100
print(task.response) # If task is complete
100101
102+
103+
Task Attributes
104+
^^^^^^^^^^^^^^^
105+
106+
The older ``param_dict`` attribute is now replaced with a method ``as_dict()`` to return a task's all attributes as a dictionary (JSON).
107+
108+
First-level attributes of Task are accessible with ``.`` annotation as the following:
109+
110+
.. code-block :: python
111+
112+
task.status # same as task.as_dict()["status"]
113+
task.params["geometries"] # same as task.as_dict()["params"]["geometries"]
114+
task.response["annotations"] # same as task.as_dict()["response"]["annotations"]
115+
116+
117+
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`.
118+
119+
.. code-block :: python
120+
121+
task.params["geometries"] # task.geometries is DEPRECATED
122+
task.params["attachment"] # task.attachment is DEPRECATED
123+
101124
List Tasks
102125
^^^^^^^^^^
103126

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

210233
.. code-block:: python
211234
212-
client.get_batch(batch_name = "batch_name_01_07_2021")
235+
batch = client.get_batch(batch_name = "batch_name_01_07_2021")
236+
237+
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).
213238

214239
List Batches
215240
^^^^^^^^^^^^
@@ -277,7 +302,9 @@ __ https://docs.scale.com/reference#project-retrieval
277302

278303
.. code-block:: python
279304
280-
client.get_project(project_name = "test_project")
305+
project = client.get_project(project_name = "test_project")
306+
307+
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).
281308

282309
List Projects
283310
^^^^^^^^^^^^^

docs/migration_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ batch.tasks_canceled # batch.canceled
7676

7777
### Enabled Auto-Retry
7878

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

8181
### New Exceptions
8282

scaleapi/_version.py

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

scaleapi/api.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@
1212
# Parameters for HTTP retry
1313
HTTP_TOTAL_RETRIES = 3 # Number of total retries
1414
HTTP_RETRY_BACKOFF_FACTOR = 2 # Wait 1, 2, 4 seconds between retries
15-
HTTP_STATUS_FORCE_LIST = [
16-
429,
17-
500,
18-
502,
19-
503,
20-
504,
21-
520,
22-
521,
23-
522,
24-
523,
25-
524,
26-
525,
27-
] # Status codes to force retry
15+
HTTP_STATUS_FORCE_LIST = [408, 429] + list(range(500, 531))
2816
HTTP_RETRY_ALLOWED_METHODS = frozenset({"GET", "POST"})
2917

3018

0 commit comments

Comments
 (0)