fleet-python 0.2.27__tar.gz → 0.2.29__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.

Files changed (75) hide show
  1. {fleet_python-0.2.27 → fleet_python-0.2.29}/PKG-INFO +1 -1
  2. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/client.py +47 -0
  3. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/env/client.py +3 -1
  4. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/tasks.py +2 -0
  5. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/client.py +55 -2
  6. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/env/__init__.py +2 -1
  7. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/env/client.py +3 -2
  8. fleet_python-0.2.29/fleet/tasks.py +84 -0
  9. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet_python.egg-info/PKG-INFO +1 -1
  10. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet_python.egg-info/SOURCES.txt +1 -0
  11. {fleet_python-0.2.27 → fleet_python-0.2.29}/pyproject.toml +1 -1
  12. {fleet_python-0.2.27 → fleet_python-0.2.29}/LICENSE +0 -0
  13. {fleet_python-0.2.27 → fleet_python-0.2.29}/README.md +0 -0
  14. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/diff_example.py +0 -0
  15. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/dsl_example.py +0 -0
  16. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example.py +0 -0
  17. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_action_log.py +0 -0
  18. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_client.py +0 -0
  19. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_mcp_anthropic.py +0 -0
  20. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_mcp_openai.py +0 -0
  21. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_sync.py +0 -0
  22. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_task.py +0 -0
  23. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_tasks.py +0 -0
  24. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/example_verifier.py +0 -0
  25. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/gemini_example.py +0 -0
  26. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/json_tasks_example.py +0 -0
  27. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/nova_act_example.py +0 -0
  28. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/openai_example.py +0 -0
  29. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/openai_simple_example.py +0 -0
  30. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/query_builder_example.py +0 -0
  31. {fleet_python-0.2.27 → fleet_python-0.2.29}/examples/quickstart.py +0 -0
  32. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/__init__.py +0 -0
  33. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/__init__.py +0 -0
  34. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/base.py +0 -0
  35. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/env/__init__.py +0 -0
  36. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/exceptions.py +0 -0
  37. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/instance/__init__.py +0 -0
  38. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/instance/base.py +0 -0
  39. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/instance/client.py +0 -0
  40. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/models.py +0 -0
  41. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/resources/__init__.py +0 -0
  42. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/resources/base.py +0 -0
  43. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/resources/browser.py +0 -0
  44. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/resources/sqlite.py +0 -0
  45. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/verifiers/__init__.py +0 -0
  46. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/verifiers/bundler.py +0 -0
  47. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/_async/verifiers/verifier.py +0 -0
  48. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/base.py +0 -0
  49. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/config.py +0 -0
  50. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/exceptions.py +0 -0
  51. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/instance/__init__.py +0 -0
  52. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/instance/base.py +0 -0
  53. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/instance/client.py +0 -0
  54. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/instance/models.py +0 -0
  55. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/models.py +0 -0
  56. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/resources/__init__.py +0 -0
  57. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/resources/base.py +0 -0
  58. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/resources/browser.py +0 -0
  59. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/resources/mcp.py +0 -0
  60. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/resources/sqlite.py +0 -0
  61. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/types.py +0 -0
  62. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/__init__.py +0 -0
  63. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/bundler.py +0 -0
  64. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/code.py +0 -0
  65. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/db.py +0 -0
  66. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/decorator.py +0 -0
  67. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/parse.py +0 -0
  68. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/sql_differ.py +0 -0
  69. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet/verifiers/verifier.py +0 -0
  70. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet_python.egg-info/dependency_links.txt +0 -0
  71. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet_python.egg-info/requires.txt +0 -0
  72. {fleet_python-0.2.27 → fleet_python-0.2.29}/fleet_python.egg-info/top_level.txt +0 -0
  73. {fleet_python-0.2.27 → fleet_python-0.2.29}/scripts/fix_sync_imports.py +0 -0
  74. {fleet_python-0.2.27 → fleet_python-0.2.29}/scripts/unasync.py +0 -0
  75. {fleet_python-0.2.27 → fleet_python-0.2.29}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.27
3
+ Version: 0.2.29
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -213,6 +213,9 @@ class AsyncFleet:
213
213
  await instance.instance.load()
214
214
  return instance
215
215
 
216
+ async def make_for_task(self, task: Task) -> AsyncEnv:
217
+ return self.make(env_key=f"{task.env_id}:{task.version}")
218
+
216
219
  async def instances(
217
220
  self, status: Optional[str] = None, region: Optional[str] = None
218
221
  ) -> List[AsyncEnv]:
@@ -247,6 +250,50 @@ class AsyncFleet:
247
250
  async def delete(self, instance_id: str) -> InstanceResponse:
248
251
  return await _delete_instance(self.client, instance_id)
249
252
 
253
+ async def load_tasks_from_file(self, filename: str) -> List[Task]:
254
+ with open(filename, 'r', encoding='utf-8') as f:
255
+ tasks_data = f.read()
256
+
257
+ return self.load_task_array_from_string(tasks_data)
258
+
259
+ async def load_task_array_from_string(self, serialized_tasks: List[Dict]) -> List[Task]:
260
+ tasks = []
261
+
262
+ json_tasks = json.loads(serialized_tasks)
263
+ for json_task in json_tasks:
264
+ parsed_task = self.load_task_from_json(json_task)
265
+ tasks.append(parsed_task)
266
+ return tasks
267
+
268
+ async def load_task_from_string(self, task_string: str) -> Task:
269
+ task_json = json.loads(task_string)
270
+ return self.load_task_from_json(task_json)
271
+
272
+ async def load_task_from_json(self, task_json: Dict) -> Task:
273
+ try:
274
+ if 'verifier_id' in task_json and task_json['verifier_id']:
275
+ verifier = self._create_verifier_from_data(
276
+ verifier_id=task_json['verifier_id'],
277
+ verifier_key=task_json['key'],
278
+ verifier_code=task_json['verifier_func'],
279
+ verifier_sha=task_json.get('verifier_sha', '')
280
+ )
281
+ except Exception as e:
282
+ logger.warning(f"Failed to create verifier {task_json['key']}: {e}")
283
+
284
+ task = Task(
285
+ key=task_json['key'],
286
+ prompt=task_json['prompt'],
287
+ env_id=task_json['env_id'], # Use env_id from the data
288
+ created_at=task_json['created_at'],
289
+ version=task_json.get('version'),
290
+ env_variables=task_json.get('env_variables', {}),
291
+ verifier_func=task_json.get('verifier_func'), # Set verifier code
292
+ verifier=verifier, # Use created verifier or None
293
+ metadata=task_json.get('metadata', {}) # Default empty metadata
294
+ )
295
+ return task
296
+
250
297
  async def load_tasks(self, env_key: Optional[str] = None) -> List[Task]:
251
298
  """Load tasks for the authenticated team, optionally filtered by environment.
252
299
 
@@ -1,4 +1,4 @@
1
- from ..client import AsyncFleet, AsyncEnv
1
+ from ..client import AsyncFleet, AsyncEnv, Task
2
2
  from ...models import Environment as EnvironmentModel, AccountResponse
3
3
  from typing import List, Optional
4
4
 
@@ -6,6 +6,8 @@ from typing import List, Optional
6
6
  async def make_async(env_key: str, region: Optional[str] = None) -> AsyncEnv:
7
7
  return await AsyncFleet().make(env_key, region=region)
8
8
 
9
+ async def make_for_task_async(task: Task) -> AsyncEnv:
10
+ return await AsyncFleet().make_for_task(task)
9
11
 
10
12
  async def list_envs_async() -> List[EnvironmentModel]:
11
13
  return await AsyncFleet().list_envs()
@@ -24,6 +24,8 @@ class Task(BaseModel):
24
24
  version: Optional[str] = Field(None, description="Task version")
25
25
  verifier_func: Optional[str] = Field(None, description="Verifier function code")
26
26
  verifier: Optional[Any] = Field(None, description="Verifier function with decorator (async or sync)")
27
+ verifier_id: Optional[str] = Field(None, description="Verifier identifier")
28
+ verifier_sha: Optional[str] = Field(None, description="Verifier SHA256 hash")
27
29
  metadata: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Additional task metadata")
28
30
 
29
31
  @validator('key')
@@ -213,6 +213,9 @@ class Fleet:
213
213
  instance.instance.load()
214
214
  return instance
215
215
 
216
+ def make_for_task(self, task: Task) -> SyncEnv:
217
+ return self.make(env_key=f"{task.env_id}:{task.version}")
218
+
216
219
  def instances(
217
220
  self, status: Optional[str] = None, region: Optional[str] = None
218
221
  ) -> List[SyncEnv]:
@@ -246,8 +249,54 @@ class Fleet:
246
249
 
247
250
  def delete(self, instance_id: str) -> InstanceResponse:
248
251
  return _delete_instance(self.client, instance_id)
252
+
253
+ def load_tasks_from_file(self, filename: str) -> List[Task]:
254
+ with open(filename, 'r', encoding='utf-8') as f:
255
+ tasks_data = f.read()
256
+
257
+ return self.load_task_array_from_string(tasks_data)
258
+
259
+ def load_task_array_from_string(self, serialized_tasks: List[Dict]) -> List[Task]:
260
+ tasks = []
261
+
262
+ json_tasks = json.loads(serialized_tasks)
263
+ for json_task in json_tasks:
264
+ parsed_task = self.load_task_from_json(json_task)
265
+ tasks.append(parsed_task)
266
+ return tasks
267
+
268
+ def load_task_from_string(self, task_string: str) -> Task:
269
+ task_json = json.loads(task_string)
270
+ return self.load_task_from_json(task_json)
271
+
272
+ def load_task_from_json(self, task_json: Dict) -> Task:
273
+ verifier = None
274
+ try:
275
+ if 'verifier_id' in task_json and task_json['verifier_id']:
276
+ verifier = self._create_verifier_from_data(
277
+ verifier_id=task_json['verifier_id'],
278
+ verifier_key=task_json['key'],
279
+ verifier_code=task_json['verifier_func'],
280
+ verifier_sha=task_json.get('verifier_sha', '')
281
+ )
282
+ except Exception as e:
283
+ logger.warning(f"Failed to create verifier {task_json['key']}: {e}")
284
+
285
+ task = Task(
286
+ key=task_json['key'],
287
+ prompt=task_json['prompt'],
288
+ env_id=task_json['env_id'], # Use env_id from the data
289
+ created_at=task_json['created_at'],
290
+ version=task_json.get('version'),
291
+ env_variables=task_json.get('env_variables', {}),
292
+ verifier_func=task_json.get('verifier_func'), # Set verifier code
293
+ verifier=verifier, # Use created verifier or None
294
+ metadata=task_json.get('metadata', {}) # Default empty metadata
295
+ )
296
+ return task
249
297
 
250
- def load_tasks(self, env_key: Optional[str] = None) -> List[Task]:
298
+
299
+ def load_tasks(self, env_key: Optional[str] = None, task_keys: Optional[List[str]] = None) -> List[Task]:
251
300
  """Load tasks for the authenticated team, optionally filtered by environment.
252
301
 
253
302
  Args:
@@ -259,6 +308,9 @@ class Fleet:
259
308
  params = {}
260
309
  if env_key is not None:
261
310
  params["env_key"] = env_key
311
+
312
+ if task_keys is not None:
313
+ params["task_keys"] = task_keys
262
314
 
263
315
  response = self.client.request("GET", "/v1/tasks", params=params)
264
316
  task_list_response = TaskListResponse(**response.json())
@@ -294,6 +346,8 @@ class Fleet:
294
346
  env_variables=task_response.env_variables or {},
295
347
  verifier_func=verifier_func, # Set verifier code
296
348
  verifier=verifier, # Use created verifier or None
349
+ verifier_id=task_response.verifier.verifier_id,
350
+ verifier_sha=task_response.verifier.sha256,
297
351
  metadata={} # Default empty metadata
298
352
  )
299
353
  tasks.append(task)
@@ -371,7 +425,6 @@ class Fleet:
371
425
  logger.error(f"Failed to import task {task.key}: {e}")
372
426
  continue
373
427
 
374
-
375
428
  def account(self) -> AccountResponse:
376
429
  """Get account information including instance limits and usage.
377
430
 
@@ -1,6 +1,6 @@
1
1
  """Fleet env module - convenience functions for environment management."""
2
2
 
3
- from .client import make, list_envs, list_regions, get, list_instances, account
3
+ from .client import make, make_for_task, list_envs, list_regions, get, list_instances, account
4
4
 
5
5
  # Import async versions from _async
6
6
  from .._async.env.client import (
@@ -14,6 +14,7 @@ from .._async.env.client import (
14
14
 
15
15
  __all__ = [
16
16
  "make",
17
+ "make_for_task",
17
18
  "list_envs",
18
19
  "list_regions",
19
20
  "list_instances",
@@ -1,4 +1,4 @@
1
- from ..client import Fleet, SyncEnv
1
+ from ..client import Fleet, SyncEnv, Task
2
2
  from ..models import Environment as EnvironmentModel, AccountResponse
3
3
  from typing import List, Optional
4
4
 
@@ -6,11 +6,12 @@ from typing import List, Optional
6
6
  def make(env_key: str, region: Optional[str] = None) -> SyncEnv:
7
7
  return Fleet().make(env_key, region=region)
8
8
 
9
+ def make_for_task(task: Task) -> SyncEnv:
10
+ return Fleet().make_for_task(task)
9
11
 
10
12
  def list_envs() -> List[EnvironmentModel]:
11
13
  return Fleet().list_envs()
12
14
 
13
-
14
15
  def list_regions() -> List[str]:
15
16
  return Fleet().list_regions()
16
17
 
@@ -0,0 +1,84 @@
1
+ """Fleet SDK Task Model."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from datetime import datetime
7
+ from typing import Any, Dict, Optional
8
+ from uuid import UUID
9
+
10
+ from pydantic import BaseModel, Field, validator
11
+
12
+ # Import the shared VerifierFunction type that works for both async and sync
13
+ from fleet.types import VerifierFunction
14
+
15
+
16
+ class Task(BaseModel):
17
+ """A task model representing a single task in the Fleet system."""
18
+
19
+ key: str = Field(..., description="Unique task key identifier")
20
+ prompt: str = Field(..., description="Task prompt or instruction")
21
+ env_id: str = Field(..., description="Environment identifier")
22
+ env_variables: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Environment variables")
23
+ created_at: Optional[datetime] = Field(None, description="Task creation timestamp")
24
+ version: Optional[str] = Field(None, description="Task version")
25
+ verifier_func: Optional[str] = Field(None, description="Verifier function code")
26
+ verifier: Optional[Any] = Field(None, description="Verifier function with decorator (async or sync)")
27
+ verifier_id: Optional[str] = Field(None, description="Verifier identifier")
28
+ verifier_sha: Optional[str] = Field(None, description="Verifier SHA256 hash")
29
+ metadata: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Additional task metadata")
30
+
31
+ @validator('key')
32
+ def validate_key_format(cls, v):
33
+ """Validate key follows kebab-case format."""
34
+ if not re.match(r'^[a-z0-9]+(-[a-z0-9]+)*$', v):
35
+ raise ValueError(f'Invalid task key format: {v}. Must follow kebab-case format.')
36
+ return v
37
+
38
+ @validator('created_at', pre=True, always=True)
39
+ def set_created_at(cls, v):
40
+ """Set created_at to current time if not provided."""
41
+ return v or datetime.now()
42
+
43
+ @property
44
+ def env_key(self) -> str:
45
+ """Get the environment key combining env_id and version."""
46
+ if self.version:
47
+ return f"{self.env_id}:{self.version}"
48
+ return self.env_id
49
+
50
+ class Config:
51
+ """Pydantic model configuration."""
52
+ json_encoders = {
53
+ datetime: lambda v: v.isoformat(),
54
+ }
55
+ # Allow arbitrary types for the verifier field
56
+ arbitrary_types_allowed = True
57
+
58
+ def verify(self, env, *args, **kwargs) -> float:
59
+ """Verify the task using the verifier function (sync version).
60
+
61
+ For sync environments, calls the sync verifier directly.
62
+ For async verifiers, automatically runs them with asyncio.run().
63
+ """
64
+ if self.verifier:
65
+ return self.verifier.remote(env, *args, **kwargs)
66
+ else:
67
+ raise ValueError("No verifier function found for this task")
68
+
69
+ def verify_async(self, *args, **kwargs) -> float:
70
+ """Verify the task using the verifier function (async version).
71
+
72
+ For async environments, awaits the async verifier.
73
+ Works with both sync and async verifiers in async contexts.
74
+ """
75
+ if self.verifier:
76
+ result = self.verifier.remote(*args, **kwargs)
77
+ # If it's a coroutine, await it
78
+ import inspect
79
+ if inspect.iscoroutine(result):
80
+ return result
81
+ else:
82
+ return result
83
+ else:
84
+ raise ValueError("No verifier function found for this task")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.27
3
+ Version: 0.2.29
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -25,6 +25,7 @@ fleet/client.py
25
25
  fleet/config.py
26
26
  fleet/exceptions.py
27
27
  fleet/models.py
28
+ fleet/tasks.py
28
29
  fleet/types.py
29
30
  fleet/_async/__init__.py
30
31
  fleet/_async/base.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fleet-python"
7
- version = "0.2.27"
7
+ version = "0.2.29"
8
8
  description = "Python SDK for Fleet environments"
9
9
  authors = [
10
10
  {name = "Fleet AI", email = "nic@fleet.so"},
File without changes
File without changes
File without changes