fleet-python 0.2.44__py3-none-any.whl → 0.2.45__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/tasks.py CHANGED
@@ -24,7 +24,9 @@ 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(
27
- None, description="Verifier function with decorator (async or sync)"
27
+ None,
28
+ description="Verifier function with decorator (async or sync)",
29
+ exclude=True # Exclude from JSON serialization
28
30
  )
29
31
  verifier_id: Optional[str] = Field(None, description="Verifier identifier")
30
32
  verifier_sha: Optional[str] = Field(None, description="Verifier SHA256 hash")
@@ -63,6 +65,10 @@ class Task(BaseModel):
63
65
  For sync environments, calls the sync verifier directly.
64
66
  For async verifiers, automatically runs them with asyncio.run().
65
67
  """
68
+ # If verifier doesn't exist but verifier_func does, rebuild it
69
+ if not self.verifier and self.verifier_func:
70
+ self._rebuild_verifier()
71
+
66
72
  if self.verifier:
67
73
  import asyncio
68
74
  import inspect
@@ -93,6 +99,10 @@ class Task(BaseModel):
93
99
  For async environments, awaits the async verifier.
94
100
  Works with both sync and async verifiers in async contexts.
95
101
  """
102
+ # If verifier doesn't exist but verifier_func does, rebuild it
103
+ if not self.verifier and self.verifier_func:
104
+ self._rebuild_verifier()
105
+
96
106
  if self.verifier:
97
107
  result = self.verifier.remote(*args, **kwargs)
98
108
  # If it's a coroutine, await it
@@ -105,6 +115,19 @@ class Task(BaseModel):
105
115
  else:
106
116
  raise ValueError("No verifier function found for this task")
107
117
 
118
+ def _rebuild_verifier(self):
119
+ """Rebuild the verifier from verifier_func string if it exists."""
120
+ if self.verifier_func:
121
+ # Use the same logic as in verifier_from_string
122
+ verifier_id = self.verifier_id or self.key
123
+ verifier = verifier_from_string(
124
+ verifier_func=self.verifier_func,
125
+ verifier_id=verifier_id,
126
+ verifier_key=self.key,
127
+ sha256=self.verifier_sha or "",
128
+ )
129
+ self.verifier = verifier
130
+
108
131
  async def make_env(self, region: Optional[str] = None):
109
132
  """Create an environment instance for this task's environment.
110
133
 
fleet/tasks.py CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import re
6
5
  import asyncio
7
6
  from datetime import datetime
8
7
  from typing import Any, Dict, Optional, List
9
- from uuid import UUID
10
8
 
11
9
  from pydantic import BaseModel, Field, validator
12
10
 
@@ -27,7 +25,9 @@ class Task(BaseModel):
27
25
  version: Optional[str] = Field(None, description="Task version")
28
26
  verifier_func: Optional[str] = Field(None, description="Verifier function code")
29
27
  verifier: Optional[Any] = Field(
30
- None, description="Verifier function with decorator (async or sync)"
28
+ None,
29
+ description="Verifier function with decorator (async or sync)",
30
+ exclude=True,
31
31
  )
32
32
  verifier_id: Optional[str] = Field(None, description="Verifier identifier")
33
33
  verifier_sha: Optional[str] = Field(None, description="Verifier SHA256 hash")
@@ -66,6 +66,10 @@ class Task(BaseModel):
66
66
  For sync environments, calls the sync verifier directly.
67
67
  For async verifiers, automatically runs them with asyncio.run().
68
68
  """
69
+ # If verifier doesn't exist but verifier_func does, rebuild it
70
+ if not self.verifier and self.verifier_func:
71
+ self._rebuild_verifier()
72
+
69
73
  if self.verifier:
70
74
  import inspect
71
75
 
@@ -96,6 +100,10 @@ class Task(BaseModel):
96
100
  For async environments, awaits the async verifier.
97
101
  Works with both sync and async verifiers in async contexts.
