diff --git a/README.rst b/README.rst index 30adebf..d4a2fa9 100644 --- a/README.rst +++ b/README.rst @@ -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", @@ -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 ^^^^^^^^^^ @@ -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 ^^^^^^^^^^^^ @@ -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 ^^^^^^^^^^^^^ diff --git a/docs/migration_guide.md b/docs/migration_guide.md index 300f19c..6c2fa15 100644 --- a/docs/migration_guide.md +++ b/docs/migration_guide.md @@ -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 diff --git a/scaleapi/_version.py b/scaleapi/_version.py index d8b1bd8..b114a63 100644 --- a/scaleapi/_version.py +++ b/scaleapi/_version.py @@ -1,2 +1,2 @@ -__version__ = "2.0.4" +__version__ = "2.0.5" __package_name__ = "scaleapi" diff --git a/scaleapi/api.py b/scaleapi/api.py index 26af3ee..5a76857 100644 --- a/scaleapi/api.py +++ b/scaleapi/api.py @@ -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"})