fleet-python 0.2.67__tar.gz → 0.2.68__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.
Potentially problematic release.
This version of fleet-python might be problematic. Click here for more details.
- {fleet_python-0.2.67/fleet_python.egg-info → fleet_python-0.2.68}/PKG-INFO +1 -1
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/client.py +32 -1
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/env/client.py +29 -3
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/tasks.py +7 -2
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/client.py +32 -1
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/env/__init__.py +8 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/env/client.py +29 -3
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/models.py +2 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/tasks.py +7 -2
- {fleet_python-0.2.67 → fleet_python-0.2.68/fleet_python.egg-info}/PKG-INFO +1 -1
- {fleet_python-0.2.67 → fleet_python-0.2.68}/pyproject.toml +1 -1
- {fleet_python-0.2.67 → fleet_python-0.2.68}/LICENSE +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/README.md +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/diff_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/dsl_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/exampleResume.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_account.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_action_log.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_client.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_mcp_anthropic.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_mcp_openai.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_sync.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_task.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_tasks.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/example_verifier.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/export_tasks.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/gemini_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/import_tasks.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/json_tasks_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/nova_act_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/openai_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/openai_simple_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/query_builder_example.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/quickstart.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/examples/test_cdp_logging.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/env/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/exceptions.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/global_client.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/instance/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/instance/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/instance/client.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/models.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/resources/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/resources/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/resources/browser.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/resources/mcp.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/resources/sqlite.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/verifiers/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/verifiers/bundler.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/_async/verifiers/verifier.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/config.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/exceptions.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/global_client.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/instance/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/instance/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/instance/client.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/instance/models.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/resources/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/resources/base.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/resources/browser.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/resources/mcp.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/resources/sqlite.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/types.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/bundler.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/code.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/db.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/decorator.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/parse.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/sql_differ.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet/verifiers/verifier.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet_python.egg-info/SOURCES.txt +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet_python.egg-info/dependency_links.txt +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet_python.egg-info/requires.txt +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/fleet_python.egg-info/top_level.txt +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/scripts/fix_sync_imports.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/scripts/unasync.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/setup.cfg +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/tests/__init__.py +0 -0
- {fleet_python-0.2.67 → fleet_python-0.2.68}/tests/test_verifier_from_string.py +0 -0
|
@@ -212,6 +212,7 @@ class AsyncFleet:
|
|
|
212
212
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
213
213
|
image_type: Optional[str] = None,
|
|
214
214
|
ttl_seconds: Optional[int] = None,
|
|
215
|
+
run_id: Optional[str] = None,
|
|
215
216
|
) -> AsyncEnv:
|
|
216
217
|
if ":" in env_key:
|
|
217
218
|
env_key_part, env_version = env_key.split(":", 1)
|
|
@@ -247,6 +248,7 @@ class AsyncFleet:
|
|
|
247
248
|
image_type=image_type,
|
|
248
249
|
created_from="sdk",
|
|
249
250
|
ttl_seconds=ttl_seconds,
|
|
251
|
+
run_id=run_id,
|
|
250
252
|
)
|
|
251
253
|
|
|
252
254
|
# Only use region-specific base URL if no custom base URL is set
|
|
@@ -269,13 +271,15 @@ class AsyncFleet:
|
|
|
269
271
|
return await self.make(env_key=f"{task.env_id}:{task.version}")
|
|
270
272
|
|
|
271
273
|
async def instances(
|
|
272
|
-
self, status: Optional[str] = None, region: Optional[str] = None
|
|
274
|
+
self, status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
273
275
|
) -> List[AsyncEnv]:
|
|
274
276
|
params = {}
|
|
275
277
|
if status:
|
|
276
278
|
params["status"] = status
|
|
277
279
|
if region:
|
|
278
280
|
params["region"] = region
|
|
281
|
+
if run_id:
|
|
282
|
+
params["run_id"] = run_id
|
|
279
283
|
|
|
280
284
|
response = await self.client.request("GET", "/v1/env/instances", params=params)
|
|
281
285
|
return [
|
|
@@ -302,6 +306,28 @@ class AsyncFleet:
|
|
|
302
306
|
async def delete(self, instance_id: str) -> InstanceResponse:
|
|
303
307
|
return await _delete_instance(self.client, instance_id)
|
|
304
308
|
|
|
309
|
+
async def close(self, instance_id: str) -> InstanceResponse:
|
|
310
|
+
"""Close (delete) a specific instance by ID.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
instance_id: The instance ID to close
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
InstanceResponse containing the deleted instance details
|
|
317
|
+
"""
|
|
318
|
+
return await _delete_instance(self.client, instance_id)
|
|
319
|
+
|
|
320
|
+
async def close_all(self, run_id: str) -> List[InstanceResponse]:
|
|
321
|
+
"""Close (delete) all instances associated with a run_id.
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
run_id: The run ID whose instances should be closed
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
List[InstanceResponse] containing the deleted instances
|
|
328
|
+
"""
|
|
329
|
+
return await _delete_instances_by_run_id(self.client, run_id)
|
|
330
|
+
|
|
305
331
|
async def load_tasks_from_file(self, filename: str) -> List[Task]:
|
|
306
332
|
with open(filename, "r", encoding="utf-8") as f:
|
|
307
333
|
tasks_data = f.read()
|
|
@@ -811,6 +837,11 @@ async def _delete_instance(client: AsyncWrapper, instance_id: str) -> InstanceRe
|
|
|
811
837
|
return InstanceResponse(**response.json())
|
|
812
838
|
|
|
813
839
|
|
|
840
|
+
async def _delete_instances_by_run_id(client: AsyncWrapper, run_id: str) -> List[InstanceResponse]:
|
|
841
|
+
response = await client.request("DELETE", f"/v1/env/instances/run/{run_id}")
|
|
842
|
+
return [InstanceResponse(**instance_data) for instance_data in response.json()]
|
|
843
|
+
|
|
844
|
+
|
|
814
845
|
async def _check_bundle_exists(
|
|
815
846
|
client: AsyncWrapper, bundle_hash: str
|
|
816
847
|
) -> VerifiersCheckResponse:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ..client import AsyncFleet, AsyncEnv, Task
|
|
2
|
-
from ...models import Environment as EnvironmentModel, AccountResponse
|
|
2
|
+
from ...models import Environment as EnvironmentModel, AccountResponse, InstanceResponse
|
|
3
3
|
from typing import List, Optional, Dict, Any
|
|
4
4
|
|
|
5
5
|
|
|
@@ -10,6 +10,7 @@ async def make_async(
|
|
|
10
10
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
11
11
|
image_type: Optional[str] = None,
|
|
12
12
|
ttl_seconds: Optional[int] = None,
|
|
13
|
+
run_id: Optional[str] = None,
|
|
13
14
|
) -> AsyncEnv:
|
|
14
15
|
return await AsyncFleet().make(
|
|
15
16
|
env_key,
|
|
@@ -18,6 +19,7 @@ async def make_async(
|
|
|
18
19
|
env_variables=env_variables,
|
|
19
20
|
image_type=image_type,
|
|
20
21
|
ttl_seconds=ttl_seconds,
|
|
22
|
+
run_id=run_id,
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
|
|
@@ -34,14 +36,38 @@ async def list_regions_async() -> List[str]:
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
async def list_instances_async(
|
|
37
|
-
status: Optional[str] = None, region: Optional[str] = None
|
|
39
|
+
status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
38
40
|
) -> List[AsyncEnv]:
|
|
39
|
-
return await AsyncFleet().instances(status=status, region=region)
|
|
41
|
+
return await AsyncFleet().instances(status=status, region=region, run_id=run_id)
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
async def get_async(instance_id: str) -> AsyncEnv:
|
|
43
45
|
return await AsyncFleet().instance(instance_id)
|
|
44
46
|
|
|
45
47
|
|
|
48
|
+
async def close_async(instance_id: str) -> InstanceResponse:
|
|
49
|
+
"""Close (delete) a specific instance by ID.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
instance_id: The instance ID to close
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
InstanceResponse containing the deleted instance details
|
|
56
|
+
"""
|
|
57
|
+
return await AsyncFleet().close(instance_id)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def close_all_async(run_id: str) -> List[InstanceResponse]:
|
|
61
|
+
"""Close (delete) all instances associated with a run_id.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
run_id: The run ID whose instances should be closed
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
List[InstanceResponse] containing the deleted instances
|
|
68
|
+
"""
|
|
69
|
+
return await AsyncFleet().close_all(run_id)
|
|
70
|
+
|
|
71
|
+
|
|
46
72
|
async def account_async() -> AccountResponse:
|
|
47
73
|
return await AsyncFleet().account()
|
|
@@ -214,13 +214,14 @@ class Task(BaseModel):
|
|
|
214
214
|
region: Optional[str] = None,
|
|
215
215
|
image_type: Optional[str] = None,
|
|
216
216
|
ttl_seconds: Optional[int] = None,
|
|
217
|
+
run_id: Optional[str] = None,
|
|
217
218
|
):
|
|
218
219
|
"""Create an environment instance for this task's environment.
|
|
219
220
|
|
|
220
221
|
Alias for make() method. Uses the task's env_id (and version if present) to create the env.
|
|
221
222
|
"""
|
|
222
223
|
return await self.make(
|
|
223
|
-
region=region, image_type=image_type, ttl_seconds=ttl_seconds
|
|
224
|
+
region=region, image_type=image_type, ttl_seconds=ttl_seconds, run_id=run_id
|
|
224
225
|
)
|
|
225
226
|
|
|
226
227
|
async def make(
|
|
@@ -228,6 +229,7 @@ class Task(BaseModel):
|
|
|
228
229
|
region: Optional[str] = None,
|
|
229
230
|
image_type: Optional[str] = None,
|
|
230
231
|
ttl_seconds: Optional[int] = None,
|
|
232
|
+
run_id: Optional[str] = None,
|
|
231
233
|
):
|
|
232
234
|
"""Create an environment instance with task's configuration.
|
|
233
235
|
|
|
@@ -235,11 +237,13 @@ class Task(BaseModel):
|
|
|
235
237
|
- env_key (env_id + version)
|
|
236
238
|
- data_key (data_id + data_version, if present)
|
|
237
239
|
- env_variables (if present)
|
|
240
|
+
- run_id (if present)
|
|
238
241
|
|
|
239
242
|
Args:
|
|
240
243
|
region: Optional AWS region for the environment
|
|
241
244
|
image_type: Optional image type for the environment
|
|
242
245
|
ttl_seconds: Optional TTL in seconds for the instance
|
|
246
|
+
run_id: Optional run ID to group instances
|
|
243
247
|
|
|
244
248
|
Returns:
|
|
245
249
|
Environment instance configured for this task
|
|
@@ -247,7 +251,7 @@ class Task(BaseModel):
|
|
|
247
251
|
Example:
|
|
248
252
|
task = fleet.Task(key="my-task", prompt="...", env_id="my-env",
|
|
249
253
|
data_id="my-data", data_version="v1.0")
|
|
250
|
-
env = await task.make(region="us-west-2")
|
|
254
|
+
env = await task.make(region="us-west-2", run_id="my-batch-123")
|
|
251
255
|
"""
|
|
252
256
|
if not self.env_id:
|
|
253
257
|
raise ValueError("Task has no env_id defined")
|
|
@@ -262,6 +266,7 @@ class Task(BaseModel):
|
|
|
262
266
|
env_variables=self.env_variables if self.env_variables else None,
|
|
263
267
|
image_type=image_type,
|
|
264
268
|
ttl_seconds=ttl_seconds,
|
|
269
|
+
run_id=run_id,
|
|
265
270
|
)
|
|
266
271
|
|
|
267
272
|
|
|
@@ -212,6 +212,7 @@ class Fleet:
|
|
|
212
212
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
213
213
|
image_type: Optional[str] = None,
|
|
214
214
|
ttl_seconds: Optional[int] = None,
|
|
215
|
+
run_id: Optional[str] = None,
|
|
215
216
|
) -> SyncEnv:
|
|
216
217
|
if ":" in env_key:
|
|
217
218
|
env_key_part, env_version = env_key.split(":", 1)
|
|
@@ -247,6 +248,7 @@ class Fleet:
|
|
|
247
248
|
image_type=image_type,
|
|
248
249
|
created_from="sdk",
|
|
249
250
|
ttl_seconds=ttl_seconds,
|
|
251
|
+
run_id=run_id,
|
|
250
252
|
)
|
|
251
253
|
|
|
252
254
|
# Only use region-specific base URL if no custom base URL is set
|
|
@@ -269,13 +271,15 @@ class Fleet:
|
|
|
269
271
|
return self.make(env_key=f"{task.env_id}:{task.version}")
|
|
270
272
|
|
|
271
273
|
def instances(
|
|
272
|
-
self, status: Optional[str] = None, region: Optional[str] = None
|
|
274
|
+
self, status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
273
275
|
) -> List[SyncEnv]:
|
|
274
276
|
params = {}
|
|
275
277
|
if status:
|
|
276
278
|
params["status"] = status
|
|
277
279
|
if region:
|
|
278
280
|
params["region"] = region
|
|
281
|
+
if run_id:
|
|
282
|
+
params["run_id"] = run_id
|
|
279
283
|
|
|
280
284
|
response = self.client.request("GET", "/v1/env/instances", params=params)
|
|
281
285
|
return [
|
|
@@ -300,6 +304,28 @@ class Fleet:
|
|
|
300
304
|
def delete(self, instance_id: str) -> InstanceResponse:
|
|
301
305
|
return _delete_instance(self.client, instance_id)
|
|
302
306
|
|
|
307
|
+
def close(self, instance_id: str) -> InstanceResponse:
|
|
308
|
+
"""Close (delete) a specific instance by ID.
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
instance_id: The instance ID to close
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
InstanceResponse containing the deleted instance details
|
|
315
|
+
"""
|
|
316
|
+
return _delete_instance(self.client, instance_id)
|
|
317
|
+
|
|
318
|
+
def close_all(self, run_id: str) -> List[InstanceResponse]:
|
|
319
|
+
"""Close (delete) all instances associated with a run_id.
|
|
320
|
+
|
|
321
|
+
Args:
|
|
322
|
+
run_id: The run ID whose instances should be closed
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
List[InstanceResponse] containing the deleted instances
|
|
326
|
+
"""
|
|
327
|
+
return _delete_instances_by_run_id(self.client, run_id)
|
|
328
|
+
|
|
303
329
|
def load_tasks_from_file(self, filename: str) -> List[Task]:
|
|
304
330
|
with open(filename, "r", encoding="utf-8") as f:
|
|
305
331
|
tasks_data = f.read()
|
|
@@ -810,6 +836,11 @@ def _delete_instance(client: SyncWrapper, instance_id: str) -> InstanceResponse:
|
|
|
810
836
|
return InstanceResponse(**response.json())
|
|
811
837
|
|
|
812
838
|
|
|
839
|
+
def _delete_instances_by_run_id(client: SyncWrapper, run_id: str) -> List[InstanceResponse]:
|
|
840
|
+
response = client.request("DELETE", f"/v1/env/instances/run/{run_id}")
|
|
841
|
+
return [InstanceResponse(**instance_data) for instance_data in response.json()]
|
|
842
|
+
|
|
843
|
+
|
|
813
844
|
def _check_bundle_exists(
|
|
814
845
|
client: SyncWrapper, bundle_hash: str
|
|
815
846
|
) -> VerifiersCheckResponse:
|
|
@@ -7,6 +7,8 @@ from .client import (
|
|
|
7
7
|
list_regions,
|
|
8
8
|
get,
|
|
9
9
|
list_instances,
|
|
10
|
+
close,
|
|
11
|
+
close_all,
|
|
10
12
|
account,
|
|
11
13
|
)
|
|
12
14
|
|
|
@@ -17,6 +19,8 @@ from .._async.env.client import (
|
|
|
17
19
|
list_regions_async,
|
|
18
20
|
get_async,
|
|
19
21
|
list_instances_async,
|
|
22
|
+
close_async,
|
|
23
|
+
close_all_async,
|
|
20
24
|
account_async,
|
|
21
25
|
)
|
|
22
26
|
|
|
@@ -27,11 +31,15 @@ __all__ = [
|
|
|
27
31
|
"list_regions",
|
|
28
32
|
"list_instances",
|
|
29
33
|
"get",
|
|
34
|
+
"close",
|
|
35
|
+
"close_all",
|
|
30
36
|
"make_async",
|
|
31
37
|
"list_envs_async",
|
|
32
38
|
"list_regions_async",
|
|
33
39
|
"list_instances_async",
|
|
34
40
|
"get_async",
|
|
41
|
+
"close_async",
|
|
42
|
+
"close_all_async",
|
|
35
43
|
"account",
|
|
36
44
|
"account_async",
|
|
37
45
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ..client import Fleet, SyncEnv, Task
|
|
2
|
-
from ..models import Environment as EnvironmentModel, AccountResponse
|
|
2
|
+
from ..models import Environment as EnvironmentModel, AccountResponse, InstanceResponse
|
|
3
3
|
from typing import List, Optional, Dict, Any
|
|
4
4
|
|
|
5
5
|
|
|
@@ -10,6 +10,7 @@ def make(
|
|
|
10
10
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
11
11
|
image_type: Optional[str] = None,
|
|
12
12
|
ttl_seconds: Optional[int] = None,
|
|
13
|
+
run_id: Optional[str] = None,
|
|
13
14
|
) -> SyncEnv:
|
|
14
15
|
return Fleet().make(
|
|
15
16
|
env_key,
|
|
@@ -18,6 +19,7 @@ def make(
|
|
|
18
19
|
env_variables=env_variables,
|
|
19
20
|
image_type=image_type,
|
|
20
21
|
ttl_seconds=ttl_seconds,
|
|
22
|
+
run_id=run_id,
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
|
|
@@ -34,14 +36,38 @@ def list_regions() -> List[str]:
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
def list_instances(
|
|
37
|
-
status: Optional[str] = None, region: Optional[str] = None
|
|
39
|
+
status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
38
40
|
) -> List[SyncEnv]:
|
|
39
|
-
return Fleet().instances(status=status, region=region)
|
|
41
|
+
return Fleet().instances(status=status, region=region, run_id=run_id)
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
def get(instance_id: str) -> SyncEnv:
|
|
43
45
|
return Fleet().instance(instance_id)
|
|
44
46
|
|
|
45
47
|
|
|
48
|
+
def close(instance_id: str) -> InstanceResponse:
|
|
49
|
+
"""Close (delete) a specific instance by ID.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
instance_id: The instance ID to close
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
InstanceResponse containing the deleted instance details
|
|
56
|
+
"""
|
|
57
|
+
return Fleet().close(instance_id)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def close_all(run_id: str) -> List[InstanceResponse]:
|
|
61
|
+
"""Close (delete) all instances associated with a run_id.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
run_id: The run ID whose instances should be closed
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
List[InstanceResponse] containing the deleted instances
|
|
68
|
+
"""
|
|
69
|
+
return Fleet().close_all(run_id)
|
|
70
|
+
|
|
71
|
+
|
|
46
72
|
def account() -> AccountResponse:
|
|
47
73
|
return Fleet().account()
|
|
@@ -51,6 +51,7 @@ class Instance(BaseModel):
|
|
|
51
51
|
team_id: str = Field(..., title="Team Id")
|
|
52
52
|
region: str = Field(..., title="Region")
|
|
53
53
|
env_variables: Optional[Dict[str, Any]] = Field(None, title="Env Variables")
|
|
54
|
+
run_id: Optional[str] = Field(None, title="Run Id")
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
class InstanceRequest(BaseModel):
|
|
@@ -363,6 +364,7 @@ class InstanceResponse(BaseModel):
|
|
|
363
364
|
data_version: Optional[str] = Field(None, title="Data Version")
|
|
364
365
|
urls: Optional[InstanceURLs] = Field(None, title="Urls")
|
|
365
366
|
health: Optional[bool] = Field(None, title="Health")
|
|
367
|
+
run_id: Optional[str] = Field(None, title="Run Id")
|
|
366
368
|
|
|
367
369
|
|
|
368
370
|
class AccountResponse(BaseModel):
|
|
@@ -207,18 +207,20 @@ class Task(BaseModel):
|
|
|
207
207
|
region: Optional[str] = None,
|
|
208
208
|
image_type: Optional[str] = None,
|
|
209
209
|
ttl_seconds: Optional[int] = None,
|
|
210
|
+
run_id: Optional[str] = None,
|
|
210
211
|
):
|
|
211
212
|
"""Create an environment instance for this task's environment.
|
|
212
213
|
|
|
213
214
|
Alias for make() method. Uses the task's env_id (and version if present) to create the env.
|
|
214
215
|
"""
|
|
215
|
-
return self.make(region=region, image_type=image_type, ttl_seconds=ttl_seconds)
|
|
216
|
+
return self.make(region=region, image_type=image_type, ttl_seconds=ttl_seconds, run_id=run_id)
|
|
216
217
|
|
|
217
218
|
def make(
|
|
218
219
|
self,
|
|
219
220
|
region: Optional[str] = None,
|
|
220
221
|
image_type: Optional[str] = None,
|
|
221
222
|
ttl_seconds: Optional[int] = None,
|
|
223
|
+
run_id: Optional[str] = None,
|
|
222
224
|
):
|
|
223
225
|
"""Create an environment instance with task's configuration.
|
|
224
226
|
|
|
@@ -226,11 +228,13 @@ class Task(BaseModel):
|
|
|
226
228
|
- env_key (env_id + version)
|
|
227
229
|
- data_key (data_id + data_version, if present)
|
|
228
230
|
- env_variables (if present)
|
|
231
|
+
- run_id (if present)
|
|
229
232
|
|
|
230
233
|
Args:
|
|
231
234
|
region: Optional AWS region for the environment
|
|
232
235
|
image_type: Optional image type for the environment
|
|
233
236
|
ttl_seconds: Optional TTL in seconds for the instance
|
|
237
|
+
run_id: Optional run ID to group instances
|
|
234
238
|
|
|
235
239
|
Returns:
|
|
236
240
|
Environment instance configured for this task
|
|
@@ -238,7 +242,7 @@ class Task(BaseModel):
|
|
|
238
242
|
Example:
|
|
239
243
|
task = fleet.Task(key="my-task", prompt="...", env_id="my-env",
|
|
240
244
|
data_id="my-data", data_version="v1.0")
|
|
241
|
-
env = task.make(region="us-west-2")
|
|
245
|
+
env = task.make(region="us-west-2", run_id="my-batch-123")
|
|
242
246
|
"""
|
|
243
247
|
if not self.env_id:
|
|
244
248
|
raise ValueError("Task has no env_id defined")
|
|
@@ -253,6 +257,7 @@ class Task(BaseModel):
|
|
|
253
257
|
env_variables=self.env_variables if self.env_variables else None,
|
|
254
258
|
image_type=image_type,
|
|
255
259
|
ttl_seconds=ttl_seconds,
|
|
260
|
+
run_id=run_id,
|
|
256
261
|
)
|
|
257
262
|
|
|
258
263
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|