98
102
  """
103
+ # If verifier doesn't exist but verifier_func does, rebuild it
104
+ if not self.verifier and self.verifier_func:
105
+ self._rebuild_verifier()
106
+
99
107
  if self.verifier:
100
108
  result = self.verifier.remote(*args, **kwargs)
101
109
  # If it's a coroutine, await it
@@ -108,6 +116,19 @@ class Task(BaseModel):
108
116
  else:
109
117
  raise ValueError("No verifier function found for this task")
110
118
 
119
+ def _rebuild_verifier(self):
120
+ """Rebuild the verifier from verifier_func string if it exists."""
121
+ if self.verifier_func:
122
+ # Use the same logic as in verifier_from_string
123
+ verifier_id = self.verifier_id or self.key
124
+ verifier = verifier_from_string(
125
+ verifier_func=self.verifier_func,
126
+ verifier_id=verifier_id,
127
+ verifier_key=self.key,
128
+ sha256=self.verifier_sha or "",
129
+ )
130
+ self.verifier = verifier
131
+
111
132
  def make_env(self, region: Optional[str] = None):
112
133
  """Create an environment instance for this task's environment.
113
134
 
@@ -245,7 +266,6 @@ def update_task(
245
266
  response = fleet.update_task("my-task", verifier_code="def verify(env): return True")
246
267
  """
247
268
  from .global_client import get_client
248
- from .models import TaskResponse
249
269
 
250
270
  client = get_client()
251
271
  return client.update_task(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.44
3
+ Version: 0.2.45
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -26,7 +26,7 @@ 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=WAiRXa68aXSVbCqmQMn36n9cSlls6YsicV6BbyoeiYQ,12750
29
- fleet/tasks.py,sha256=F1rKm-dCz4taVtEr8DoIF3fty83KQNpbYnR_nFDjiBk,8819
29
+ fleet/tasks.py,sha256=3VKk3g1gXXhy-N9QnDq2eTdNK9rJENn_N6_TKZU-uvY,9634
30
30
  fleet/types.py,sha256=L4Y82xICf1tzyCLqhLYUgEoaIIS5h9T05TyFNHSWs3s,652
31
31
  fleet/_async/__init__.py,sha256=7C_JaEHoqZ4cddsCmlJ4z-UaU6Kr2CBZSgwx5B6fqnc,6765
32
32
  fleet/_async/base.py,sha256=oisVTQsx0M_yTmyQJc3oij63uKZ97MHz-xYFsWXxQE8,9202
@@ -34,7 +34,7 @@ fleet/_async/client.py,sha256=ub6YGR8tBIEob3z5u8F0x0fktUYiVet87RN8iqJiY2I,27306
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=li5Cii7ASUHCFMFeJIMklyicYczqPez768RxO0Q0F2o,12618
37
- fleet/_async/tasks.py,sha256=R0xStgxY5hLQD6oMC_GItblUspaMDXu4yXeEuiHrKXY,8469
37
+ fleet/_async/tasks.py,sha256=TAS7IkSsS8rTW34blTaEPuWzuBqe8NezLpz1ozjP82M,9416
38
38
  fleet/_async/env/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  fleet/_async/env/client.py,sha256=8dS42VvSgdqfuh96l6cyiLZlKElilmfTeRSZ4LZnFuE,1143
40
40
  fleet/_async/instance/__init__.py,sha256=PtmJq8J8bh0SOQ2V55QURz5GJfobozwtQoqhaOk3_tI,515
@@ -67,10 +67,10 @@ fleet/verifiers/decorator.py,sha256=nAP3O8szXu7md_kpwpz91hGSUNEVLYjwZQZTkQlV1DM,
67
67
  fleet/verifiers/parse.py,sha256=IaROVGmtmilsHQp2sMoJUJcB7tATLLsoHdF0TTWcoC0,8541
68
68
  fleet/verifiers/sql_differ.py,sha256=TqTLWyK3uOyLbitT6HYzYEzuSFC39wcyhgk3rcm__k8,6525
69
69
  fleet/verifiers/verifier.py,sha256=WViDlhEU9OEwWBjp7fvIW0-HltpuFcuXfzGazQnJUuw,14380
70
- fleet_python-0.2.44.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
70
+ fleet_python-0.2.45.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.44.dist-info/METADATA,sha256=aF5qWt31x7QQsPvX8DPHVB9DfxtNInK5pkTA-29S55I,3304
74
- fleet_python-0.2.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- fleet_python-0.2.44.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
- fleet_python-0.2.44.dist-info/RECORD,,
73
+ fleet_python-0.2.45.dist-info/METADATA,sha256=po9K7F5ILTQzLIR95WWM1l7seIpd68Mby99ggmdkgk0,3304
74
+ fleet_python-0.2.45.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ fleet_python-0.2.45.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
76
+ fleet_python-0.2.45.dist-info/RECORD,,