fleet-python 0.2.51__py3-none-any.whl → 0.2.52__py3-none-any.whl

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.

Potentially problematic release.


This version of fleet-python might be problematic. Click here for more details.

fleet/_async/client.py CHANGED
@@ -560,6 +560,24 @@ class AsyncFleet:
560
560
  logger.info("No tasks found to export")
561
561
  return None
562
562
 
563
+ async def import_single_task(self, task: Task):
564
+ """Import a single task.
565
+
566
+ Args:
567
+ task: Task object to import
568
+
569
+ Returns:
570
+ Response from the API, or None if the import failed
571
+ """
572
+ try:
573
+ response = await self.client.request(
574
+ "POST", "/v1/tasks", json=task.model_dump()
575
+ )
576
+ return response
577
+ except Exception as e:
578
+ logger.error(f"Failed to import task {task.key}: {e}")
579
+ return None
580
+
563
581
  async def import_tasks(self, filename: str):
564
582
  """Import tasks from a JSON file.
565
583
 
@@ -578,14 +596,20 @@ class AsyncFleet:
578
596
  task = Task(**task_data)
579
597
  tasks.append(task)
580
598
 
581
- for task in tasks:
582
- try:
583
- response = await self.client.request(
584
- "POST", "/v1/tasks", json=task.model_dump()
585
- )
586
- except Exception as e:
587
- logger.error(f"Failed to import task {task.key}: {e}")
588
- continue
599
+ # Use semaphore to limit concurrency to 20
600
+ semaphore = asyncio.Semaphore(20)
601
+
602
+ async def import_with_semaphore(task):
603
+ async with semaphore:
604
+ return await self.import_single_task(task)
605
+
606
+ # Use asyncio.gather to parallelize the imports
607
+ responses = await asyncio.gather(
608
+ *[import_with_semaphore(task) for task in tasks]
609
+ )
610
+
611
+ # Filter out None values (failed imports)
612
+ return [r for r in responses if r is not None]
589
613
 
590
614
  async def account(self) -> AccountResponse:
591
615
  """Get account information including instance limits and usage.
fleet/client.py CHANGED
@@ -566,6 +566,22 @@ class Fleet:
566
566
  logger.info("No tasks found to export")
567
567
  return None
568
568
 
569
+ def import_single_task(self, task: Task):
570
+ """Import a single task.
571
+
572
+ Args:
573
+ task: Task object to import
574
+
575
+ Returns:
576
+ Response from the API, or None if the import failed
577
+ """
578
+ try:
579
+ response = self.client.request("POST", "/v1/tasks", json=task.model_dump())
580
+ return response
581
+ except Exception as e:
582
+ logger.error(f"Failed to import task {task.key}: {e}")
583
+ return None
584
+
569
585
  def import_tasks(self, filename: str):
570
586
  """Import tasks from a JSON file.
571
587
 
@@ -584,19 +600,12 @@ class Fleet:
584
600
  task = Task(**task_data)
585
601
  tasks.append(task)
586
602
 
587
- responses = []
588
-
589
- for task in tasks:
590
- try:
591
- response = self.client.request(
592
- "POST", "/v1/tasks", json=task.model_dump()
593
- )
594
- responses.append(response)
595
- except Exception as e:
596
- logger.error(f"Failed to import task {task.key}: {e}")
597
- continue
603
+ # Use ThreadPoolExecutor to parallelize the imports with max 20 workers
604
+ with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
605
+ responses = list(executor.map(self.import_single_task, tasks))
598
606
 
599
- return responses
607
+ # Filter out None values (failed imports)
608
+ return [r for r in responses if r is not None]
600
609
 
601
610
  def account(self) -> AccountResponse:
602
611
  """Get account information including instance limits and usage.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.51
3
+ Version: 0.2.52
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -21,7 +21,7 @@ examples/quickstart.py,sha256=1VT39IRRhemsJgxi0O0gprdpcw7HB4pYO97GAYagIcg,3788
21
21
  examples/test_cdp_logging.py,sha256=AkCwQCgOTQEI8w3v0knWK_4eXMph7L9x07wj9yIYM10,2836
22
22
  fleet/__init__.py,sha256=Mkdeh45N47lnSv73Eehj92cGU-AImUitvDWJLFhEp0Y,3844
