fleet-python 0.2.51__py3-none-any.whl → 0.2.53__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/__init__.py +7 -2
- fleet/_async/client.py +38 -9
- fleet/client.py +27 -13
- {fleet_python-0.2.51.dist-info → fleet_python-0.2.53.dist-info}/METADATA +1 -1
- {fleet_python-0.2.51.dist-info → fleet_python-0.2.53.dist-info}/RECORD +8 -8
- {fleet_python-0.2.51.dist-info → fleet_python-0.2.53.dist-info}/WHEEL +0 -0
- {fleet_python-0.2.51.dist-info → fleet_python-0.2.53.dist-info}/licenses/LICENSE +0 -0
- {fleet_python-0.2.51.dist-info → fleet_python-0.2.53.dist-info}/top_level.txt +0 -0
fleet/_async/__init__.py
CHANGED
|
@@ -193,13 +193,18 @@ async def export_tasks(
|
|
|
193
193
|
return await _async_global_client.get_client().export_tasks(env_key, filename)
|
|
194
194
|
|
|
195
195
|
|
|
196
|
-
async def import_tasks(filename: str):
|
|
196
|
+
async def import_tasks(filename: str, project_key: Optional[str] = None):
|
|
197
197
|
"""Import tasks from a JSON file.
|
|
198
198
|
|
|
199
|
+
Args:
|
|
200
|
+
filename: Path to the JSON file of Task objects to import
|
|
201
|
+
project_key: Optional project key to associate with the tasks
|
|
202
|
+
|
|
199
203
|
Example:
|
|
200
204
|
await fleet.import_tasks("tasks.json")
|
|
205
|
+
await fleet.import_tasks("tasks.json", project_key="my-project")
|
|
201
206
|
"""
|
|
202
|
-
return await _async_global_client.get_client().import_tasks(filename)
|
|
207
|
+
return await _async_global_client.get_client().import_tasks(filename, project_key)
|
|
203
208
|
|
|
204
209
|
|
|
205
210
|
async def account() -> AccountResponse:
|
fleet/_async/client.py
CHANGED
|
@@ -560,11 +560,34 @@ class AsyncFleet:
|
|
|
560
560
|
logger.info("No tasks found to export")
|
|
561
561
|
return None
|
|
562
562
|
|
|
563
|
-
async def
|
|
563
|
+
async def import_single_task(self, task: Task, project_key: Optional[str] = None):
|
|
564
|
+
"""Import a single task.
|
|
565
|
+
|
|
566
|
+
Args:
|
|
567
|
+
task: Task object to import
|
|
568
|
+
project_key: Optional project key to associate with the task
|
|
569
|
+
|
|
570
|
+
Returns:
|
|
571
|
+
Response from the API, or None if the import failed
|
|
572
|
+
"""
|
|
573
|
+
try:
|
|
574
|
+
params = {}
|
|
575
|
+
if project_key:
|
|
576
|
+
params["project_key"] = project_key
|
|
577
|
+
response = await self.client.request(
|
|
578
|
+
"POST", "/v1/tasks", json=task.model_dump(), params=params
|
|
579
|
+
)
|
|
580
|
+
return response
|
|
581
|
+
except Exception as e:
|
|
582
|
+
logger.error(f"Failed to import task {task.key}: {e}")
|
|
583
|
+
return None
|
|
584
|
+
|
|
585
|
+
async def import_tasks(self, filename: str, project_key: Optional[str] = None):
|
|
564
586
|
"""Import tasks from a JSON file.
|
|
565
587
|
|
|
566
588
|
Args:
|
|
567
589
|
filename: Path to the JSON file of Task objects to import
|
|
590
|
+
project_key: Optional project key to associate with the tasks
|
|
568
591
|
|
|
569
592
|
Returns:
|
|
570
593
|
List[Task] containing imported Task objects
|
|
@@ -578,14 +601,20 @@ class AsyncFleet:
|
|
|
578
601
|
task = Task(**task_data)
|
|
579
602
|
tasks.append(task)
|
|
580
603
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
604
|
+
# Use semaphore to limit concurrency to 20
|
|
605
|
+
semaphore = asyncio.Semaphore(20)
|
|
606
|
+
|
|
607
|
+
async def import_with_semaphore(task):
|
|
608
|
+
async with semaphore:
|
|
609
|
+
return await self.import_single_task(task, project_key)
|
|
610
|
+
|
|
611
|
+
# Use asyncio.gather to parallelize the imports
|
|
612
|
+
responses = await asyncio.gather(
|
|
613
|
+
*[import_with_semaphore(task) for task in tasks]
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
# Filter out None values (failed imports)
|
|
617
|
+
return [r for r in responses if r is not None]
|
|
589
618
|
|
|
590
619
|
async def account(self) -> AccountResponse:
|
|
591
620
|
"""Get account information including instance limits and usage.
|
fleet/client.py
CHANGED
|
@@ -566,11 +566,32 @@ class Fleet:
|
|
|
566
566
|
logger.info("No tasks found to export")
|
|
567
567
|
return None
|
|
568
568
|
|
|
569
|
-
def
|
|
569
|
+
def import_single_task(self, task: Task, project_key: Optional[str] = None):
|
|
570
|
+
"""Import a single task.
|
|
571
|
+
|
|
572
|
+
Args:
|
|
573
|
+
task: Task object to import
|
|
574
|
+
project_key: Optional project key to associate with the task
|
|
575
|
+
|
|
576
|
+
Returns:
|
|
577
|
+
Response from the API, or None if the import failed
|
|
578
|
+
"""
|
|
579
|
+
try:
|
|
580
|
+
params = {}
|
|
581
|
+
if project_key:
|
|
582
|
+
params["project_key"] = project_key
|
|
583
|
+
response = self.client.request("POST", "/v1/tasks", json=task.model_dump(), params=params)
|
|
584
|
+
return response
|
|
585
|
+
except Exception as e:
|
|
586
|
+
logger.error(f"Failed to import task {task.key}: {e}")
|
|
587
|
+
return None
|
|
588
|
+
|
|
589
|
+
def import_tasks(self, filename: str, project_key: Optional[str] = None):
|
|
570
590
|
"""Import tasks from a JSON file.
|
|
571
591
|
|
|
572
592
|
Args:
|
|
573
593
|
filename: Path to the JSON file of Task objects to import
|
|
594
|
+
project_key: Optional project key to associate with the tasks
|
|
574
595
|
|
|
575
596
|
Returns:
|
|
576
597
|
List[Task] containing imported Task objects
|
|
@@ -584,19 +605,12 @@ class Fleet:
|
|
|
584
605
|
task = Task(**task_data)
|
|
585
606
|
tasks.append(task)
|
|
586
607
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
|
608
|
+
# Use ThreadPoolExecutor to parallelize the imports with max 20 workers
|
|
609
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
|
|
610
|
+
responses = list(executor.map(lambda t: self.import_single_task(t, project_key), tasks))
|
|
598
611
|
|
|
599
|
-
|
|
612
|
+
# Filter out None values (failed imports)
|
|
613
|
+
return [r for r in responses if r is not None]
|
|
600
614
|
|
|
601
615
|
def account(self) -> AccountResponse:
|
|
602
616
|
"""Get account information including instance limits and usage.
|
|
@@ -21,16 +21,16 @@ 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=
|
|
24
|
+
fleet/client.py,sha256=zu05ApXhJrKX7UiMF8TOY1yNWiHRGlYRAMBmhaCsOSo,27806
|
|
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
|
|
28
28
|
fleet/models.py,sha256=d9eish0KO3t4VCNu8h8Q_6K1Xj-crYo5Fejtle0Ur28,13056
|
|
29
29
|
fleet/tasks.py,sha256=uR94wq7SG4ymJYLq24F2iYn0el58C2Czb2oK-8rIs8s,12344
|
|
30
30
|
fleet/types.py,sha256=L4Y82xICf1tzyCLqhLYUgEoaIIS5h9T05TyFNHSWs3s,652
|
|
31
|
-
fleet/_async/__init__.py,sha256=
|
|
31
|
+
fleet/_async/__init__.py,sha256=x2esWn8yf2AMfzHRmSHtFkXcxbrSSXCZdJyrFnJldEo,7033
|
|
32
32
|
fleet/_async/base.py,sha256=oisVTQsx0M_yTmyQJc3oij63uKZ97MHz-xYFsWXxQE8,9202
|
|
33
|
-
fleet/_async/client.py,sha256=
|
|
33
|
+
fleet/_async/client.py,sha256=TZJsEg43IiYPnSA3S48GRpwAYg1fehcHVbYHA3yUHXY,28266
|
|
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.
|
|
70
|
+
fleet_python-0.2.53.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.
|
|
74
|
-
fleet_python-0.2.
|
|
75
|
-
fleet_python-0.2.
|
|
76
|
-
fleet_python-0.2.
|
|
73
|
+
fleet_python-0.2.53.dist-info/METADATA,sha256=SaC_PN_pQ1GG1g3RdaitFUy0PJWpD-1-hCIOT4sqcn8,3304
|
|
74
|
+
fleet_python-0.2.53.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
75
|
+
fleet_python-0.2.53.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
|
|
76
|
+
fleet_python-0.2.53.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|