fleet-python 0.2.44__tar.gz → 0.2.46__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.

Files changed (81) hide show
  1. {fleet_python-0.2.44 → fleet_python-0.2.46}/PKG-INFO +1 -1
  2. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/tasks.py +24 -1
  3. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/verifiers/verifier.py +6 -18
  4. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/client.py +5 -0
  5. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/tasks.py +24 -4
  6. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/verifier.py +5 -18
  7. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet_python.egg-info/PKG-INFO +1 -1
  8. {fleet_python-0.2.44 → fleet_python-0.2.46}/pyproject.toml +1 -1
  9. {fleet_python-0.2.44 → fleet_python-0.2.46}/LICENSE +0 -0
  10. {fleet_python-0.2.44 → fleet_python-0.2.46}/README.md +0 -0
  11. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/diff_example.py +0 -0
  12. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/dsl_example.py +0 -0
  13. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example.py +0 -0
  14. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/exampleResume.py +0 -0
  15. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_account.py +0 -0
  16. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_action_log.py +0 -0
  17. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_client.py +0 -0
  18. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_mcp_anthropic.py +0 -0
  19. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_mcp_openai.py +0 -0
  20. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_sync.py +0 -0
  21. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_task.py +0 -0
  22. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_tasks.py +0 -0
  23. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/example_verifier.py +0 -0
  24. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/gemini_example.py +0 -0
  25. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/json_tasks_example.py +0 -0
  26. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/nova_act_example.py +0 -0
  27. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/openai_example.py +0 -0
  28. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/openai_simple_example.py +0 -0
  29. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/query_builder_example.py +0 -0
  30. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/quickstart.py +0 -0
  31. {fleet_python-0.2.44 → fleet_python-0.2.46}/examples/test_cdp_logging.py +0 -0
  32. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/__init__.py +0 -0
  33. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/__init__.py +0 -0
  34. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/base.py +0 -0
  35. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/client.py +0 -0
  36. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/env/__init__.py +0 -0
  37. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/env/client.py +0 -0
  38. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/exceptions.py +0 -0
  39. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/global_client.py +0 -0
  40. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/instance/__init__.py +0 -0
  41. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/instance/base.py +0 -0
  42. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/instance/client.py +0 -0
  43. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/models.py +0 -0
  44. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/resources/__init__.py +0 -0
  45. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/resources/base.py +0 -0
  46. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/resources/browser.py +0 -0
  47. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/resources/mcp.py +0 -0
  48. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/resources/sqlite.py +0 -0
  49. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/verifiers/__init__.py +0 -0
  50. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/_async/verifiers/bundler.py +0 -0
  51. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/base.py +0 -0
  52. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/config.py +0 -0
  53. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/env/__init__.py +0 -0
  54. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/env/client.py +0 -0
  55. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/exceptions.py +0 -0
  56. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/global_client.py +0 -0
  57. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/instance/__init__.py +0 -0
  58. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/instance/base.py +0 -0
  59. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/instance/client.py +0 -0
  60. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/instance/models.py +0 -0
  61. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/models.py +0 -0
  62. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/resources/__init__.py +0 -0
  63. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/resources/base.py +0 -0
  64. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/resources/browser.py +0 -0
  65. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/resources/mcp.py +0 -0
  66. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/resources/sqlite.py +0 -0
  67. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/types.py +0 -0
  68. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/__init__.py +0 -0
  69. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/bundler.py +0 -0
  70. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/code.py +0 -0
  71. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/db.py +0 -0
  72. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/decorator.py +0 -0
  73. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/parse.py +0 -0
  74. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet/verifiers/sql_differ.py +0 -0
  75. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet_python.egg-info/SOURCES.txt +0 -0
  76. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet_python.egg-info/dependency_links.txt +0 -0
  77. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet_python.egg-info/requires.txt +0 -0
  78. {fleet_python-0.2.44 → fleet_python-0.2.46}/fleet_python.egg-info/top_level.txt +0 -0
  79. {fleet_python-0.2.44 → fleet_python-0.2.46}/scripts/fix_sync_imports.py +0 -0
  80. {fleet_python-0.2.44 → fleet_python-0.2.46}/scripts/unasync.py +0 -0
  81. {fleet_python-0.2.44 → fleet_python-0.2.46}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.44
3
+ Version: 0.2.46
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -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
 
@@ -12,7 +12,7 @@ import uuid
12
12
  import logging
13
13
  import hashlib
14
14
  import asyncio
15
- from typing import Any, Callable, Dict, Optional, List, TypeVar, Set, Tuple
15
+ from typing import Any, Callable, Dict, Optional, List, TypeVar, Tuple
16
16
 
17
17
  from .bundler import FunctionBundler
18
18
  from ..client import AsyncEnv
@@ -21,8 +21,7 @@ logger = logging.getLogger(__name__)
21
21
 
22
22
  F = TypeVar("F", bound=Callable[..., Any])
23
23
 
24
- # Global cache to track which bundle SHAs have been uploaded to S3
25
- _uploaded_bundle_shas: Set[str] = set()
24
+ # Removed global cache - always check server for bundle status
26
25
 
27
26
 
28
27
  @functools.lru_cache(maxsize=128)
@@ -107,25 +106,16 @@ class AsyncVerifierFunction:
107
106
  logger.debug(f"Using server-side bundle {bundle_sha[:8]}...")
108
107
  return bundle_sha, False # No upload needed, server has it
109
108
 
