fleet-python 0.2.37__py3-none-any.whl → 0.2.38__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/tasks.py +41 -9
- {fleet_python-0.2.37.dist-info → fleet_python-0.2.38.dist-info}/METADATA +1 -1
- {fleet_python-0.2.37.dist-info → fleet_python-0.2.38.dist-info}/RECORD +6 -6
- {fleet_python-0.2.37.dist-info → fleet_python-0.2.38.dist-info}/WHEEL +0 -0
- {fleet_python-0.2.37.dist-info → fleet_python-0.2.38.dist-info}/licenses/LICENSE +0 -0
- {fleet_python-0.2.37.dist-info → fleet_python-0.2.38.dist-info}/top_level.txt +0 -0
fleet/tasks.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import re
|
|
6
|
+
import asyncio
|
|
6
7
|
from datetime import datetime
|
|
7
8
|
from typing import Any, Dict, Optional, List
|
|
8
9
|
from uuid import UUID
|
|
@@ -73,7 +74,12 @@ class Task(BaseModel):
|
|
|
73
74
|
if self.verifier:
|
|
74
75
|
import inspect
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
# Check if verifier has remote method (for decorated verifiers)
|
|
78
|
+
if hasattr(self.verifier, 'remote'):
|
|
79
|
+
result = self.verifier.remote(env, *args, **kwargs)
|
|
80
|
+
else:
|
|
81
|
+
# For verifiers created from string, call directly
|
|
82
|
+
result = self.verifier(env, *args, **kwargs)
|
|
77
83
|
|
|
78
84
|
# If the result is a coroutine, we need to run it
|
|
79
85
|
if inspect.iscoroutine(result):
|
|
@@ -144,19 +150,23 @@ def verifier_from_string(
|
|
|
144
150
|
try:
|
|
145
151
|
import inspect
|
|
146
152
|
from .verifiers import verifier, SyncVerifierFunction
|
|
147
|
-
from
|
|
148
|
-
from
|
|
153
|
+
from .verifiers.code import TASK_SUCCESSFUL_SCORE, TASK_FAILED_SCORE
|
|
154
|
+
from .verifiers.db import IgnoreConfig
|
|
149
155
|
|
|
150
|
-
# Create a
|
|
151
|
-
|
|
156
|
+
# Create a globals namespace with all required imports
|
|
157
|
+
exec_globals = globals().copy()
|
|
158
|
+
exec_globals.update({
|
|
152
159
|
'TASK_SUCCESSFUL_SCORE': TASK_SUCCESSFUL_SCORE,
|
|
153
160
|
'TASK_FAILED_SCORE': TASK_FAILED_SCORE,
|
|
154
161
|
'IgnoreConfig': IgnoreConfig,
|
|
155
162
|
'Environment': object # Add Environment type if needed
|
|
156
|
-
}
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
# Create a local namespace for executing the code
|
|
166
|
+
local_namespace = {}
|
|
157
167
|
|
|
158
168
|
# Execute the verifier code in the namespace
|
|
159
|
-
exec(verifier_func,
|
|
169
|
+
exec(verifier_func, exec_globals, local_namespace)
|
|
160
170
|
|
|
161
171
|
# Find the function that was defined
|
|
162
172
|
func_obj = None
|
|
@@ -168,8 +178,30 @@ def verifier_from_string(
|
|
|
168
178
|
if func_obj is None:
|
|
169
179
|
raise ValueError("No function found in verifier code")
|
|
170
180
|
|
|
171
|
-
# Create
|
|
172
|
-
|
|
181
|
+
# Create a wrapper function that provides the necessary globals
|
|
182
|
+
def wrapped_verifier(env, *args, **kwargs):
|
|
183
|
+
# Set up globals for the function execution
|
|
184
|
+
func_globals = func_obj.__globals__.copy() if hasattr(func_obj, '__globals__') else {}
|
|
185
|
+
func_globals.update({
|
|
186
|
+
'TASK_SUCCESSFUL_SCORE': TASK_SUCCESSFUL_SCORE,
|
|
187
|
+
'TASK_FAILED_SCORE': TASK_FAILED_SCORE,
|
|
188
|
+
'IgnoreConfig': IgnoreConfig
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
# Create a new function with the updated globals
|
|
192
|
+
import types
|
|
193
|
+
new_func = types.FunctionType(
|
|
194
|
+
func_obj.__code__,
|
|
195
|
+
func_globals,
|
|
196
|
+
func_obj.__name__,
|
|
197
|
+
func_obj.__defaults__,
|
|
198
|
+
func_obj.__closure__
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return new_func(env, *args, **kwargs)
|
|
202
|
+
|
|
203
|
+
# Create an AsyncVerifierFunction instance with the wrapped function
|
|
204
|
+
verifier_instance = SyncVerifierFunction(wrapped_verifier, verifier_key, verifier_id)
|
|
173
205
|
|
|
174
206
|
# Store additional metadata
|
|
175
207
|
verifier_instance._verifier_code = verifier_func
|
|
@@ -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=9tDjgcgKPMnf-R_MDh-Ocp_UMbyJ8tJyjb15XqU0N94,12454
|
|
29
|
-
fleet/tasks.py,sha256=
|
|
29
|
+
fleet/tasks.py,sha256=PcqwRktjR7o7surwWCgDScFp6PMl2YguJSs8VgZYs0g,8968
|
|
30
30
|
fleet/types.py,sha256=L4Y82xICf1tzyCLqhLYUgEoaIIS5h9T05TyFNHSWs3s,652
|
|
31
31
|
fleet/_async/__init__.py,sha256=lrnDD6N9p0Oqpi_djxTnxh8I5F7nA7KNn0khciGmgpg,6747
|
|
32
32
|
fleet/_async/base.py,sha256=oisVTQsx0M_yTmyQJc3oij63uKZ97MHz-xYFsWXxQE8,9202
|
|
@@ -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.
|
|
70
|
+
fleet_python-0.2.38.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.
|
|
74
|
-
fleet_python-0.2.
|
|
75
|
-
fleet_python-0.2.
|
|
76
|
-
fleet_python-0.2.
|
|
73
|
+
fleet_python-0.2.38.dist-info/METADATA,sha256=72nH4_f7klXmhxV8TGFNHBSejrFWJFxMJHoYq75RhBc,3354
|
|
74
|
+
fleet_python-0.2.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
75
|
+
fleet_python-0.2.38.dist-info/top_level.txt,sha256=_3DSmTohvSDf3AIP_BYfGzhwO1ECFwuzg83X-wHCx3Y,23
|
|
76
|
+
fleet_python-0.2.38.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|