fleet-python 0.2.27__tar.gz → 0.2.28__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.27 → fleet_python-0.2.28}/PKG-INFO +1 -1
- fleet_python-0.2.28/fleet/tasks.py +82 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet_python.egg-info/PKG-INFO +1 -1
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet_python.egg-info/SOURCES.txt +1 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/pyproject.toml +1 -1
- {fleet_python-0.2.27 → fleet_python-0.2.28}/LICENSE +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/README.md +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/diff_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/dsl_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_action_log.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_mcp_anthropic.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_mcp_openai.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_sync.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_task.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_tasks.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/example_verifier.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/gemini_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/json_tasks_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/nova_act_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/openai_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/openai_simple_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/query_builder_example.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/examples/quickstart.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/env/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/env/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/exceptions.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/instance/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/instance/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/instance/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/models.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/resources/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/resources/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/resources/browser.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/resources/sqlite.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/tasks.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/verifiers/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/verifiers/bundler.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/_async/verifiers/verifier.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/config.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/env/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/env/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/exceptions.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/instance/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/instance/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/instance/client.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/instance/models.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/models.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/resources/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/resources/base.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/resources/browser.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/resources/mcp.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/resources/sqlite.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/types.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/__init__.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/bundler.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/code.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/db.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/decorator.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/parse.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/sql_differ.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet/verifiers/verifier.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet_python.egg-info/dependency_links.txt +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet_python.egg-info/requires.txt +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/fleet_python.egg-info/top_level.txt +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/scripts/fix_sync_imports.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/scripts/unasync.py +0 -0
- {fleet_python-0.2.27 → fleet_python-0.2.28}/setup.cfg +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
metadata: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Additional task metadata")
|
|
28
|
+
|
|
29
|
+
@validator('key')
|
|
30
|
+
def validate_key_format(cls, v):
|
|
31
|
+
"""Validate key follows kebab-case format."""
|
|
32
|
+
if not re.match(r'^[a-z0-9]+(-[a-z0-9]+)*$', v):
|
|
33
|
+
raise ValueError(f'Invalid task key format: {v}. Must follow kebab-case format.')
|
|
34
|
+
return v
|
|
35
|
+
|
|
36
|
+
@validator('created_at', pre=True, always=True)
|
|
37
|
+
def set_created_at(cls, v):
|
|
38
|
+
"""Set created_at to current time if not provided."""
|
|
39
|
+
return v or datetime.now()
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def env_key(self) -> str:
|
|
43
|
+
"""Get the environment key combining env_id and version."""
|
|
44
|
+
if self.version:
|
|
45
|
+
return f"{self.env_id}:{self.version}"
|
|
46
|
+
return self.env_id
|
|
47
|
+
|
|
48
|
+
class Config:
|
|
49
|
+
"""Pydantic model configuration."""
|
|
50
|
+
json_encoders = {
|
|
51
|
+
datetime: lambda v: v.isoformat(),
|
|
52
|
+
}
|
|
53
|
+
# Allow arbitrary types for the verifier field
|
|
54
|
+
arbitrary_types_allowed = True
|
|
55
|
+
|
|
56
|
+
def verify(self, env, *args, **kwargs) -> float:
|
|
57
|
+
"""Verify the task using the verifier function (sync version).
|
|
58
|
+
|
|
59
|
+
For sync environments, calls the sync verifier directly.
|
|
60
|
+
For async verifiers, automatically runs them with asyncio.run().
|
|
61
|
+
"""
|
|
62
|
+
if self.verifier:
|
|
63
|
+
return self.verifier.remote(env, *args, **kwargs)
|
|
64
|
+
else:
|
|
65
|
+
raise ValueError("No verifier function found for this task")
|
|
66
|
+
|
|
67
|
+
def verify_async(self, *args, **kwargs) -> float:
|
|
68
|
+
"""Verify the task using the verifier function (async version).
|
|
69
|
+
|
|
70
|
+
For async environments, awaits the async verifier.
|
|
71
|
+
Works with both sync and async verifiers in async contexts.
|
|
72
|
+
"""
|
|
73
|
+
if self.verifier:
|
|
74
|
+
result = self.verifier.remote(*args, **kwargs)
|
|
75
|
+
# If it's a coroutine, await it
|
|
76
|
+
import inspect
|
|
77
|
+
if inspect.iscoroutine(result):
|
|
78
|
+
return result
|
|
79
|
+
else:
|
|
80
|
+
return result
|
|
81
|
+
else:
|
|
82
|
+
raise ValueError("No verifier function found for this task")
|
|
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
|