mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
feat(execution): payload size bottlenecks with lazy execution value hydration, safer materialization, and batched parallel execution (#4560)
* improvement(resolver): lazy resolution for underlying fields greater than 10MB * progress * feat(parallel): batching * codegen to allow inline substitution * address comments * ui inconsistencies * cleanup redundant code * address more comments * address comments * replace helper * fix tests
This commit is contained in:
@@ -115,17 +115,17 @@ result = client.execute_workflow_sync("workflow-id", {"data": "some input"}, tim
|
||||
|
||||
**Returns:** `WorkflowExecutionResult`
|
||||
|
||||
##### get_job_status(task_id)
|
||||
##### get_job_status(job_id)
|
||||
|
||||
Get the status of an async job.
|
||||
|
||||
```python
|
||||
status = client.get_job_status("task-id-from-async-execution")
|
||||
status = client.get_job_status("job-id-from-async-execution")
|
||||
print("Job status:", status)
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `task_id` (str): The task ID returned from async execution
|
||||
- `job_id` (str): The job ID returned from async execution
|
||||
|
||||
**Returns:** `dict`
|
||||
|
||||
@@ -248,10 +248,11 @@ class SimStudioError(Exception):
|
||||
@dataclass
|
||||
class AsyncExecutionResult:
|
||||
success: bool
|
||||
task_id: str
|
||||
status: str # 'queued'
|
||||
created_at: str
|
||||
links: Dict[str, str]
|
||||
job_id: str
|
||||
status_url: str
|
||||
execution_id: Optional[str] = None
|
||||
message: str = ""
|
||||
async_execution: bool = True
|
||||
```
|
||||
|
||||
### RateLimitInfo
|
||||
|
||||
@@ -49,10 +49,11 @@ class WorkflowStatus:
|
||||
class AsyncExecutionResult:
|
||||
"""Result of an async workflow execution."""
|
||||
success: bool
|
||||
task_id: str
|
||||
status: str # 'queued'
|
||||
created_at: str
|
||||
links: Dict[str, str]
|
||||
job_id: str
|
||||
status_url: str
|
||||
execution_id: Optional[str] = None
|
||||
message: str = ""
|
||||
async_execution: bool = True
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -237,13 +238,14 @@ class SimStudioClient:
|
||||
result_data = response.json()
|
||||
|
||||
# Check if this is an async execution response (202 status)
|
||||
if response.status_code == 202 and 'taskId' in result_data:
|
||||
if response.status_code == 202 and 'jobId' in result_data:
|
||||
return AsyncExecutionResult(
|
||||
success=result_data.get('success', True),
|
||||
task_id=result_data['taskId'],
|
||||
status=result_data.get('status', 'queued'),
|
||||
created_at=result_data.get('createdAt', ''),
|
||||
links=result_data.get('links', {})
|
||||
job_id=result_data['jobId'],
|
||||
status_url=result_data['statusUrl'],
|
||||
execution_id=result_data.get('executionId'),
|
||||
message=result_data.get('message', ''),
|
||||
async_execution=result_data.get('async', True)
|
||||
)
|
||||
|
||||
return WorkflowExecutionResult(
|
||||
@@ -374,12 +376,12 @@ class SimStudioClient:
|
||||
"""Close the underlying HTTP session."""
|
||||
self._session.close()
|
||||
|
||||
def get_job_status(self, task_id: str) -> Dict[str, Any]:
|
||||
def get_job_status(self, job_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Get the status of an async job.
|
||||
|
||||
Args:
|
||||
task_id: The task ID returned from async execution
|
||||
job_id: The job ID returned from async execution
|
||||
|
||||
Returns:
|
||||
Dictionary containing the job status
|
||||
@@ -387,7 +389,7 @@ class SimStudioClient:
|
||||
Raises:
|
||||
SimStudioError: If getting the status fails
|
||||
"""
|
||||
url = f"{self.base_url}/api/jobs/{task_id}"
|
||||
url = f"{self.base_url}/api/jobs/{job_id}"
|
||||
|
||||
try:
|
||||
response = self._session.get(url)
|
||||
|
||||
@@ -95,17 +95,18 @@ def test_context_manager(mock_close):
|
||||
|
||||
|
||||
@patch('simstudio.requests.Session.post')
|
||||
def test_async_execution_returns_task_id(mock_post):
|
||||
def test_async_execution_returns_job_id(mock_post):
|
||||
"""Test async execution returns AsyncExecutionResult."""
|
||||
mock_response = Mock()
|
||||
mock_response.ok = True
|
||||
mock_response.status_code = 202
|
||||
mock_response.json.return_value = {
|
||||
"success": True,
|
||||
"taskId": "task-123",
|
||||
"status": "queued",
|
||||
"createdAt": "2024-01-01T00:00:00Z",
|
||||
"links": {"status": "/api/jobs/task-123"}
|
||||
"jobId": "job-123",
|
||||
"statusUrl": "https://test.sim.ai/api/jobs/job-123",
|
||||
"executionId": "execution-123",
|
||||
"message": "Workflow execution started",
|
||||
"async": True
|
||||
}
|
||||
mock_response.headers.get.return_value = None
|
||||
mock_post.return_value = mock_response
|
||||
@@ -118,9 +119,10 @@ def test_async_execution_returns_task_id(mock_post):
|
||||
)
|
||||
|
||||
assert result.success is True
|
||||
assert result.task_id == "task-123"
|
||||
assert result.status == "queued"
|
||||
assert result.links["status"] == "/api/jobs/task-123"
|
||||
assert result.job_id == "job-123"
|
||||
assert result.status_url == "https://test.sim.ai/api/jobs/job-123"
|
||||
assert result.execution_id == "execution-123"
|
||||
assert result.async_execution is True
|
||||
|
||||
call_args = mock_post.call_args
|
||||
assert call_args[1]["headers"]["X-Execution-Mode"] == "async"
|
||||
|
||||
Reference in New Issue
Block a user