fleet-python 0.2.67__py3-none-any.whl → 0.2.69__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/base.py +4 -3
- fleet/_async/client.py +64 -32
- fleet/_async/env/client.py +29 -3
- fleet/_async/tasks.py +7 -2
- fleet/_async/verifiers/bundler.py +22 -21
- fleet/_async/verifiers/verifier.py +20 -19
- fleet/base.py +4 -3
- fleet/client.py +61 -30
- fleet/env/__init__.py +8 -0
- fleet/env/client.py +29 -3
- fleet/models.py +2 -0
- fleet/tasks.py +7 -2
- fleet/verifiers/bundler.py +22 -21
- fleet/verifiers/decorator.py +1 -1
- fleet/verifiers/verifier.py +20 -19
- {fleet_python-0.2.67.dist-info → fleet_python-0.2.69.dist-info}/METADATA +1 -1
- {fleet_python-0.2.67.dist-info → fleet_python-0.2.69.dist-info}/RECORD +20 -20
- {fleet_python-0.2.67.dist-info → fleet_python-0.2.69.dist-info}/WHEEL +0 -0
- {fleet_python-0.2.67.dist-info → fleet_python-0.2.69.dist-info}/licenses/LICENSE +0 -0
- {fleet_python-0.2.67.dist-info → fleet_python-0.2.69.dist-info}/top_level.txt +0 -0
fleet/client.py
CHANGED
|
@@ -212,6 +212,7 @@ class Fleet:
|
|
|
212
212
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
213
213
|
image_type: Optional[str] = None,
|
|
214
214
|
ttl_seconds: Optional[int] = None,
|
|
215
|
+
run_id: Optional[str] = None,
|
|
215
216
|
) -> SyncEnv:
|
|
216
217
|
if ":" in env_key:
|
|
217
218
|
env_key_part, env_version = env_key.split(":", 1)
|
|
@@ -247,6 +248,7 @@ class Fleet:
|
|
|
247
248
|
image_type=image_type,
|
|
248
249
|
created_from="sdk",
|
|
249
250
|
ttl_seconds=ttl_seconds,
|
|
251
|
+
run_id=run_id,
|
|
250
252
|
)
|
|
251
253
|
|
|
252
254
|
# Only use region-specific base URL if no custom base URL is set
|
|
@@ -269,13 +271,15 @@ class Fleet:
|
|
|
269
271
|
return self.make(env_key=f"{task.env_id}:{task.version}")
|
|
270
272
|
|
|
271
273
|
def instances(
|
|
272
|
-
self, status: Optional[str] = None, region: Optional[str] = None
|
|
274
|
+
self, status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
273
275
|
) -> List[SyncEnv]:
|
|
274
276
|
params = {}
|
|
275
277
|
if status:
|
|
276
278
|
params["status"] = status
|
|
277
279
|
if region:
|
|
278
280
|
params["region"] = region
|
|
281
|
+
if run_id:
|
|
282
|
+
params["run_id"] = run_id
|
|
279
283
|
|
|
280
284
|
response = self.client.request("GET", "/v1/env/instances", params=params)
|
|
281
285
|
return [
|
|
@@ -300,6 +304,28 @@ class Fleet:
|
|
|
300
304
|
def delete(self, instance_id: str) -> InstanceResponse:
|
|
301
305
|
return _delete_instance(self.client, instance_id)
|
|
302
306
|
|
|
307
|
+
def close(self, instance_id: str) -> InstanceResponse:
|
|
308
|
+
"""Close (delete) a specific instance by ID.
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
instance_id: The instance ID to close
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
InstanceResponse containing the deleted instance details
|
|
315
|
+
"""
|
|
316
|
+
return _delete_instance(self.client, instance_id)
|
|
317
|
+
|
|
318
|
+
def close_all(self, run_id: str) -> List[InstanceResponse]:
|
|
319
|
+
"""Close (delete) all instances associated with a run_id.
|
|
320
|
+
|
|
321
|
+
Args:
|
|
322
|
+
run_id: The run ID whose instances should be closed
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
List[InstanceResponse] containing the deleted instances
|
|
326
|
+
"""
|
|
327
|
+
return _delete_instances_by_run_id(self.client, run_id)
|
|
328
|
+
|
|
303
329
|
def load_tasks_from_file(self, filename: str) -> List[Task]:
|
|
304
330
|
with open(filename, "r", encoding="utf-8") as f:
|
|
305
331
|
tasks_data = f.read()
|
|
@@ -378,8 +404,8 @@ class Fleet:
|
|
|
378
404
|
error_msg = f"Failed to create verifier {task_json.get('key', task_json.get('id'))}: {e}"
|
|
379
405
|
if raise_on_verifier_error:
|
|
380
406
|
raise ValueError(error_msg) from e
|
|
381
|
-
else:
|
|
382
|
-
|
|
407
|
+
# else:
|
|
408
|
+
# logger.warning(error_msg)
|
|
383
409
|
|
|
384
410
|
task = Task(
|
|
385
411
|
key=task_json.get("key", task_json.get("id")),
|
|
@@ -469,23 +495,23 @@ class Fleet:
|
|
|
469
495
|
verifier_sha=tr.verifier.sha256,
|
|
470
496
|
)
|
|
471
497
|
except Exception as e:
|
|
472
|
-
logger.warning(
|
|
473
|
-
|
|
474
|
-
)
|
|
498
|
+
# logger.warning(
|
|
499
|
+
# f"Failed to create verifier {tr.verifier.key}: {e}"
|
|
500
|
+
# )
|
|
475
501
|
return None
|
|
476
502
|
else:
|
|
477
503
|
# Fallback: try fetching by ID
|
|
478
504
|
try:
|
|
479
|
-
logger.warning(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
)
|
|
505
|
+
# logger.warning(
|
|
506
|
+
# f"Embedded verifier code missing for {tr.verifier.key} (NoSuchKey). "
|
|
507
|
+
# f"Attempting to refetch by id {tr.verifier.verifier_id}"
|
|
508
|
+
# )
|
|
483
509
|
return self._load_verifier(tr.verifier.verifier_id)
|
|
484
510
|
except Exception as e:
|
|
485
|
-
logger.warning(
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
)
|
|
511
|
+
# logger.warning(
|
|
512
|
+
# f"Refetch by verifier id failed for {tr.verifier.key}: {e}. "
|
|
513
|
+
# "Leaving verifier unset."
|
|
514
|
+
# )
|
|
489
515
|
return None
|
|
490
516
|
|
|
491
517
|
# Add the task for parallel execution
|
|
@@ -525,7 +551,7 @@ class Fleet:
|
|
|
525
551
|
result = future.result()
|
|
526
552
|
verifier_results.append(result)
|
|
527
553
|
except Exception as e:
|
|
528
|
-
logger.warning(f"Verifier loading failed: {e}")
|
|
554
|
+
# logger.warning(f"Verifier loading failed: {e}")
|
|
529
555
|
verifier_results.append(None)
|
|
530
556
|
|
|
531
557
|
# Build tasks with results
|
|
@@ -612,10 +638,10 @@ class Fleet:
|
|
|
612
638
|
with open(filename, "w", encoding="utf-8") as f:
|
|
613
639
|
json.dump(tasks_data, f, indent=2, default=str)
|
|
614
640
|
|
|
615
|
-
logger.info(f"Exported {len(tasks)} tasks to {filename}")
|
|
641
|
+
# logger.info(f"Exported {len(tasks)} tasks to {filename}")
|
|
616
642
|
return filename
|
|
617
643
|
else:
|
|
618
|
-
logger.info("No tasks found to export")
|
|
644
|
+
# logger.info("No tasks found to export")
|
|
619
645
|
return None
|
|
620
646
|
|
|
621
647
|
def import_single_task(self, task: Task, project_key: Optional[str] = None):
|
|
@@ -644,7 +670,7 @@ class Fleet:
|
|
|
644
670
|
)
|
|
645
671
|
return response
|
|
646
672
|
except Exception as e:
|
|
647
|
-
logger.error(f"Failed to import task {task.key}: {e}")
|
|
673
|
+
# logger.error(f"Failed to import task {task.key}: {e}")
|
|
648
674
|
return None
|
|
649
675
|
|
|
650
676
|
def import_tasks(self, filename: str, project_key: Optional[str] = None):
|
|
@@ -810,6 +836,11 @@ def _delete_instance(client: SyncWrapper, instance_id: str) -> InstanceResponse:
|
|
|
810
836
|
return InstanceResponse(**response.json())
|
|
811
837
|
|
|
812
838
|
|
|
839
|
+
def _delete_instances_by_run_id(client: SyncWrapper, run_id: str) -> List[InstanceResponse]:
|
|
840
|
+
response = client.request("DELETE", f"/v1/env/instances/run/{run_id}")
|
|
841
|
+
return [InstanceResponse(**instance_data) for instance_data in response.json()]
|
|
842
|
+
|
|
843
|
+
|
|
813
844
|
def _check_bundle_exists(
|
|
814
845
|
client: SyncWrapper, bundle_hash: str
|
|
815
846
|
) -> VerifiersCheckResponse:
|
|
@@ -852,17 +883,17 @@ def _execute_verifier_remote(
|
|
|
852
883
|
request_data["bundle"] = bundle_b64
|
|
853
884
|
|
|
854
885
|
# Debug logging
|
|
855
|
-
logger.debug(
|
|
856
|
-
|
|
857
|
-
)
|
|
858
|
-
logger.debug(f"Request has bundle: {needs_upload}")
|
|
859
|
-
logger.debug(f"Using client with base_url: {client.base_url}")
|
|
860
|
-
logger.debug(f"Request data keys: {list(request_data.keys())}")
|
|
861
|
-
logger.debug(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
)
|
|
886
|
+
# logger.debug(
|
|
887
|
+
# f"Sending verifier execute request: key={key}, sha256={bundle_sha[:8]}..., function_name={function_name}"
|
|
888
|
+
# )
|
|
889
|
+
# logger.debug(f"Request has bundle: {needs_upload}")
|
|
890
|
+
# logger.debug(f"Using client with base_url: {client.base_url}")
|
|
891
|
+
# logger.debug(f"Request data keys: {list(request_data.keys())}")
|
|
892
|
+
# logger.debug(
|
|
893
|
+
# f"Bundle size: {len(request_data.get('bundle', ''))} chars"
|
|
894
|
+
# if "bundle" in request_data
|
|
895
|
+
# else "No bundle"
|
|
896
|
+
# )
|
|
866
897
|
|
|
867
898
|
# Note: This should be called on the instance URL, not the orchestrator
|
|
868
899
|
# The instance has manager URLs for verifier execution
|
|
@@ -870,6 +901,6 @@ def _execute_verifier_remote(
|
|
|
870
901
|
|
|
871
902
|
# Debug the response
|
|
872
903
|
response_json = response.json()
|
|
873
|
-
logger.debug(f"Verifier execute response: {response_json}")
|
|
904
|
+
# logger.debug(f"Verifier execute response: {response_json}")
|
|
874
905
|
|
|
875
906
|
return VerifiersExecuteResponse(**response_json)
|
fleet/env/__init__.py
CHANGED
|
@@ -7,6 +7,8 @@ from .client import (
|
|
|
7
7
|
list_regions,
|
|
8
8
|
get,
|
|
9
9
|
list_instances,
|
|
10
|
+
close,
|
|
11
|
+
close_all,
|
|
10
12
|
account,
|
|
11
13
|
)
|
|
12
14
|
|
|
@@ -17,6 +19,8 @@ from .._async.env.client import (
|
|
|
17
19
|
list_regions_async,
|
|
18
20
|
get_async,
|
|
19
21
|
list_instances_async,
|
|
22
|
+
close_async,
|
|
23
|
+
close_all_async,
|
|
20
24
|
account_async,
|
|
21
25
|
)
|
|
22
26
|
|
|
@@ -27,11 +31,15 @@ __all__ = [
|
|
|
27
31
|
"list_regions",
|
|
28
32
|
"list_instances",
|
|
29
33
|
"get",
|
|
34
|
+
"close",
|
|
35
|
+
"close_all",
|
|
30
36
|
"make_async",
|
|
31
37
|
"list_envs_async",
|
|
32
38
|
"list_regions_async",
|
|
33
39
|
"list_instances_async",
|
|
34
40
|
"get_async",
|
|
41
|
+
"close_async",
|
|
42
|
+
"close_all_async",
|
|
35
43
|
"account",
|
|
36
44
|
"account_async",
|
|
37
45
|
]
|
fleet/env/client.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ..client import Fleet, SyncEnv, Task
|
|
2
|
-
from ..models import Environment as EnvironmentModel, AccountResponse
|
|
2
|
+
from ..models import Environment as EnvironmentModel, AccountResponse, InstanceResponse
|
|
3
3
|
from typing import List, Optional, Dict, Any
|
|
4
4
|
|
|
5
5
|
|
|
@@ -10,6 +10,7 @@ def make(
|
|
|
10
10
|
env_variables: Optional[Dict[str, Any]] = None,
|
|
11
11
|
image_type: Optional[str] = None,
|
|
12
12
|
ttl_seconds: Optional[int] = None,
|
|
13
|
+
run_id: Optional[str] = None,
|
|
13
14
|
) -> SyncEnv:
|
|
14
15
|
return Fleet().make(
|
|
15
16
|
env_key,
|
|
@@ -18,6 +19,7 @@ def make(
|
|
|
18
19
|
env_variables=env_variables,
|
|
19
20
|
image_type=image_type,
|
|
20
21
|
ttl_seconds=ttl_seconds,
|
|
22
|
+
run_id=run_id,
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
|
|
@@ -34,14 +36,38 @@ def list_regions() -> List[str]:
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
def list_instances(
|
|
37
|
-
status: Optional[str] = None, region: Optional[str] = None
|
|
39
|
+
status: Optional[str] = None, region: Optional[str] = None, run_id: Optional[str] = None
|
|
38
40
|
) -> List[SyncEnv]:
|
|
39
|
-
return Fleet().instances(status=status, region=region)
|
|
41
|
+
return Fleet().instances(status=status, region=region, run_id=run_id)
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
def get(instance_id: str) -> SyncEnv:
|
|
43
45
|
return Fleet().instance(instance_id)
|
|
44
46
|
|
|
45
47
|
|
|
48
|
+
def close(instance_id: str) -> InstanceResponse:
|
|
49
|
+
"""Close (delete) a specific instance by ID.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
instance_id: The instance ID to close
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
InstanceResponse containing the deleted instance details
|
|
56
|
+
"""
|
|
57
|
+
return Fleet().close(instance_id)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def close_all(run_id: str) -> List[InstanceResponse]:
|
|
61
|
+
"""Close (delete) all instances associated with a run_id.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
run_id: The run ID whose instances should be closed
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
List[InstanceResponse] containing the deleted instances
|
|
68
|
+
"""
|
|
69
|
+
return Fleet().close_all(run_id)
|
|
70
|
+
|
|
71
|
+
|
|
46
72
|
def account() -> AccountResponse:
|
|
47
73
|
return Fleet().account()
|
fleet/models.py
CHANGED
|
@@ -51,6 +51,7 @@ class Instance(BaseModel):
|
|
|
51
51
|
team_id: str = Field(..., title="Team Id")
|
|
52
52
|
region: str = Field(..., title="Region")
|
|
53
53
|
env_variables: Optional[Dict[str, Any]] = Field(None, title="Env Variables")
|
|
54
|
+
run_id: Optional[str] = Field(None, title="Run Id")
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
class InstanceRequest(BaseModel):
|
|
@@ -363,6 +364,7 @@ class InstanceResponse(BaseModel):
|
|
|
363
364
|
data_version: Optional[str] = Field(None, title="Data Version")
|
|
364
365
|
urls: Optional[InstanceURLs] = Field(None, title="Urls")
|
|
365
366
|
health: Optional[bool] = Field(None, title="Health")
|
|
367
|
+
run_id: Optional[str] = Field(None, title="Run Id")
|
|
366
368
|
|
|
367
369
|
|
|
368
370
|
class AccountResponse(BaseModel):
|
fleet/tasks.py
CHANGED
|
@@ -207,18 +207,20 @@ class Task(BaseModel):
|
|
|
207
207
|
region: Optional[str] = None,
|
|
208
208
|
image_type: Optional[str] = None,
|
|
209
209
|
ttl_seconds: Optional[int] = None,
|
|
210
|
+
run_id: Optional[str] = None,
|
|
210
211
|
):
|
|
211
212
|
"""Create an environment instance for this task's environment.
|
|
212
213
|
|
|
213
214
|
Alias for make() method. Uses the task's env_id (and version if present) to create the env.
|
|
214
215
|
"""
|
|
215
|
-
return self.make(region=region, image_type=image_type, ttl_seconds=ttl_seconds)
|
|
216
|
+
return self.make(region=region, image_type=image_type, ttl_seconds=ttl_seconds, run_id=run_id)
|
|
216
217
|
|
|
217
218
|
def make(
|
|
218
219
|
self,
|
|
219
220
|
region: Optional[str] = None,
|
|
220
221
|
image_type: Optional[str] = None,
|
|
221
222
|
ttl_seconds: Optional[int] = None,
|
|
223
|
+
run_id: Optional[str] = None,
|
|
222
224
|
):
|
|
223
225
|
"""Create an environment instance with task's configuration.
|
|
224
226
|
|
|
@@ -226,11 +228,13 @@ class Task(BaseModel):
|
|
|
226
228
|
- env_key (env_id + version)
|
|
227
229
|
- data_key (data_id + data_version, if present)
|
|
228
230
|
- env_variables (if present)
|
|
231
|
+
- run_id (if present)
|
|
229
232
|
|
|
230
233
|
Args:
|
|
231
234
|
region: Optional AWS region for the environment
|
|
232
235
|
image_type: Optional image type for the environment
|
|
233
236
|
ttl_seconds: Optional TTL in seconds for the instance
|
|
237
|
+
run_id: Optional run ID to group instances
|
|
234
238
|
|
|
235
239
|
Returns:
|
|
236
240
|
Environment instance configured for this task
|
|
@@ -238,7 +242,7 @@ class Task(BaseModel):
|
|
|
238
242
|
Example:
|
|
239
243
|
task = fleet.Task(key="my-task", prompt="...", env_id="my-env",
|
|
240
244
|
data_id="my-data", data_version="v1.0")
|
|
241
|
-
env = task.make(region="us-west-2")
|
|
245
|
+
env = task.make(region="us-west-2", run_id="my-batch-123")
|
|
242
246
|
"""
|
|
243
247
|
if not self.env_id:
|
|
244
248
|
raise ValueError("Task has no env_id defined")
|
|
@@ -253,6 +257,7 @@ class Task(BaseModel):
|
|
|
253
257
|
env_variables=self.env_variables if self.env_variables else None,
|
|
254
258
|
image_type=image_type,
|
|
255
259
|
ttl_seconds=ttl_seconds,
|
|
260
|
+
run_id=run_id,
|
|
256
261
|
)
|
|
257
262
|
|
|
258
263
|
|
fleet/verifiers/bundler.py
CHANGED
|
@@ -37,7 +37,7 @@ class FunctionBundler:
|
|
|
37
37
|
) -> bytes:
|
|
38
38
|
"""Create a function bundle with statically extracted code."""
|
|
39
39
|
|
|
40
|
-
logger.info(f"Creating function bundle for {func.__name__}")
|
|
40
|
+
# logger.info(f"Creating function bundle for {func.__name__}")
|
|
41
41
|
|
|
42
42
|
# 1. Parse the main function and find dependencies
|
|
43
43
|
mod_file = Path(func.__code__.co_filename)
|
|
@@ -115,7 +115,7 @@ class FunctionBundler:
|
|
|
115
115
|
|
|
116
116
|
# Find function calls within the verifier function
|
|
117
117
|
called_functions = self._extract_function_calls(main_func_ast)
|
|
118
|
-
logger.debug(f"Functions called in verifier: {called_functions}")
|
|
118
|
+
# logger.debug(f"Functions called in verifier: {called_functions}")
|
|
119
119
|
|
|
120
120
|
# Find all functions defined in the module
|
|
121
121
|
module_functions = {}
|
|
@@ -128,7 +128,7 @@ class FunctionBundler:
|
|
|
128
128
|
for func_name in called_functions:
|
|
129
129
|
if func_name in module_functions and func_name != func.__name__:
|
|
130
130
|
same_module_deps.append(func_name)
|
|
131
|
-
logger.debug(f"Found same-module dependency: {func_name}")
|
|
131
|
+
# logger.debug(f"Found same-module dependency: {func_name}")
|
|
132
132
|
|
|
133
133
|
# Separate local and external imports
|
|
134
134
|
local_imports = {}
|
|
@@ -292,7 +292,7 @@ class FunctionBundler:
|
|
|
292
292
|
code = ast.unparse(node)
|
|
293
293
|
extracted_code.append(code)
|
|
294
294
|
except Exception as e:
|
|
295
|
-
logger.warning(f"Could not unparse AST node: {e}")
|
|
295
|
+
# logger.warning(f"Could not unparse AST node: {e}")
|
|
296
296
|
# Fallback to original source extraction
|
|
297
297
|
lines = content.split("\n")
|
|
298
298
|
start_line = node.lineno - 1
|
|
@@ -305,11 +305,11 @@ class FunctionBundler:
|
|
|
305
305
|
extracted_code.append(code)
|
|
306
306
|
|
|
307
307
|
result = "\n\n".join(extracted_code)
|
|
308
|
-
logger.debug(f"Extracted {len(extracted_code)} items from {file_path}")
|
|
308
|
+
# logger.debug(f"Extracted {len(extracted_code)} items from {file_path}")
|
|
309
309
|
return result
|
|
310
310
|
|
|
311
311
|
except Exception as e:
|
|
312
|
-
logger.warning(f"Failed to extract functions from {file_path}: {e}")
|
|
312
|
+
# logger.warning(f"Failed to extract functions from {file_path}: {e}")
|
|
313
313
|
# Fallback to including the entire file
|
|
314
314
|
with open(file_path, "r", encoding="utf-8") as f:
|
|
315
315
|
return f.read()
|
|
@@ -464,14 +464,14 @@ class FunctionBundler:
|
|
|
464
464
|
version = dist.version # Get the installed version
|
|
465
465
|
package_with_version = f"{package_name}=={version}"
|
|
466
466
|
packages.add(package_with_version)
|
|
467
|
-
logger.debug(f"Mapped {mod} -> {package_with_version}")
|
|
467
|
+
# logger.debug(f"Mapped {mod} -> {package_with_version}")
|
|
468
468
|
except imd.PackageNotFoundError:
|
|
469
469
|
# Skip stdlib or local modules
|
|
470
|
-
logger.debug(f"Skipping {mod} (stdlib or local)")
|
|
470
|
+
# logger.debug(f"Skipping {mod} (stdlib or local)")
|
|
471
471
|
continue
|
|
472
472
|
|
|
473
473
|
package_list = list(packages)
|
|
474
|
-
logger.debug(f"Final package list: {package_list}")
|
|
474
|
+
# logger.debug(f"Final package list: {package_list}")
|
|
475
475
|
return package_list
|
|
476
476
|
|
|
477
477
|
def _merge_requirements(
|
|
@@ -511,10 +511,10 @@ class FunctionBundler:
|
|
|
511
511
|
if pkg_name not in seen_packages:
|
|
512
512
|
final_requirements.append(req)
|
|
513
513
|
seen_packages.add(pkg_name)
|
|
514
|
-
else:
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
514
|
+
# else:
|
|
515
|
+
# logger.debug(
|
|
516
|
+
# f"Skipping auto-detected {req}, using explicit version instead"
|
|
517
|
+
# )
|
|
518
518
|
|
|
519
519
|
# Always ensure fleet-python is included
|
|
520
520
|
if "fleet-python" not in seen_packages:
|
|
@@ -565,9 +565,9 @@ class FunctionBundler:
|
|
|
565
565
|
)
|
|
566
566
|
if dep_src:
|
|
567
567
|
same_module_code += f"\n{dep_src}\n"
|
|
568
|
-
logger.debug(
|
|
569
|
-
|
|
570
|
-
)
|
|
568
|
+
# logger.debug(
|
|
569
|
+
# f"Extracted same-module dependency: {dep_name}"
|
|
570
|
+
# )
|
|
571
571
|
|
|
572
572
|
# Create verifier.py with the main function
|
|
573
573
|
verifier_file = build_dir / "verifier.py"
|
|
@@ -586,7 +586,7 @@ class FunctionBundler:
|
|
|
586
586
|
{code}
|
|
587
587
|
"""
|
|
588
588
|
dest_path.write_text(extracted_content)
|
|
589
|
-
logger.debug(f"Created extracted file: {relative_path}")
|
|
589
|
+
# logger.debug(f"Created extracted file: {relative_path}")
|
|
590
590
|
|
|
591
591
|
# Ensure __init__.py files exist
|
|
592
592
|
self._ensure_init_files(Path(relative_path), build_dir)
|
|
@@ -595,7 +595,7 @@ class FunctionBundler:
|
|
|
595
595
|
return self._create_zip_bundle(build_dir)
|
|
596
596
|
|
|
597
597
|
except Exception as e:
|
|
598
|
-
logger.error(f"Failed to build function bundle: {e}")
|
|
598
|
+
# logger.error(f"Failed to build function bundle: {e}")
|
|
599
599
|
raise RuntimeError(f"Function bundle creation failed: {e}")
|
|
600
600
|
|
|
601
601
|
def _ensure_init_files(self, rel_path: Path, build_dir: Path):
|
|
@@ -607,7 +607,7 @@ class FunctionBundler:
|
|
|
607
607
|
if not init_file.exists():
|
|
608
608
|
init_file.parent.mkdir(parents=True, exist_ok=True)
|
|
609
609
|
init_file.write_text("# Auto-generated __init__.py")
|
|
610
|
-
logger.debug(f"Created __init__.py: {current}")
|
|
610
|
+
# logger.debug(f"Created __init__.py: {current}")
|
|
611
611
|
current = current.parent
|
|
612
612
|
|
|
613
613
|
def _create_zip_bundle(self, build_dir: Path) -> bytes:
|
|
@@ -621,7 +621,7 @@ class FunctionBundler:
|
|
|
621
621
|
zf.write(file_path, arcname)
|
|
622
622
|
|
|
623
623
|
bundle_size = len(zip_buffer.getvalue())
|
|
624
|
-
logger.debug(f"Created function bundle ({bundle_size:,} bytes)")
|
|
624
|
+
# logger.debug(f"Created function bundle ({bundle_size:,} bytes)")
|
|
625
625
|
return zip_buffer.getvalue()
|
|
626
626
|
|
|
627
627
|
def _extract_function_source(
|
|
@@ -662,7 +662,8 @@ class FunctionBundler:
|
|
|
662
662
|
return "\n".join(func_lines)
|
|
663
663
|
|
|
664
664
|
except Exception as e:
|
|
665
|
-
logger.warning(f"Failed to extract function {function_name}: {e}")
|
|
665
|
+
# logger.warning(f"Failed to extract function {function_name}: {e}")
|
|
666
|
+
pass
|
|
666
667
|
|
|
667
668
|
return None
|
|
668
669
|
|
fleet/verifiers/decorator.py
CHANGED
fleet/verifiers/verifier.py
CHANGED
|
@@ -90,9 +90,9 @@ class SyncVerifierFunction:
|
|
|
90
90
|
|
|
91
91
|
self._bundle_data = zip_buffer.getvalue()
|
|
92
92
|
self._bundle_sha = _get_bundle_sha(self._bundle_data)
|
|
93
|
-
logger.debug(
|
|
94
|
-
|
|
95
|
-
)
|
|
93
|
+
# logger.debug(
|
|
94
|
+
# f"Created bundle from raw code for {self.key} with SHA: {self._bundle_sha}"
|
|
95
|
+
# )
|
|
96
96
|
else:
|
|
97
97
|
# Try to create bundle from function source
|
|
98
98
|
try:
|
|
@@ -100,9 +100,9 @@ class SyncVerifierFunction:
|
|
|
100
100
|
self.func, self.extra_requirements, self.verifier_id
|
|
101
101
|
)
|
|
102
102
|
self._bundle_sha = _get_bundle_sha(self._bundle_data)
|
|
103
|
-
logger.debug(
|
|
104
|
-
|
|
105
|
-
)
|
|
103
|
+
# logger.debug(
|
|
104
|
+
# f"Created bundle for {self.key} with SHA: {self._bundle_sha}"
|
|
105
|
+
# )
|
|
106
106
|
except OSError as e:
|
|
107
107
|
# Can't create bundle - no source and no raw code
|
|
108
108
|
raise OSError(f"Cannot create bundle for {self.key}: {e}")
|
|
@@ -115,20 +115,21 @@ class SyncVerifierFunction:
|
|
|
115
115
|
|
|
116
116
|
# If bundle_data is empty, we're using server-side bundle
|
|
117
117
|
if not bundle_data:
|
|
118
|
-
logger.debug(f"Using server-side bundle {bundle_sha[:8]}...")
|
|
118
|
+
# logger.debug(f"Using server-side bundle {bundle_sha[:8]}...")
|
|
119
119
|
return bundle_sha, False # No upload needed, server has it
|
|
120
120
|
|
|
121
121
|
# Always check if bundle exists on server
|
|
122
122
|
try:
|
|
123
123
|
exists = env.check_bundle_exists(bundle_sha)
|
|
124
124
|
if exists.success:
|
|
125
|
-
logger.info(f"Bundle {bundle_sha[:8]}... found on server")
|
|
125
|
+
# logger.info(f"Bundle {bundle_sha[:8]}... found on server")
|
|
126
126
|
return bundle_sha, False # Found on server, no upload needed
|
|
127
127
|
except Exception as e:
|
|
128
|
-
logger.warning(f"Failed to check bundle existence: {e}")
|
|
128
|
+
# logger.warning(f"Failed to check bundle existence: {e}")
|
|
129
|
+
pass
|
|
129
130
|
|
|
130
131
|
# Bundle not found on server - upload needed
|
|
131
|
-
logger.info(f"Bundle {bundle_sha[:8]}... needs to be uploaded")
|
|
132
|
+
# logger.info(f"Bundle {bundle_sha[:8]}... needs to be uploaded")
|
|
132
133
|
return bundle_sha, True # Upload needed
|
|
133
134
|
|
|
134
135
|
def __call__(self, env: "SyncEnv", *args, **kwargs) -> float:
|
|
@@ -158,7 +159,7 @@ class SyncVerifierFunction:
|
|
|
158
159
|
)
|
|
159
160
|
|
|
160
161
|
except Exception as e:
|
|
161
|
-
logger.error(f"Error in verifier {self.key}: {e}")
|
|
162
|
+
# logger.error(f"Error in verifier {self.key}: {e}")
|
|
162
163
|
# Return error score 0
|
|
163
164
|
return 0.0
|
|
164
165
|
|
|
@@ -190,7 +191,7 @@ class SyncVerifierFunction:
|
|
|
190
191
|
try:
|
|
191
192
|
return float(result)
|
|
192
193
|
except (ValueError, TypeError):
|
|
193
|
-
logger.warning(f"Could not convert result to float: {result}")
|
|
194
|
+
# logger.warning(f"Could not convert result to float: {result}")
|
|
194
195
|
return 0.0
|
|
195
196
|
|
|
196
197
|
def _raise_remote_error(self, error_info: Dict[str, Any]):
|
|
@@ -249,7 +250,7 @@ Remote traceback:
|
|
|
249
250
|
|
|
250
251
|
if needs_upload:
|
|
251
252
|
# Need to upload bundle to S3
|
|
252
|
-
logger.info(f"Uploading bundle {bundle_sha[:8]}... for {self.key}")
|
|
253
|
+
# logger.info(f"Uploading bundle {bundle_sha[:8]}... for {self.key}")
|
|
253
254
|
bundle_data, _ = self._get_or_create_bundle()
|
|
254
255
|
|
|
255
256
|
response = env.execute_verifier_remote(
|
|
@@ -263,12 +264,12 @@ Remote traceback:
|
|
|
263
264
|
needs_upload=True,
|
|
264
265
|
)
|
|
265
266
|
|
|
266
|
-
logger.debug(f"Bundle {bundle_sha[:8]}... uploaded successfully")
|
|
267
|
+
# logger.debug(f"Bundle {bundle_sha[:8]}... uploaded successfully")
|
|
267
268
|
return response
|
|
268
269
|
|
|
269
270
|
else:
|
|
270
271
|
# Bundle already available - execute without upload
|
|
271
|
-
logger.info(f"Bundle {bundle_sha[:8]}... already cached for {self.key}")
|
|
272
|
+
# logger.info(f"Bundle {bundle_sha[:8]}... already cached for {self.key}")
|
|
272
273
|
response = env.execute_verifier_remote(
|
|
273
274
|
bundle_data=b"", # Empty bundle since it's cached
|
|
274
275
|
bundle_sha=bundle_sha,
|
|
@@ -284,9 +285,9 @@ Remote traceback:
|
|
|
284
285
|
except Exception as e:
|
|
285
286
|
# Check if error indicates bundle not found and retry with upload
|
|
286
287
|
if self._is_bundle_not_found_error(e) and not needs_upload:
|
|
287
|
-
logger.info(
|
|
288
|
-
|
|
289
|
-
)
|
|
288
|
+
# logger.info(
|
|
289
|
+
# f"Bundle {bundle_sha[:8]}... not found on server, uploading..."
|
|
290
|
+
# )
|
|
290
291
|
bundle_data, _ = self._get_or_create_bundle()
|
|
291
292
|
response = env.execute_verifier_remote(
|
|
292
293
|
bundle_data=bundle_data,
|
|
@@ -300,7 +301,7 @@ Remote traceback:
|
|
|
300
301
|
)
|
|
301
302
|
return response
|
|
302
303
|
else:
|
|
303
|
-
logger.error(f"Error in remote execution of {self.key}: {e}")
|
|
304
|
+
# logger.error(f"Error in remote execution of {self.key}: {e}")
|
|
304
305
|
raise
|
|
305
306
|
|
|
306
307
|
|