23
23
  fleet/base.py,sha256=bc-340sTpq_DJs7yQ9d2pDWnmJFmA1SwDB9Lagvqtb4,9182
24
- fleet/client.py,sha256=xuo9aqX9bTMzVtk_2I6hS7-9p9WPENIWpQAj76J7dXE,27021
24
+ fleet/client.py,sha256=eLo_yie4xUAV2SgeyNIIY-CUhdhp0K5zHr-XEQUw-S8,27444
25
25
  fleet/config.py,sha256=uY02ZKxVoXqVDta-0IMWaYJeE1CTXF_fA9NI6QUutmU,319
26
26
  fleet/exceptions.py,sha256=fUmPwWhnT8SR97lYsRq0kLHQHKtSh2eJS0VQ2caSzEI,5055
27
27
  fleet/global_client.py,sha256=frrDAFNM2ywN0JHLtlm9qbE1dQpnQJsavJpb7xSR_bU,1072
@@ -30,7 +30,7 @@ fleet/tasks.py,sha256=uR94wq7SG4ymJYLq24F2iYn0el58C2Czb2oK-8rIs8s,12344
30
30
  fleet/types.py,sha256=L4Y82xICf1tzyCLqhLYUgEoaIIS5h9T05TyFNHSWs3s,652
31
31
  fleet/_async/__init__.py,sha256=7C_JaEHoqZ4cddsCmlJ4z-UaU6Kr2CBZSgwx5B6fqnc,6765
32
32
  fleet/_async/base.py,sha256=oisVTQsx0M_yTmyQJc3oij63uKZ97MHz-xYFsWXxQE8,9202
33
- fleet/_async/client.py,sha256=aGbfT9PYsGcZFLlEV26-1GaPhU9WTQ8nCBNnqAmPiG4,27196
33
+ fleet/_async/client.py,sha256=UIF0t-GgLdJeZLJqzsE9gVuzEesj7O8wWPVgjF45tso,27917
34
34
  fleet/_async/exceptions.py,sha256=fUmPwWhnT8SR97lYsRq0kLHQHKtSh2eJS0VQ2caSzEI,5055
35
35
  fleet/_async/global_client.py,sha256=4WskpLHbsDEgWW7hXMD09W-brkp4euy8w2ZJ88594rQ,1103
36
36
  fleet/_async/models.py,sha256=GX-sRciZDenW2O7Qx9w_ftOkJyE4ph1-92WMq6lynHE,12856
@@ -67,10 +67,10 @@ fleet/verifiers/decorator.py,sha256=nAP3O8szXu7md_kpwpz91hGSUNEVLYjwZQZTkQlV1DM,
67
67
  fleet/verifiers/parse.py,sha256=qz9AfJrTbjlg-LU-lE8Ciqi7Yt2a8-cs17FdpjTLhMk,8550
68
68
  fleet/verifiers/sql_differ.py,sha256=TqTLWyK3uOyLbitT6HYzYEzuSFC39wcyhgk3rcm__k8,6525
69
69
  fleet/verifiers/verifier.py,sha256=_lcxXVm8e0xRrK2gNJy9up7pW1zOkPRY5n5lQ85S8jg,14197
70
- fleet_python-0.2.51.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
70
+ fleet_python-0.2.52.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
71
71
  scripts/fix_sync_imports.py,sha256=X9fWLTpiPGkSHsjyQUDepOJkxOqw1DPj7nd8wFlFqLQ,8368
72
72
  scripts/unasync.py,sha256=vWVQxRWX8SRZO5cmzEhpvnG_REhCWXpidIGIpWmEcvI,696
73
- fleet_python-0.2.51.dist-info/METADATA,sha256=MODNsxRtnsaN4On2g4xQU23B2hwHfIsPPhD213guVrQ,3304
74
- fleet_python-0.2.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- fleet_python-0.2.51.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
- fleet_python-0.2.51.dist-info/RECORD,,
73
+ fleet_python-0.2.52.dist-info/METADATA,sha256=5XJkEis8IQs2W8ITyyU7a1LmZ3XqzrweVTFHCltP7zw,3304
74
+ fleet_python-0.2.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ fleet_python-0.2.52.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
+ fleet_python-0.2.52.dist-info/RECORD,,