fleet-python 0.2.72b2__tar.gz → 0.2.73b1__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.
Files changed (91) hide show
  1. {fleet_python-0.2.72b2/fleet_python.egg-info → fleet_python-0.2.73b1}/PKG-INFO +1 -1
  2. fleet_python-0.2.73b1/examples/fetch_tasks.py +230 -0
  3. fleet_python-0.2.73b1/examples/iterate_verifiers.py +519 -0
  4. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/__init__.py +1 -1
  5. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/__init__.py +1 -1
  6. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/base.py +1 -1
  7. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/client.py +16 -1
  8. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/verifiers/verifier.py +5 -0
  9. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/base.py +1 -1
  10. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/client.py +16 -1
  11. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/tasks.py +4 -1
  12. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/verifier.py +5 -0
  13. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1/fleet_python.egg-info}/PKG-INFO +1 -1
  14. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet_python.egg-info/SOURCES.txt +2 -0
  15. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/pyproject.toml +1 -1
  16. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/LICENSE +0 -0
  17. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/README.md +0 -0
  18. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/diff_example.py +0 -0
  19. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/dsl_example.py +0 -0
  20. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example.py +0 -0
  21. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/exampleResume.py +0 -0
  22. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_account.py +0 -0
  23. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_action_log.py +0 -0
  24. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_client.py +0 -0
  25. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_mcp_anthropic.py +0 -0
  26. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_mcp_openai.py +0 -0
  27. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_sync.py +0 -0
  28. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_task.py +0 -0
  29. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_tasks.py +0 -0
  30. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/example_verifier.py +0 -0
  31. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/export_tasks.py +0 -0
  32. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/gemini_example.py +0 -0
  33. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/import_tasks.py +0 -0
  34. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/json_tasks_example.py +0 -0
  35. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/nova_act_example.py +0 -0
  36. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/openai_example.py +0 -0
  37. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/openai_simple_example.py +0 -0
  38. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/query_builder_example.py +0 -0
  39. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/quickstart.py +0 -0
  40. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/examples/test_cdp_logging.py +0 -0
  41. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/env/__init__.py +0 -0
  42. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/env/client.py +0 -0
  43. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/exceptions.py +0 -0
  44. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/global_client.py +0 -0
  45. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/instance/__init__.py +0 -0
  46. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/instance/base.py +0 -0
  47. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/instance/client.py +0 -0
  48. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/models.py +0 -0
  49. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/resources/__init__.py +0 -0
  50. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/resources/base.py +0 -0
  51. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/resources/browser.py +0 -0
  52. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/resources/mcp.py +0 -0
  53. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/resources/sqlite.py +0 -0
  54. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/tasks.py +0 -0
  55. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/verifiers/__init__.py +0 -0
  56. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/_async/verifiers/bundler.py +0 -0
  57. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/config.py +0 -0
  58. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/env/__init__.py +0 -0
  59. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/env/client.py +0 -0
  60. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/exceptions.py +0 -0
  61. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/global_client.py +0 -0
  62. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/instance/__init__.py +0 -0
  63. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/instance/base.py +0 -0
  64. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/instance/client.py +0 -0
  65. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/instance/models.py +0 -0
  66. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/models.py +0 -0
  67. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/resources/__init__.py +0 -0
  68. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/resources/base.py +0 -0
  69. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/resources/browser.py +0 -0
  70. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/resources/mcp.py +0 -0
  71. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/resources/sqlite.py +0 -0
  72. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/types.py +0 -0
  73. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/__init__.py +0 -0
  74. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/bundler.py +0 -0
  75. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/code.py +0 -0
  76. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/db.py +0 -0
  77. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/decorator.py +0 -0
  78. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/parse.py +0 -0
  79. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet/verifiers/sql_differ.py +0 -0
  80. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet_python.egg-info/dependency_links.txt +0 -0
  81. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet_python.egg-info/requires.txt +0 -0
  82. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/fleet_python.egg-info/top_level.txt +0 -0
  83. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/scripts/fix_sync_imports.py +0 -0
  84. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/scripts/unasync.py +0 -0
  85. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/setup.cfg +0 -0
  86. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/__init__.py +0 -0
  87. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/test_app_method.py +0 -0
  88. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/test_instance_dispatch.py +0 -0
  89. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/test_sqlite_resource_dual_mode.py +0 -0
  90. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/test_sqlite_shared_memory_behavior.py +0 -0
  91. {fleet_python-0.2.72b2 → fleet_python-0.2.73b1}/tests/test_verifier_from_string.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.72b2
