fleet-python 0.2.26__py3-none-any.whl → 0.2.27__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.

@@ -9,18 +9,38 @@ def fix_file(filepath: Path) -> bool:
9
9
  content = filepath.read_text()
10
10
  original = content
11
11
 
12
- # Remove asyncio import if it exists
13
- content = re.sub(r'^import asyncio.*\n', '', content, flags=re.MULTILINE)
14
- content = re.sub(r'^import asyncio as async_time.*\n', '', content, flags=re.MULTILINE)
15
- # Also remove indented asyncio imports (like in functions)
16
- content = re.sub(r'^\s+import asyncio.*\n', '', content, flags=re.MULTILINE)
12
+ # Handle asyncio imports - replace with inspect in verifier files, remove elsewhere
13
+ if 'verifier' in str(filepath).lower() and 'iscoroutinefunction' in content:
14
+ # In verifier files, replace asyncio with inspect
15
+ content = re.sub(r'^import asyncio\b', 'import inspect', content, flags=re.MULTILINE)
16
+ content = content.replace('asyncio.iscoroutinefunction', 'inspect.iscoroutinefunction')
17
+ else:
18
+ # In other files, remove asyncio imports
19
+ content = re.sub(r'^import asyncio.*\n', '', content, flags=re.MULTILINE)
20
+ content = re.sub(r'^import asyncio as async_time.*\n', '', content, flags=re.MULTILINE)
21
+ # Also remove indented asyncio imports (like in functions)
22
+ content = re.sub(r'^\s+import asyncio.*\n', '', content, flags=re.MULTILINE)
17
23
 
18
24
  # Fix any remaining asyncio.sleep or async_time.sleep calls
19
25
  content = content.replace('asyncio.sleep(', 'time.sleep(')
20
26
  content = content.replace('async_time.sleep(', 'time.sleep(')
21
27
 
22
- # Fix absolute imports to relative imports for verifiers
23
- content = content.replace('from fleet.verifiers import', 'from ..verifiers import')
28
+ # Fix absolute imports to relative imports for verifiers based on file location
29
+ rel_path = filepath.relative_to(Path(__file__).parent.parent / "fleet")
30
+ depth = len(rel_path.parts) - 1 # -1 because the file itself doesn't count
31
+
32
+ # Fix verifier imports specifically - only in non-verifiers directories
33
+ if 'verifiers' not in str(rel_path):
34
+ content = content.replace('from ..verifiers', 'from .verifiers')
35
+
36
+ # Fix specific cases for verifiers/__init__.py
37
+ if rel_path == Path('verifiers/__init__.py'):
38
+ # These should be relative imports within the verifiers package
39
+ content = content.replace('from ...verifiers.db import', 'from .db import')
40
+ content = content.replace('from ...verifiers.code import', 'from .code import')
41
+ # Also handle the case where unasync transformed fleet.verifiers to ..verifiers
42
+ content = content.replace('from ..verifiers.db import', 'from .db import')
43
+ content = content.replace('from ..verifiers.code import', 'from .code import')
24
44
 
25
45
  # Fix any remaining AsyncFleetPlaywrightWrapper references in docstrings
26
46
  content = content.replace('AsyncFleetPlaywrightWrapper', 'FleetPlaywrightWrapper')
@@ -56,6 +76,23 @@ def fix_file(filepath: Path) -> bool:
56
76
  content = content.replace('"Environment",', '"SyncEnv",')
57
77
  content = content.replace("'Environment',", "'SyncEnv',")
58
78
 
79
+ # Add async-to-sync conversion to client.py _create_verifier_from_data method
80
+ if rel_path.parts[0] == 'client.py' and len(rel_path.parts) == 1:
81
+ # Find the _create_verifier_from_data method and add async-to-sync conversion
82
+ if '_create_verifier_from_data' in content and 'from .verifiers.verifier import SyncVerifierFunction' in content:
83
+ # Look for the line where we have the verifier_code and add conversion before any other processing
84
+ insertion_point = 'from .verifiers.verifier import SyncVerifierFunction'
85
+ if insertion_point in content:
86
+ replacement = insertion_point + '''
87
+
88
+ # Convert async verifier code to sync
89
+ if 'async def' in verifier_code:
90
+ verifier_code = verifier_code.replace('async def', 'def')
91
+ if 'await ' in verifier_code:
92
+ verifier_code = verifier_code.replace('await ', '')'''
93
+
94
+ content = content.replace(insertion_point, replacement)
95
+
59
96
  # Fix playwright imports for sync version
60
97
  if 'playwright' in str(filepath):
61
98
  # Fix the import statement
fleet/tasks.py DELETED
@@ -1,44 +0,0 @@
1
- """Fleet SDK Task Model."""
2
-
3
- from __future__ import annotations
4
-
5
- import re
6
- from datetime import datetime
7
- from typing import Any, Dict, Optional
8
- from uuid import UUID
9
-
10
- from pydantic import BaseModel, Field, validator
11
-
12
- # Import the shared VerifierFunction type that works for both async and sync
13
- from fleet.types import VerifierFunction
14
-
15
-
16
- class Task(BaseModel):
17
- """A task model representing a single task in the Fleet system."""
18
-
19
- key: str = Field(..., description="Unique task key identifier")
20
- prompt: str = Field(..., description="Task prompt or instruction")
21
- env_id: str = Field(..., description="Environment identifier")
22
- created_at: Optional[datetime] = Field(None, description="Task creation timestamp")
23
- verifier: Optional[Any] = Field(None, description="Verifier function with decorator (async or sync)")
24
- metadata: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Additional task metadata")
25
-
26
- @validator('key')
27
- def validate_key_format(cls, v):
28
- """Validate key follows kebab-case format."""
29
- if not re.match(r'^[a-z0-9]+(-[a-z0-9]+)*$', v):
30
- raise ValueError(f'Invalid task key format: {v}. Must follow kebab-case format.')
31
- return v
32
-
33
- @validator('created_at', pre=True, always=True)
34
- def set_created_at(cls, v):
35
- """Set created_at to current time if not provided."""
36
- return v or datetime.now()
37
-
38
- class Config:
39
- """Pydantic model configuration."""
40
- json_encoders = {
41
- datetime: lambda v: v.isoformat(),
42
- }
43
- # Allow arbitrary types for the verifier field
44
- arbitrary_types_allowed = True