110
- # 1. Check local process cache first
111
- if bundle_sha in _uploaded_bundle_shas:
112
- logger.debug(f"Bundle {bundle_sha[:8]}... found in local cache")
113
- return bundle_sha, False # Already uploaded, no upload needed
114
-
115
- # 2. Check if bundle exists on server (pseudocode)
116
- # TODO: Add endpoint to check if bundle SHA exists in S3
109
+ # Always check if bundle exists on server
117
110
  try:
118
111
  exists = await env.check_bundle_exists(bundle_sha)
119
112
  if exists.success:
120
- logger.info(
121
- f"Bundle {bundle_sha[:8]}... found on server, updating cache"
122
- )
123
- _uploaded_bundle_shas.add(bundle_sha)
113
+ logger.info(f"Bundle {bundle_sha[:8]}... found on server")
124
114
  return bundle_sha, False # Found on server, no upload needed
125
115
  except Exception as e:
126
116
  logger.warning(f"Failed to check bundle existence: {e}")
127
117
 
128
- # 3. Bundle not found locally or on server - upload needed
118
+ # Bundle not found on server - upload needed
129
119
  logger.info(f"Bundle {bundle_sha[:8]}... needs to be uploaded")
130
120
  return bundle_sha, True # Upload needed
131
121
 
@@ -194,9 +184,7 @@ class AsyncVerifierFunction:
194
184
  needs_upload=True,
195
185
  )
196
186
 
197
- # Mark as uploaded after successful execution
198
- _uploaded_bundle_shas.add(bundle_sha)
199
- logger.debug(f"Registered bundle {bundle_sha[:8]}... as uploaded")
187
+ logger.debug(f"Bundle {bundle_sha[:8]}... uploaded successfully")
200
188
 
201
189
  else:
202
190
  # Bundle already available - execute without upload
@@ -579,6 +579,8 @@ class Fleet:
579
579
  task = Task(**task_data)
580
580
  tasks.append(task)
581
581
 
582
+ responses = []
583
+
582
584
  for task in tasks:
583
585
  payload = TaskRequest(
584
586
  key=task.key,
@@ -592,10 +594,13 @@ class Fleet:
592
594
  response = self.client.request(
593
595
  "POST", "/v1/tasks", json=payload.model_dump()
594
596
  )
597
+ responses.append(response)
595
598
  except Exception as e:
596
599
  logger.error(f"Failed to import task {task.key}: {e}")
597
600
  continue
598
601
 
602
+ return responses
603
+
599
604
  def account(self) -> AccountResponse:
600
605
  """Get account information including instance limits and usage.
601
606
 
@@ -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(
@@ -19,7 +19,6 @@ from typing import (
19
19
  Optional,
20
20
  List,
21
21
  TypeVar,
22
- Set,
23
22
  TYPE_CHECKING,
24
23
  Tuple,
25
24
  )
@@ -33,8 +32,7 @@ logger = logging.getLogger(__name__)
33
32
 
34
33
  F = TypeVar("F", bound=Callable[..., Any])
35
34
 
36
- # Global cache to track which bundle SHAs have been uploaded to S3
37
- _uploaded_bundle_shas: Set[str] = set()
35
+ # Removed global cache - always check server for bundle status
38
36
 
39
37
 
40
38
  @functools.lru_cache(maxsize=128)
@@ -119,25 +117,16 @@ class SyncVerifierFunction:
119
117
  logger.debug(f"Using server-side bundle {bundle_sha[:8]}...")
120
118
  return bundle_sha, False # No upload needed, server has it
121
119
 
122
- # 1. Check local process cache first
123
- if bundle_sha in _uploaded_bundle_shas:
124
- logger.debug(f"Bundle {bundle_sha[:8]}... found in local cache")
125
- return bundle_sha, False # Already uploaded, no upload needed
126
-
127
- # 2. Check if bundle exists on server (pseudocode)
128
- # TODO: Add endpoint to check if bundle SHA exists in S3
120
+ # Always check if bundle exists on server
129
121
  try:
130
122
  exists = env.check_bundle_exists(bundle_sha)
131
123
  if exists.success:
132
- logger.info(
133
- f"Bundle {bundle_sha[:8]}... found on server, updating cache"
134
- )
135
- _uploaded_bundle_shas.add(bundle_sha)
124
+ logger.info(f"Bundle {bundle_sha[:8]}... found on server")
136
125
  return bundle_sha, False # Found on server, no upload needed
137
126
  except Exception as e:
138
127
  logger.warning(f"Failed to check bundle existence: {e}")
139
128
 
140
- # 3. Bundle not found locally or on server - upload needed
129
+ # Bundle not found on server - upload needed
141
130
  logger.info(f"Bundle {bundle_sha[:8]}... needs to be uploaded")
142
131
  return bundle_sha, True # Upload needed
143
132
 
@@ -206,9 +195,7 @@ class SyncVerifierFunction:
206
195
  needs_upload=True,
207
196
  )
208
197
 
209
- # Mark as uploaded after successful execution
210
- _uploaded_bundle_shas.add(bundle_sha)
211
- logger.debug(f"Registered bundle {bundle_sha[:8]}... as uploaded")
198
+ logger.debug(f"Bundle {bundle_sha[:8]}... uploaded successfully")
212
199
 
213
200
  else:
214
201
  # Bundle already available - execute without upload
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.44
3
+ Version: 0.2.46
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fleet-python"
7
- version = "0.2.44"
7
+ version = "0.2.46"
8
8
  description = "Python SDK for Fleet environments"
9
9
  authors = [
10
10
  {name = "Fleet AI", email = "nic@fleet.so"},
File without changes
File without changes
File without changes