3
+ Version: 0.2.73b1
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -0,0 +1,230 @@
1
+ import argparse
2
+ import asyncio
3
+ import json
4
+ import sys
5
+ from typing import List, Dict, Any, Optional, Tuple
6
+ import fleet
7
+ from dotenv import load_dotenv
8
+
9
+ load_dotenv()
10
+
11
+
12
+ async def fetch_task(
13
+ task_key: str, semaphore: asyncio.Semaphore
14
+ ) -> Tuple[str, Optional[Dict[str, Any]], Optional[str]]:
15
+ """
16
+ Fetch a single task from the Fleet API.
17
+
18
+ Args:
19
+ task_key: Task key to fetch
20
+ semaphore: Semaphore to limit concurrent requests
21
+
22
+ Returns:
23
+ Tuple of (task_key, task_data_dict, error_message)
24
+ """
25
+ async with semaphore:
26
+ try:
27
+ # Use load_tasks with keys parameter to get Task objects
28
+ tasks = await fleet.load_tasks_async(keys=[task_key])
29
+ if tasks:
30
+ task = tasks[0]
31
+ # Convert to dict using model_dump() like export_tasks.py does
32
+ return task_key, task.model_dump(), None
33
+ else:
34
+ return task_key, None, "Task not found"
35
+ except Exception as e:
36
+ error_msg = f"{type(e).__name__}: {str(e)}"
37
+ return task_key, None, error_msg
38
+
39
+
40
+ async def fetch_tasks_batch(
41
+ task_keys: List[str], max_concurrent: int = 20
42
+ ) -> Dict[str, Dict[str, Any]]:
43
+ """
44
+ Fetch multiple tasks concurrently from the Fleet API.
45
+
46
+ Args:
47
+ task_keys: List of task keys to fetch
48
+ max_concurrent: Maximum number of concurrent requests
49
+
50
+ Returns:
51
+ Dictionary mapping task_key to task data
52
+ """
53
+ print(f"\nFetching {len(task_keys)} task(s) from Fleet API...")
54
+ print(f"Max concurrent requests: {max_concurrent}")
55
+
56
+ semaphore = asyncio.Semaphore(max_concurrent)
57
+
58
+ # Fetch all tasks concurrently
59
+ results = await asyncio.gather(
60
+ *[fetch_task(key, semaphore) for key in task_keys],
61
+ return_exceptions=True,
62
+ )
63
+
64
+ # Process results
65
+ fetched_tasks = {}
66
+ errors = []
67
+
68
+ for result in results:
69
+ if isinstance(result, Exception):
70
+ errors.append(f"Unexpected error: {result}")
71
+ continue
72
+
73
+ task_key, task_data, error = result
74
+
75
+ if error:
76
+ errors.append(f"{task_key}: {error}")
77
+ print(f" ✗ {task_key}: {error}")
78
+ elif task_data:
79
+ # Task data is already a dict from model_dump()
80
+ fetched_tasks[task_key] = task_data
81
+ print(f" ✓ {task_key}")
82
+
83
+ print(f"\n✓ Successfully fetched {len(fetched_tasks)} task(s)")
84
+
85
+ if errors:
86
+ print(f"\n⚠ {len(errors)} error(s) occurred:")
87
+ for error in errors[:10]: # Show first 10
88
+ print(f" - {error}")
89
+ if len(errors) > 10:
90
+ print(f" ... and {len(errors) - 10} more")
91
+
92
+ return fetched_tasks
93
+
94
+
95
+ async def main():
96
+ parser = argparse.ArgumentParser(
97
+ description="Fetch tasks from Fleet API and update JSON file",
98
+ formatter_class=argparse.RawDescriptionHelpFormatter,
99
+ epilog="""
100
+ Examples:
101
+ # Fetch tasks and update in-place
102
+ %(prog)s tasks.json
103
+
104
+ # Fetch tasks and save to a new file
105
+ %(prog)s tasks.json --output updated_tasks.json
106
+
107
+ # Limit concurrent requests
108
+ %(prog)s tasks.json --max-concurrent 10
109
+ """,
110
+ )
111
+
112
+ parser.add_argument("json_file", help="Path to JSON file containing tasks")
113
+ parser.add_argument(
114
+ "--output",
115
+ "-o",
116
+ help="Path to output JSON file (defaults to overwriting input)",
117
+ default=None,
118
+ )
119
+ parser.add_argument(
120
+ "--max-concurrent",
121
+ "-c",
122
+ type=int,
123
+ default=20,
124
+ help="Maximum number of concurrent API requests (default: 20)",
125
+ )
126
+
127
+ args = parser.parse_args()
128
+
129
+ # Load JSON file
130
+ print(f"Reading tasks from: {args.json_file}")
131
+ try:
132
+ with open(args.json_file, "r", encoding="utf-8") as f:
133
+ tasks_data = json.load(f)
134
+ except FileNotFoundError:
135
+ print(f"✗ Error: File '{args.json_file}' not found")
136
+ sys.exit(1)
137
+ except json.JSONDecodeError as e:
138
+ print(f"✗ Error: Invalid JSON in '{args.json_file}': {e}")
139
+ sys.exit(1)
140
+
141
+ if not isinstance(tasks_data, list):
142
+ print("✗ Error: JSON file must contain an array of tasks")
143
+ sys.exit(1)
144
+
145
+ print(f"Found {len(tasks_data)} task(s) in file")
146
+
147
+ # Extract task keys
148
+ task_keys = []
149
+ missing_keys = []
150
+
151
+ for i, task in enumerate(tasks_data):
152
+ task_key = task.get("key") or task.get("id")
153
+ if task_key:
154
+ task_keys.append(task_key)
155
+ else:
156
+ missing_keys.append(f"Task at index {i}")
157
+
158
+ if missing_keys:
159
+ print(f"\n⚠ Warning: {len(missing_keys)} task(s) missing key/id:")
160
+ for key in missing_keys[:10]:
161
+ print(f" - {key}")
162
+ if len(missing_keys) > 10:
163
+ print(f" ... and {len(missing_keys) - 10} more")
164
+
165
+ if not task_keys:
166
+ print("\n✗ Error: No valid task keys found in JSON file")
167
+ sys.exit(1)
168
+
169
+ print(f"\nExtracted {len(task_keys)} task key(s)")
170
+
171
+ # Get account info
172
+ account = await fleet.env.account_async()
173
+ print(f"Fetching from team: {account.team_name}")
174
+
175
+ # Fetch tasks from API
176
+ fetched_tasks = await fetch_tasks_batch(task_keys, args.max_concurrent)
177
+
178
+ if not fetched_tasks:
179
+ print("\n✗ Error: No tasks were successfully fetched")
180
+ sys.exit(1)
181
+
182
+ # Update tasks in the original data
183
+ updated_count = 0
184
+ not_found = []
185
+
186
+ print("\nUpdating task data...")
187
+ for i, task in enumerate(tasks_data):
188
+ task_key = task.get("key") or task.get("id")
189
+
190
+ if task_key in fetched_tasks:
191
+ # Replace entire task with fetched data
192
+ tasks_data[i] = fetched_tasks[task_key]
193
+ updated_count += 1
194
+ else:
195
+ not_found.append(task_key or f"index {i}")
196
+
197
+ print(f"✓ Updated {updated_count} task(s)")
198
+
199
+ if not_found:
200
+ print(f"\n⚠ Warning: {len(not_found)} task(s) not fetched:")
201
+ for key in not_found[:10]:
202
+ print(f" - {key}")
203
+ if len(not_found) > 10:
204
+ print(f" ... and {len(not_found) - 10} more")
205
+
206
+ # Write output
207
+ output_file = args.output or args.json_file
208
+ print(f"\nWriting updated tasks to: {output_file}")
209
+
210
+ try:
211
+ with open(output_file, "w", encoding="utf-8") as f:
212
+ json.dump(tasks_data, f, indent=2, ensure_ascii=False)
213
+ print(f"✓ Successfully wrote {len(tasks_data)} task(s) to '{output_file}'")
214
+ except Exception as e:
215
+ print(f"✗ Error writing output file: {e}")
216
+ sys.exit(1)
217
+
218
+ # Summary
219
+ print("\n" + "=" * 60)
220
+ print("Summary:")
221
+ print(f" Total tasks in file: {len(tasks_data)}")
222
+ print(f" Successfully fetched: {len(fetched_tasks)}")
223
+ print(f" Updated in file: {updated_count}")
224
+ print(f" Failed to fetch: {len(task_keys) - len(fetched_tasks)}")
225
+ print("=" * 60)
226
+
227
+
228
+ if __name__ == "__main__":
229
+ asyncio.run(main())
230
+