mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-14 09:19:40 +00:00
WorkflowRunStatusResponse -> WorkflowRunResponse (#1959)
This commit is contained in:
parent
8955c0498c
commit
09fb6ae60a
12 changed files with 44 additions and 43 deletions
|
@ -14,7 +14,7 @@ from skyvern.forge.prompts import prompt_engine
|
|||
from skyvern.forge.sdk.api.files import create_folder_if_not_exist
|
||||
from skyvern.forge.sdk.schemas.task_v2 import TaskV2, TaskV2Request
|
||||
from skyvern.forge.sdk.schemas.tasks import ProxyLocation, TaskRequest, TaskResponse, TaskStatus
|
||||
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRequestBody, WorkflowRunStatus, WorkflowRunStatusResponse
|
||||
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRequestBody, WorkflowRunResponse, WorkflowRunStatus
|
||||
|
||||
|
||||
class TaskOutput(BaseModel):
|
||||
|
@ -70,7 +70,7 @@ class SkyvernClient:
|
|||
assert response.status_code == 200, f"Expected to get task response status 200, but got {response.status_code}"
|
||||
return TaskResponse(**response.json())
|
||||
|
||||
async def get_workflow_run(self, workflow_pid: str, workflow_run_id: str) -> WorkflowRunStatusResponse:
|
||||
async def get_workflow_run(self, workflow_pid: str, workflow_run_id: str) -> WorkflowRunResponse:
|
||||
url = f"{self.base_url}/workflows/{workflow_pid}/runs/{workflow_run_id}"
|
||||
headers = {"x-api-key": self.credentials}
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
@ -78,7 +78,7 @@ class SkyvernClient:
|
|||
assert response.status_code == 200, (
|
||||
f"Expected to get workflow run response status 200, but got {response.status_code}"
|
||||
)
|
||||
return WorkflowRunStatusResponse(**response.json())
|
||||
return WorkflowRunResponse(**response.json())
|
||||
|
||||
|
||||
class Evaluator:
|
||||
|
|
|
@ -1164,7 +1164,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/WorkflowRunStatusResponse'
|
||||
$ref: '#/components/schemas/WorkflowRunResponse'
|
||||
'422':
|
||||
description: Validation Error
|
||||
content:
|
||||
|
@ -4879,7 +4879,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/WorkflowRunStatusResponse'
|
||||
$ref: '#/components/schemas/WorkflowRunResponse'
|
||||
'422':
|
||||
description: Validation Error
|
||||
content:
|
||||
|
@ -9373,7 +9373,7 @@ components:
|
|||
- timed_out
|
||||
- completed
|
||||
title: WorkflowRunStatus
|
||||
WorkflowRunStatusResponse:
|
||||
WorkflowRunResponse:
|
||||
properties:
|
||||
workflow_id:
|
||||
type: string
|
||||
|
@ -9464,7 +9464,7 @@ components:
|
|||
- created_at
|
||||
- modified_at
|
||||
- parameters
|
||||
title: WorkflowRunStatusResponse
|
||||
title: WorkflowRunResponse
|
||||
WorkflowRunTimeline:
|
||||
properties:
|
||||
type:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "skyvern"
|
||||
version = "0.1.63"
|
||||
version = "0.1.64.dev0"
|
||||
description = ""
|
||||
authors = ["Skyvern AI <info@skyvern.com>"]
|
||||
readme = "README.md"
|
||||
|
|
|
@ -3,6 +3,7 @@ from ddtrace.filters import FilterRequestsOnUrl
|
|||
|
||||
from skyvern.agent import SkyvernAgent, SkyvernClient
|
||||
from skyvern.forge.sdk.forge_log import setup_logger
|
||||
from skyvern.forge.sdk.workflow.models.workflow import WorkflowRunResponse
|
||||
|
||||
tracer.configure(
|
||||
settings={
|
||||
|
@ -13,4 +14,4 @@ tracer.configure(
|
|||
)
|
||||
setup_logger()
|
||||
|
||||
__all__ = ["SkyvernAgent", "SkyvernClient"]
|
||||
__all__ = ["SkyvernAgent", "SkyvernClient", "WorkflowRunResponse"]
|
||||
|
|
|
@ -7,7 +7,7 @@ from skyvern.config import settings
|
|||
from skyvern.exceptions import SkyvernClientException
|
||||
from skyvern.forge.sdk.schemas.task_runs import TaskRunResponse
|
||||
from skyvern.forge.sdk.schemas.tasks import ProxyLocation
|
||||
from skyvern.forge.sdk.workflow.models.workflow import RunWorkflowResponse, WorkflowRunStatusResponse
|
||||
from skyvern.forge.sdk.workflow.models.workflow import RunWorkflowResponse, WorkflowRunResponse
|
||||
|
||||
|
||||
class RunEngine(StrEnum):
|
||||
|
@ -82,7 +82,7 @@ class SkyvernClient:
|
|||
async def get_workflow_run(
|
||||
self,
|
||||
workflow_run_id: str,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(
|
||||
f"{self.base_url}/api/v1/workflows/runs/{workflow_run_id}",
|
||||
|
@ -94,4 +94,4 @@ class SkyvernClient:
|
|||
f"Failed to get workflow run: {response.text}",
|
||||
status_code=response.status_code,
|
||||
)
|
||||
return WorkflowRunStatusResponse.model_validate(response.json())
|
||||
return WorkflowRunResponse.model_validate(response.json())
|
||||
|
|
|
@ -246,7 +246,7 @@ from .types import (
|
|||
WorkflowRunBlockNavigationPayload,
|
||||
WorkflowRunBlockOutput,
|
||||
WorkflowRunStatus,
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowRunResponse,
|
||||
WorkflowRunTimeline,
|
||||
WorkflowRunTimelineType,
|
||||
WorkflowStatus,
|
||||
|
@ -510,7 +510,7 @@ __all__ = [
|
|||
"WorkflowRunBlockNavigationPayload",
|
||||
"WorkflowRunBlockOutput",
|
||||
"WorkflowRunStatus",
|
||||
"WorkflowRunStatusResponse",
|
||||
"WorkflowRunResponse",
|
||||
"WorkflowRunTimeline",
|
||||
"WorkflowRunTimelineType",
|
||||
"WorkflowStatus",
|
||||
|
|
|
@ -30,7 +30,7 @@ from ..types.run_workflow_response import RunWorkflowResponse
|
|||
from ..types.workflow_run_status import WorkflowRunStatus
|
||||
from ..types.workflow_run import WorkflowRun
|
||||
from ..types.workflow_run_timeline import WorkflowRunTimeline
|
||||
from ..types.workflow_run_status_response import WorkflowRunStatusResponse
|
||||
from ..types.workflow_run_status_response import WorkflowRunResponse
|
||||
from ..types.workflow import Workflow
|
||||
from ..types.ai_suggestion_base import AiSuggestionBase
|
||||
from ..types.task_generation import TaskGeneration
|
||||
|
@ -1658,7 +1658,7 @@ class AgentClient:
|
|||
api_key: typing.Optional[str] = None,
|
||||
authorization: typing.Optional[str] = None,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
|
@ -1673,7 +1673,7 @@ class AgentClient:
|
|||
|
||||
Returns
|
||||
-------
|
||||
WorkflowRunStatusResponse
|
||||
WorkflowRunResponse
|
||||
Successful Response
|
||||
|
||||
Examples
|
||||
|
@ -1697,9 +1697,9 @@ class AgentClient:
|
|||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return typing.cast(
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowRunResponse,
|
||||
parse_obj_as(
|
||||
type_=WorkflowRunStatusResponse, # type: ignore
|
||||
type_=WorkflowRunResponse, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
|
@ -3457,7 +3457,7 @@ class AgentClient:
|
|||
|
||||
def get_eval_workflow_run_by_run_id(
|
||||
self, workflow_run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
|
@ -3468,7 +3468,7 @@ class AgentClient:
|
|||
|
||||
Returns
|
||||
-------
|
||||
WorkflowRunStatusResponse
|
||||
WorkflowRunResponse
|
||||
Successful Response
|
||||
|
||||
Examples
|
||||
|
@ -3488,9 +3488,9 @@ class AgentClient:
|
|||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return typing.cast(
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowRunResponse,
|
||||
parse_obj_as(
|
||||
type_=WorkflowRunStatusResponse, # type: ignore
|
||||
type_=WorkflowRunResponse, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
|
@ -5741,7 +5741,7 @@ class AsyncAgentClient:
|
|||
api_key: typing.Optional[str] = None,
|
||||
authorization: typing.Optional[str] = None,
|
||||
request_options: typing.Optional[RequestOptions] = None,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
|
@ -5756,7 +5756,7 @@ class AsyncAgentClient:
|
|||
|
||||
Returns
|
||||
-------
|
||||
WorkflowRunStatusResponse
|
||||
WorkflowRunResponse
|
||||
Successful Response
|
||||
|
||||
Examples
|
||||
|
@ -5788,9 +5788,9 @@ class AsyncAgentClient:
|
|||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return typing.cast(
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowRunResponse,
|
||||
parse_obj_as(
|
||||
type_=WorkflowRunStatusResponse, # type: ignore
|
||||
type_=WorkflowRunResponse, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
|
@ -7739,7 +7739,7 @@ class AsyncAgentClient:
|
|||
|
||||
async def get_eval_workflow_run_by_run_id(
|
||||
self, workflow_run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
|
@ -7750,7 +7750,7 @@ class AsyncAgentClient:
|
|||
|
||||
Returns
|
||||
-------
|
||||
WorkflowRunStatusResponse
|
||||
WorkflowRunResponse
|
||||
Successful Response
|
||||
|
||||
Examples
|
||||
|
@ -7778,9 +7778,9 @@ class AsyncAgentClient:
|
|||
try:
|
||||
if 200 <= _response.status_code < 300:
|
||||
return typing.cast(
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowRunResponse,
|
||||
parse_obj_as(
|
||||
type_=WorkflowRunStatusResponse, # type: ignore
|
||||
type_=WorkflowRunResponse, # type: ignore
|
||||
object_=_response.json(),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -277,7 +277,7 @@ from .workflow_run_block_data_schema import WorkflowRunBlockDataSchema
|
|||
from .workflow_run_block_navigation_payload import WorkflowRunBlockNavigationPayload
|
||||
from .workflow_run_block_output import WorkflowRunBlockOutput
|
||||
from .workflow_run_status import WorkflowRunStatus
|
||||
from .workflow_run_status_response import WorkflowRunStatusResponse
|
||||
from .workflow_run_status_response import WorkflowRunResponse
|
||||
from .workflow_run_timeline import WorkflowRunTimeline
|
||||
from .workflow_run_timeline_type import WorkflowRunTimelineType
|
||||
from .workflow_status import WorkflowStatus
|
||||
|
@ -528,7 +528,7 @@ __all__ = [
|
|||
"WorkflowRunBlockNavigationPayload",
|
||||
"WorkflowRunBlockOutput",
|
||||
"WorkflowRunStatus",
|
||||
"WorkflowRunStatusResponse",
|
||||
"WorkflowRunResponse",
|
||||
"WorkflowRunTimeline",
|
||||
"WorkflowRunTimelineType",
|
||||
"WorkflowStatus",
|
||||
|
|
|
@ -10,7 +10,7 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2
|
|||
import pydantic
|
||||
|
||||
|
||||
class WorkflowRunStatusResponse(UniversalBaseModel):
|
||||
class WorkflowRunResponse(UniversalBaseModel):
|
||||
workflow_id: str
|
||||
workflow_run_id: str
|
||||
status: WorkflowRunStatus
|
||||
|
|
|
@ -70,8 +70,8 @@ from skyvern.forge.sdk.workflow.models.workflow import (
|
|||
Workflow,
|
||||
WorkflowRequestBody,
|
||||
WorkflowRun,
|
||||
WorkflowRunResponse,
|
||||
WorkflowRunStatus,
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowStatus,
|
||||
)
|
||||
from skyvern.forge.sdk.workflow.models.yaml import WorkflowCreateYAMLRequest
|
||||
|
@ -714,17 +714,17 @@ async def get_workflow_run_timeline(
|
|||
|
||||
@base_router.get(
|
||||
"/workflows/runs/{workflow_run_id}",
|
||||
response_model=WorkflowRunStatusResponse,
|
||||
response_model=WorkflowRunResponse,
|
||||
)
|
||||
@base_router.get(
|
||||
"/workflows/runs/{workflow_run_id}/",
|
||||
response_model=WorkflowRunStatusResponse,
|
||||
response_model=WorkflowRunResponse,
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def get_workflow_run(
|
||||
workflow_run_id: str,
|
||||
current_org: Organization = Depends(org_auth_service.get_current_org),
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
analytics.capture("skyvern-oss-agent-workflow-run-get")
|
||||
return await app.WORKFLOW_SERVICE.build_workflow_run_status_response_by_workflow_id(
|
||||
workflow_run_id=workflow_run_id,
|
||||
|
|
|
@ -130,7 +130,7 @@ class WorkflowRunOutputParameter(BaseModel):
|
|||
created_at: datetime
|
||||
|
||||
|
||||
class WorkflowRunStatusResponse(BaseModel):
|
||||
class WorkflowRunResponse(BaseModel):
|
||||
workflow_id: str
|
||||
workflow_run_id: str
|
||||
status: WorkflowRunStatus
|
||||
|
|
|
@ -79,8 +79,8 @@ from skyvern.forge.sdk.workflow.models.workflow import (
|
|||
WorkflowRun,
|
||||
WorkflowRunOutputParameter,
|
||||
WorkflowRunParameter,
|
||||
WorkflowRunResponse,
|
||||
WorkflowRunStatus,
|
||||
WorkflowRunStatusResponse,
|
||||
WorkflowStatus,
|
||||
)
|
||||
from skyvern.forge.sdk.workflow.models.yaml import (
|
||||
|
@ -949,7 +949,7 @@ class WorkflowService:
|
|||
workflow_run_id: str,
|
||||
organization_id: str,
|
||||
include_cost: bool = False,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id, organization_id=organization_id)
|
||||
if workflow_run is None:
|
||||
LOG.error(f"Workflow run {workflow_run_id} not found")
|
||||
|
@ -968,7 +968,7 @@ class WorkflowService:
|
|||
workflow_run_id: str,
|
||||
organization_id: str,
|
||||
include_cost: bool = False,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
) -> WorkflowRunResponse:
|
||||
workflow = await self.get_workflow_by_permanent_id(workflow_permanent_id)
|
||||
if workflow is None:
|
||||
LOG.error(f"Workflow {workflow_permanent_id} not found")
|
||||
|
@ -1064,7 +1064,7 @@ class WorkflowService:
|
|||
# successful steps are the ones that have a status of completed and the total count of unique step.order
|
||||
successful_steps = [step for step in workflow_run_steps if step.status == StepStatus.completed]
|
||||
total_cost = 0.1 * (len(successful_steps) + len(text_prompt_blocks))
|
||||
return WorkflowRunStatusResponse(
|
||||
return WorkflowRunResponse(
|
||||
workflow_id=workflow.workflow_permanent_id,
|
||||
workflow_run_id=workflow_run_id,
|
||||
status=workflow_run.status,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue