| |
|
| |
|
| | This document outlines the API endpoints for running and managing workflow executions in PySpur.
|
| |
|
| |
|
| |
|
| | **Description**: Executes a workflow synchronously and returns the outputs. This is a blocking call that waits for the workflow to complete before returning a response. If the workflow contains a human intervention node, it may pause execution and return a pause exception.
|
| |
|
| | **URL**: `/wf/{workflow_id}/run/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class StartRunRequestSchema(BaseModel):
|
| | initial_inputs: Optional[Dict[str, Dict[str, Any]]] = None
|
| | parent_run_id: Optional[str] = None
|
| | files: Optional[Dict[str, List[str]]] = None
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | Dict[str, Any]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Starts a workflow execution asynchronously and returns immediately with the run details. The workflow continues execution in the background. This is useful for long-running workflows where you don't want to wait for completion.
|
| |
|
| | **URL**: `/wf/{workflow_id}/start_run/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Request Payload**: Same as Run Workflow (Blocking)
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class RunResponseSchema(BaseModel):
|
| | id: str
|
| | workflow_id: str
|
| | workflow_version_id: Optional[str]
|
| | workflow_version: Optional[WorkflowVersionResponseSchema]
|
| | status: RunStatus
|
| | start_time: datetime
|
| | end_time: Optional[datetime]
|
| | initial_inputs: Optional[Dict[str, Dict[str, Any]]]
|
| | outputs: Optional[Dict[str, Dict[str, Any]]]
|
| | tasks: List[TaskResponseSchema]
|
| | parent_run_id: Optional[str]
|
| | run_type: str
|
| | output_file_id: Optional[str]
|
| | input_dataset_id: Optional[str]
|
| | message: Optional[str]
|
| | duration: Optional[float]
|
| | percentage_complete: float
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Executes a partial workflow starting from a specific node, using precomputed outputs for upstream nodes. This is useful for testing specific parts of a workflow without running the entire workflow.
|
| |
|
| | **URL**: `/wf/{workflow_id}/run_partial/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class PartialRunRequestSchema(BaseModel):
|
| | node_id: str
|
| | initial_inputs: Optional[Dict[str, Dict[str, Any]]] = None
|
| | partial_outputs: Optional[Dict[str, Dict[str, Any]]] = None
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | Dict[str, Any]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Starts a batch execution of a workflow over a dataset. The workflow is run once for each row in the dataset, with dataset columns mapped to workflow inputs. Results are written to an output file.
|
| |
|
| | **URL**: `/wf/{workflow_id}/start_batch_run/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class BatchRunRequestSchema(BaseModel):
|
| | dataset_id: str
|
| | mini_batch_size: int = 10
|
| | ```
|
| |
|
| | **Response Schema**: Same as Start Run (Non-Blocking)
|
| |
|
| |
|
| |
|
| | **Description**: Lists all runs for a specific workflow with pagination support, ordered by start time descending. This endpoint also updates run status based on task status.
|
| |
|
| | **URL**: `/wf/{workflow_id}/runs/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | page: int
|
| | page_size: int
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[RunResponseSchema]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Lists all workflows that are currently in a paused state, with pagination support. This endpoint is useful for monitoring workflows that require human intervention.
|
| |
|
| | **URL**: `/wf/paused_workflows/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Query Parameters**:
|
| | ```python
|
| | page: int
|
| | page_size: int
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[PausedWorkflowResponseSchema]
|
| | ```
|
| |
|
| | Where `PausedWorkflowResponseSchema` contains:
|
| | ```python
|
| | class PausedWorkflowResponseSchema(BaseModel):
|
| | run: RunResponseSchema
|
| | current_pause: PauseHistoryResponseSchema
|
| | workflow: WorkflowDefinitionSchema
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Retrieves the pause history for a specific workflow run, showing when and why the workflow was paused, and any actions taken to resume it.
|
| |
|
| | **URL**: `/wf/pause_history/{run_id}/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | run_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | List[PauseHistoryResponseSchema]
|
| | ```
|
| |
|
| | Where `PauseHistoryResponseSchema` contains:
|
| | ```python
|
| | class PauseHistoryResponseSchema(BaseModel):
|
| | id: str
|
| | run_id: str
|
| | node_id: str
|
| | pause_message: Optional[str]
|
| | pause_time: datetime
|
| | resume_time: Optional[datetime]
|
| | resume_user_id: Optional[str]
|
| | resume_action: Optional[PauseAction]
|
| | input_data: Optional[Dict[str, Any]]
|
| | comments: Optional[str]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Processes an action on a paused workflow, allowing for approval, decline, or override of a workflow that has been paused for human intervention. The workflow will resume execution based on the action taken.
|
| |
|
| | **URL**: `/wf/process_pause_action/{run_id}/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | run_id: str
|
| | ```
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class ResumeRunRequestSchema(BaseModel):
|
| | inputs: Dict[str, Any]
|
| | user_id: str
|
| | action: PauseAction
|
| | comments: Optional[str] = None
|
| | ```
|
| |
|
| | **Response Schema**: Same as Start Run (Non-Blocking)
|
| |
|
| |
|
| |
|
| | **Description**: Cancels a workflow that is currently paused or running. This will mark the run as CANCELED in the database and update all pending, running, and paused tasks to CANCELED as well.
|
| |
|
| | **URL**: `/wf/cancel_workflow/{run_id}/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | run_id: str
|
| | ```
|
| |
|
| | **Response Schema**: Same as Start Run (Non-Blocking) with a message indicating the workflow has been canceled successfully.
|
| |
|