scaleapi 2.14.3__tar.gz → 2.15.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scaleapi
3
- Version: 2.14.3
3
+ Version: 2.15.0
4
4
  Summary: The official Python client library for Scale AI, the Data Platform for AI
5
5
  Home-page: https://github.com/scaleapi/scaleapi-python-client
6
6
  Author: Scale AI
@@ -269,6 +269,10 @@ class ScaleClient:
269
269
  limit (int):
270
270
  Determines the page size (1-100)
271
271
 
272
+ include_attachment_url (bool):
273
+ If true, returns a pre-signed s3 url for the
274
+ attachment used to create the task.
275
+
272
276
  next_token (str):
273
277
  Can be use to fetch the next page of tasks
274
278
  """
@@ -288,6 +292,7 @@ class ScaleClient:
288
292
  "updated_before",
289
293
  "updated_after",
290
294
  "unique_id",
295
+ "include_attachment_url",
291
296
  }
292
297
 
293
298
  for key in kwargs:
@@ -323,6 +328,7 @@ class ScaleClient:
323
328
  created_after: str = None,
324
329
  created_before: str = None,
325
330
  tags: Union[List[str], str] = None,
331
+ include_attachment_url: bool = True,
326
332
  ) -> Generator[Task, None, None]:
327
333
  """Retrieve all tasks as a `generator` method, with the
328
334
  given parameters. This methods handles pagination of
@@ -382,6 +388,11 @@ class ScaleClient:
382
388
  The tags of a task; multiple tags can be
383
389
  specified as a list.
384
390
 
391
+ include_attachment_url (bool):
392
+ If true, returns a pre-signed s3 url for the
393
+ attachment used to create the task.
394
+
395
+
385
396
  Yields:
386
397
  Generator[Task]:
387
398
  Yields Task objects, can be iterated.
@@ -404,6 +415,7 @@ class ScaleClient:
404
415
  created_after,
405
416
  created_before,
406
417
  tags,
418
+ include_attachment_url,
407
419
  )
408
420
 
409
421
  while has_more:
@@ -431,6 +443,7 @@ class ScaleClient:
431
443
  created_after: str = None,
432
444
  created_before: str = None,
433
445
  tags: Union[List[str], str] = None,
446
+ include_attachment_url: bool = True,
434
447
  ) -> int:
435
448
  """Returns number of tasks with given filters.
436
449
 
@@ -485,6 +498,10 @@ class ScaleClient:
485
498
  The tags of a task; multiple tags can be
486
499
  specified as a list.
487
500
 
501
+ include_attachment_url (bool):
502
+ If true, returns a pre-signed s3 url for the
503
+ attachment used to create the task.
504
+
488
505
  Returns:
489
506
  int:
490
507
  Returns number of tasks
@@ -504,6 +521,7 @@ class ScaleClient:
504
521
  created_after,
505
522
  created_before,
506
523
  tags,
524
+ include_attachment_url,
507
525
  )
508
526
 
509
527
  tasks_args["limit"] = 1
@@ -526,6 +544,7 @@ class ScaleClient:
526
544
  created_after: str = None,
527
545
  created_before: str = None,
528
546
  tags: Union[List[str], str] = None,
547
+ include_attachment_url: bool = True,
529
548
  ):
530
549
  """Generates args for /tasks endpoint."""
531
550
  tasks_args = {
@@ -539,6 +558,7 @@ class ScaleClient:
539
558
  "updated_before": updated_before,
540
559
  "updated_after": updated_after,
541
560
  "unique_id": unique_id,
561
+ "include_attachment_url": include_attachment_url,
542
562
  }
543
563
 
544
564
  if status:
@@ -1,2 +1,2 @@
1
- __version__ = "2.14.3"
1
+ __version__ = "2.15.0"
2
2
  __package_name__ = "scaleapi"
@@ -151,16 +151,22 @@ class Api:
151
151
  # error=None,
152
152
  # status=409,
153
153
  # redirect_location=None)
154
- if retry_history != ():
155
- # See if the first retry was a 500 or 503 error
156
- if retry_history[0][3] >= 500:
157
- uuid = body["unique_id"]
158
- newUrl = f"{self.base_api_url}/tasks?unique_id={uuid}"
159
- # grab task from api
160
- newRes = self._http_request(
161
- "GET", newUrl, headers=headers, auth=auth
162
- )
163
- json = newRes.json()["docs"][0]
154
+
155
+ if retry_history and retry_history[0][3] >= 500:
156
+ uuid = body["unique_id"]
157
+ new_url = f"{self.base_api_url}/tasks?unique_id={uuid}"
158
+
159
+ # Perform a GET request to retrieve task data
160
+ new_res = self._http_request("GET", new_url, headers=headers, auth=auth)
161
+
162
+ if new_res.status_code == 200:
163
+ new_res_data = new_res.json()
164
+ if new_res_data["docs"]:
165
+ json = new_res_data["docs"][0]
166
+ else:
167
+ self._raise_on_respose(new_res)
168
+ else:
169
+ self._raise_on_respose(new_res)
164
170
  else:
165
171
  self._raise_on_respose(res)
166
172
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scaleapi
3
- Version: 2.14.3
3
+ Version: 2.15.0
4
4
  Summary: The official Python client library for Scale AI, the Data Platform for AI
5
5
  Home-page: https://github.com/scaleapi/scaleapi-python-client
6
6
  Author: Scale AI
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes