fleet-python 0.2.34__py3-none-any.whl → 0.2.35__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/__init__.py CHANGED
@@ -46,8 +46,11 @@ from ._async.verifiers import (
46
46
  AsyncVerifierFunction,
47
47
  )
48
48
 
49
- # Import async tasks (default tasks are async for modern usage)
50
- from ._async.tasks import Task
49
+ # Import async tasks (default tasks are async for modern usage)
50
+ from ._async.tasks import Task, load_tasks
51
+
52
+ # Import sync load_tasks function
53
+ from .tasks import load_tasks as load_tasks_sync
51
54
 
52
55
  # Import shared types
53
56
  from .types import VerifierFunction
@@ -94,19 +97,14 @@ __all__ = [
94
97
  "configure",
95
98
  "get_client",
96
99
  "reset_client",
100
+ # Module-level functions (async is default)
101
+ "load_tasks",
102
+ "load_tasks_sync",
97
103
  # Version
98
104
  "__version__",
99
105
  ]
100
106
 
101
107
 
102
- def load_tasks(env_key: Optional[str] = None) -> List[Task]:
103
- """Load tasks without explicitly creating a client.
104
-
105
- Example:
106
- tasks = fleet.load_tasks(env_key="fira")
107
- """
108
- # Use global client by default so users can configure once
109
- return _global_client.get_client().load_tasks(env_key=env_key)
110
108
 
111
109
 
112
110
  def configure(
fleet/_async/__init__.py CHANGED
@@ -35,7 +35,7 @@ from .verifiers import (
35
35
  )
36
36
 
37
37
  # Import async tasks
38
- from .tasks import Task
38
+ from .tasks import Task, load_tasks
39
39
 
40
40
  # Import shared types
41
41
  from ..types import VerifierFunction
@@ -93,33 +93,6 @@ __all__ = [
93
93
  ]
94
94
 
95
95
 
96
- async def load_tasks(
97
- env_key: Optional[str] = None,
98
- keys: Optional[List[str]] = None,
99
- version: Optional[str] = None,
100
- team_id: Optional[str] = None
101
- ) -> List[Task]:
102
- """Load tasks with optional filtering.
103
-
104
- Args:
105
- env_key: Optional environment key to filter tasks by
106
- keys: Optional list of task keys to filter by
107
- version: Optional version to filter tasks by
108
-
109
- Examples:
110
- tasks = await fleet.load_tasks(env_key="fira")
111
- tasks = await fleet.load_tasks(keys=["task1", "task2"])
112
- tasks = await fleet.load_tasks(env_key="fira", version="v1.0")
113
- """
114
- # Use global client by default so users can configure once
115
- return await _async_global_client.get_client().load_tasks(
116
- env_key=env_key,
117
- keys=keys,
118
- version=version,
119
- team_id=team_id
120
- )
121
-
122
-
123
96
  async def list_envs() -> List[Environment]:
124
97
  """List all available environments."""
125
98
  return await _async_global_client.get_client().list_envs()
fleet/_async/client.py CHANGED
@@ -50,7 +50,7 @@ from .instance.client import ValidatorType
50
50
  from .resources.base import Resource
51
51
  from .resources.sqlite import AsyncSQLiteResource
52
52
  from .resources.browser import AsyncBrowserResource
53
- from ..resources.mcp import MCPResource
53
+ from .resources.mcp import AsyncMCPResource
54
54
 
55
55
  logger = logging.getLogger(__name__)
56
56
 
@@ -105,9 +105,9 @@ class AsyncEnv(EnvironmentBase):
105
105
  return self.instance.browser(name)
106
106
 
107
107
  @property
108
- def mcp(self) -> MCPResource:
108
+ def mcp(self) -> AsyncMCPResource:
109
109
  mcp_url = f"{self.urls.root}mcp"
110
- return MCPResource(url=mcp_url, env_key=self.env_key)
110
+ return AsyncMCPResource(url=mcp_url, env_key=self.env_key)
111
111
 
112
112
  def state(self, uri: str) -> Resource:
113
113
  return self.instance.state(uri)
@@ -507,12 +507,6 @@ class AsyncFleet:
507
507
  sha256=verifier_sha,
508
508
  )
509
509
 
510
- # Ensure we return an AsyncVerifierFunction
511
- if not isinstance(verifier_func, AsyncVerifierFunction):
512
- raise TypeError(
513
- f"Expected AsyncVerifierFunction but got {type(verifier_func).__name__}"
514
- )
515
-
516
510
  # Store the original verifier code for reference
517
511
  verifier_func._verifier_code = verifier_code
518
512
 
fleet/_async/tasks.py CHANGED
@@ -125,6 +125,56 @@ class Task(BaseModel):
125
125
  return await AsyncFleet().make(env_key=self.env_key, region=region)
126
126
 
127
127
 
128
+ def verifier_from_string(
129
+ verifier_func: str,
130
+ verifier_id: str,
131
+ verifier_key: str,
132
+ sha256: str = ""
133
+ ) -> 'VerifierFunction':
134
+ """Create a verifier function from string code.
135
+
136
+ Args:
137
+ verifier_func: The verifier function code as a string
138
+ verifier_id: Unique identifier for the verifier
139
+ verifier_key: Key/name for the verifier
140
+ sha256: SHA256 hash of the verifier code
141
+
142
+ Returns:
143
+ VerifierFunction instance that can be used to verify tasks
144
+ """
145
+ try:
146
+ import inspect
147
+ from .verifiers import verifier, AsyncVerifierFunction
148
+
149
+ # Create a local namespace for executing the code
150
+ local_namespace = {}
151
+
152
+ # Execute the verifier code in the namespace
153
+ exec(verifier_func, globals(), local_namespace)
154
+
155
+ # Find the function that was defined
156
+ func_obj = None
157
+ for name, obj in local_namespace.items():
158
+ if inspect.isfunction(obj):
159
+ func_obj = obj
160
+ break
161
+
162
+ if func_obj is None:
163
+ raise ValueError("No function found in verifier code")
164
+
165
+ # Create an AsyncVerifierFunction instance
166
+ verifier_instance = AsyncVerifierFunction(func_obj, verifier_key, verifier_id)
167
+
168
+ # Store additional metadata
169
+ verifier_instance._verifier_code = verifier_func
170
+ verifier_instance._sha256 = sha256
171
+
172
+ return verifier_instance
173
+
174
+ except Exception as e:
175
+ raise ValueError(f"Failed to create verifier from string: {e}")
176
+
177
+
128
178
  async def load_tasks(
129
179
  env_key: Optional[str] = None,
130
180
  keys: Optional[List[str]] = None,
fleet/client.py CHANGED
@@ -50,7 +50,7 @@ from .instance.client import ValidatorType
50
50
  from .resources.base import Resource
51
51
  from .resources.sqlite import SQLiteResource
52
52
  from .resources.browser import BrowserResource
53
- from ..resources.mcp import MCPResource
53
+ from .resources.mcp import SyncMCPResource
54
54
 
55
55
  logger = logging.getLogger(__name__)
56
56
 
@@ -105,9 +105,9 @@ class SyncEnv(EnvironmentBase):
105
105
  return self.instance.browser(name)
106
106
 
107
107
  @property
108
- def mcp(self) -> MCPResource:
108
+ def mcp(self) -> SyncMCPResource:
109
109
  mcp_url = f"{self.urls.root}mcp"
110
- return MCPResource(url=mcp_url, env_key=self.env_key)
110
+ return SyncMCPResource(url=mcp_url, env_key=self.env_key)
111
111
 
112
112
  def state(self, uri: str) -> Resource:
113
113
  return self.instance.state(uri)
@@ -496,14 +496,8 @@ class Fleet:
496
496
  Returns:
497
497
  AsyncVerifierFunction created from the verifier code
498
498
  """
499
- from ..tasks import verifier_from_string
500
- from .verifiers.verifier import SyncVerifierFunction
501
-
502
- # Convert async verifier code to sync
503
- if 'async def' in verifier_code:
504
- verifier_code = verifier_code.replace('async def', 'def')
505
- if 'await ' in verifier_code:
506
- verifier_code = verifier_code.replace('await ', '')
499
+ from .tasks import verifier_from_string
500
+ from .verifiers import SyncVerifierFunction
507
501
 
508
502
  # Use verifier_from_string to create the verifier
509
503
  verifier_func = verifier_from_string(
@@ -513,12 +507,6 @@ class Fleet:
513
507
  sha256=verifier_sha,
514
508
  )
515
509
 
516
- # Ensure we return an AsyncVerifierFunction
517
- if not isinstance(verifier_func, SyncVerifierFunction):
518
- raise TypeError(
519
- f"Expected AsyncVerifierFunction but got {type(verifier_func).__name__}"
520
- )
521
-
522
510
  # Store the original verifier code for reference
523
511
  verifier_func._verifier_code = verifier_code
524
512
 
fleet/env/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  from .client import (
4
4
  make,
5
- make_for_task,
5
+ make_for_task_async,
6
6
  list_envs,
7
7
  list_regions,
8
8
  get,
@@ -22,7 +22,7 @@ from .._async.env.client import (
22
22
 
23
23
  __all__ = [
24
24
  "make",
25
- "make_for_task",
25
+ "make_for_task_async",
26
26
  "list_envs",
27
27
  "list_regions",
28
28
  "list_instances",
fleet/global_client.py CHANGED
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from typing import Optional
4
4
 
5
5
  from .client import Fleet
6
- from ..config import DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT
6
+ from .config import DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT
7
7
 
8
8
 
9
9
  _default_client: Optional[Fleet] = None
fleet/tasks.py CHANGED
@@ -124,6 +124,56 @@ class Task(BaseModel):
124
124
  return Fleet().make(env_key=self.env_key, region=region)
125
125
 
126
126
 
127
+ def verifier_from_string(
128
+ verifier_func: str,
129
+ verifier_id: str,
130
+ verifier_key: str,
131
+ sha256: str = ""
132
+ ) -> 'VerifierFunction':
133
+ """Create a verifier function from string code.
134
+
135
+ Args:
136
+ verifier_func: The verifier function code as a string
137
+ verifier_id: Unique identifier for the verifier
138
+ verifier_key: Key/name for the verifier
139
+ sha256: SHA256 hash of the verifier code
140
+
141
+ Returns:
142
+ VerifierFunction instance that can be used to verify tasks
143
+ """
144
+ try:
145
+ import inspect
146
+ from .verifiers import verifier, SyncVerifierFunction
147
+
148
+ # Create a local namespace for executing the code
149
+ local_namespace = {}
150
+
151
+ # Execute the verifier code in the namespace
152
+ exec(verifier_func, globals(), local_namespace)
153
+
154
+ # Find the function that was defined
155
+ func_obj = None
156
+ for name, obj in local_namespace.items():
157
+ if inspect.isfunction(obj):
158
+ func_obj = obj
159
+ break
160
+
161
+ if func_obj is None:
162
+ raise ValueError("No function found in verifier code")
163
+
164
+ # Create an AsyncVerifierFunction instance
165
+ verifier_instance = SyncVerifierFunction(func_obj, verifier_key, verifier_id)
166
+
167
+ # Store additional metadata
168
+ verifier_instance._verifier_code = verifier_func
169
+ verifier_instance._sha256 = sha256
170
+
171
+ return verifier_instance
172
+
173
+ except Exception as e:
174
+ raise ValueError(f"Failed to create verifier from string: {e}")
175
+
176
+
127
177
  def load_tasks(
128
178
  env_key: Optional[str] = None,
129
179
  keys: Optional[List[str]] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.34
3
+ Version: 0.2.35
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -19,22 +19,22 @@ examples/openai_simple_example.py,sha256=HmiufucrAZne7tHq9uoEsDWlEhjNC265bQAyIGB
19
19
  examples/query_builder_example.py,sha256=-cOMfWGNifYfYEt_Ds73XpwATZvFDL6F4KTkVxdMjzg,3951
20
20
  examples/quickstart.py,sha256=1VT39IRRhemsJgxi0O0gprdpcw7HB4pYO97GAYagIcg,3788
21
21
  examples/test_cdp_logging.py,sha256=AkCwQCgOTQEI8w3v0knWK_4eXMph7L9x07wj9yIYM10,2836
22
- fleet/__init__.py,sha256=LYJ8zS6Ldo5wLpRqsFMoiikkyosTmm7sRTUY4SnJAgE,3880
22
+ fleet/__init__.py,sha256=F6PrtihwOKZxmaOkeHmGLBM3feTpRTEDT5tSqeSD7ts,3749
23
23
  fleet/base.py,sha256=bc-340sTpq_DJs7yQ9d2pDWnmJFmA1SwDB9Lagvqtb4,9182
24
- fleet/client.py,sha256=JG9soTIkGK_uRezHU79PFn7PBXeN1iNpun1D4JDFTyE,22310
24
+ fleet/client.py,sha256=63tZ9favxVgDYrOpurVltuE4SHxr6BmV387Ugg6_PFo,21794
25
25
  fleet/config.py,sha256=uY02ZKxVoXqVDta-0IMWaYJeE1CTXF_fA9NI6QUutmU,319
26
26
  fleet/exceptions.py,sha256=fUmPwWhnT8SR97lYsRq0kLHQHKtSh2eJS0VQ2caSzEI,5055
27
- fleet/global_client.py,sha256=oSWhV1cggVKQ0ec0YDOGu6Zr0Tgdcx3oKMM6s2Y9fQw,1073
27
+ fleet/global_client.py,sha256=frrDAFNM2ywN0JHLtlm9qbE1dQpnQJsavJpb7xSR_bU,1072
28
28
  fleet/models.py,sha256=9tDjgcgKPMnf-R_MDh-Ocp_UMbyJ8tJyjb15XqU0N94,12454
29
- fleet/tasks.py,sha256=1AlNhe0WRggj3pIwTeaxMhpmMqI0MGBVjEmODVu37YI,5648
29
+ fleet/tasks.py,sha256=vLFHHzgk7BBvDzGY1urEB_bzPaoV-kxNdRIFDttVqXo,7245
30
30
  fleet/types.py,sha256=L4Y82xICf1tzyCLqhLYUgEoaIIS5h9T05TyFNHSWs3s,652
31
- fleet/_async/__init__.py,sha256=1X00u-0Zu4S-e8MGE9nJWbZEt3H-DHZA-gfwN-JuP2U,7415
31
+ fleet/_async/__init__.py,sha256=Jgy63JiZQxArfEHLz8JrYR1_ne9IzgSY3fVP8nmZ40Y,6581
32
32
  fleet/_async/base.py,sha256=oisVTQsx0M_yTmyQJc3oij63uKZ97MHz-xYFsWXxQE8,9202
33
- fleet/_async/client.py,sha256=cX5eFE4J1nfdXddarc2HcNQpBYzQejlVWwbM2n3URlg,22497
33
+ fleet/_async/client.py,sha256=fyjr5LLPAntUmd5e9vG6n9Mx25tBFMIX-kQHS8FcPHc,22253
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=9tDjgcgKPMnf-R_MDh-Ocp_UMbyJ8tJyjb15XqU0N94,12454
37
- fleet/_async/tasks.py,sha256=jHGAvMkR3byayR429YSDiiIDV3W30y4UHZf9W6UhA8M,5721
37
+ fleet/_async/tasks.py,sha256=hyBn2QWobcvG1k5snxxvYqohmpSv43iRghA-g6jx8Ro,7320
38
38
  fleet/_async/env/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  fleet/_async/env/client.py,sha256=Fx4jVEGlM4JB_pgk9lZutzPAOgp6Yi3vxt3waMPrMvM,971
40
40
  fleet/_async/instance/__init__.py,sha256=PtmJq8J8bh0SOQ2V55QURz5GJfobozwtQoqhaOk3_tI,515
@@ -48,7 +48,7 @@ fleet/_async/resources/sqlite.py,sha256=h6pX41j8_aJaeZ7UVs25QQGgMWbHMPlGpDnPGMIA
48
48
  fleet/_async/verifiers/__init__.py,sha256=1WTlCNq4tIFbbXaQu5Bf2WppZq0A8suhtZbxMTSOwxI,465
49
49
  fleet/_async/verifiers/bundler.py,sha256=Sq0KkqEhM5Ng2x8R6Z4puXvQ8FMlEO7D3-ldBLktPi4,26205
50
50
  fleet/_async/verifiers/verifier.py,sha256=lwVIV5ZpWJhM87tXShtjwN5KP7n5XDcPq0XX7AjV6_E,14343
51
- fleet/env/__init__.py,sha256=6-zgP705M61tCquiDKw29dBZGq1US9mtsB1gQngJ4FQ,664
51
+ fleet/env/__init__.py,sha256=cS9zCYobM5jypppDMZIQMYd6hOg5f4sgqRXEQ67pckk,676
52
52
  fleet/env/client.py,sha256=I4pjnXGzifZSr7iZFdn0cTX6nLuGYo-sCt-qk4ez29Y,805
53
53
  fleet/instance/__init__.py,sha256=CyWUkbGAK-DBPw4DC4AnCW-MqqheGhZMA5QSRVu-ws4,479
54
54
  fleet/instance/base.py,sha256=OYqzBwZFfTX9wlBGSG5gljqj98NbiJeKIfFJ3uj5I4s,1587
@@ -67,10 +67,10 @@ fleet/verifiers/decorator.py,sha256=nAP3O8szXu7md_kpwpz91hGSUNEVLYjwZQZTkQlV1DM,
67
67
  fleet/verifiers/parse.py,sha256=0bAbj9VvT__yU4ZVREUK-Tn9dukh9LCpmfVsgj1DfP4,8508
68
68
  fleet/verifiers/sql_differ.py,sha256=dmiGCFXVMEMbAX519OjhVqgA8ZvhnvdmC1BVpL7QCF0,6490
69
69
  fleet/verifiers/verifier.py,sha256=53oBWAf0yy3bZmZx9eH9AWIf65H7OP2UUm0YwWCL6Mc,14286
70
- fleet_python-0.2.34.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
70
+ fleet_python-0.2.35.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
71
71
  scripts/fix_sync_imports.py,sha256=0XKTkAV7WdMxRfk8-x4Ts1LjSbUpyI0tPL0DcTQ_38w,7308
72
72
  scripts/unasync.py,sha256=vWVQxRWX8SRZO5cmzEhpvnG_REhCWXpidIGIpWmEcvI,696
73
- fleet_python-0.2.34.dist-info/METADATA,sha256=WmolSCZR49qXHttFTyPhRnEJxj6po_YbDeUhOnk4t9M,3354
74
- fleet_python-0.2.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- fleet_python-0.2.34.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
- fleet_python-0.2.34.dist-info/RECORD,,
73
+ fleet_python-0.2.35.dist-info/METADATA,sha256=jr2ZZiRPFV_mfy-Fy4OrAzDPllhNGDo1_Ku6B86t_Uc,3354
74
+ fleet_python-0.2.35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ fleet_python-0.2.35.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
+ fleet_python-0.2.35.dist-info/RECORD,,