mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-10 06:15:18 +00:00
Automatically create output parameters (#327)
This commit is contained in:
parent
72d25cd37d
commit
e6cee25416
3 changed files with 187 additions and 157 deletions
|
@ -1,33 +1,61 @@
|
|||
from skyvern.exceptions import SkyvernException
|
||||
from starlette import status
|
||||
|
||||
from skyvern.exceptions import SkyvernException, SkyvernHTTPException
|
||||
|
||||
|
||||
class BaseWorkflowException(SkyvernException):
|
||||
pass
|
||||
|
||||
|
||||
class WorkflowDefinitionHasDuplicateBlockLabels(BaseWorkflowException):
|
||||
class BaseWorkflowHTTPException(SkyvernHTTPException):
|
||||
pass
|
||||
|
||||
|
||||
class WorkflowDefinitionHasDuplicateBlockLabels(BaseWorkflowHTTPException):
|
||||
def __init__(self, duplicate_labels: set[str]) -> None:
|
||||
super().__init__(
|
||||
f"WorkflowDefinition has blocks with duplicate labels. Each block needs to have a unique "
|
||||
f"label. Duplicate label(s): {','.join(duplicate_labels)}"
|
||||
f"label. Duplicate label(s): {','.join(duplicate_labels)}",
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
class OutputParameterKeyCollisionError(BaseWorkflowException):
|
||||
class OutputParameterKeyCollisionError(BaseWorkflowHTTPException):
|
||||
def __init__(self, key: str, retry_count: int | None = None) -> None:
|
||||
message = f"Output parameter key {key} already exists in the context manager."
|
||||
if retry_count is not None:
|
||||
message += f" Retrying {retry_count} more times."
|
||||
elif retry_count == 0:
|
||||
message += " Max duplicate retries reached, aborting."
|
||||
super().__init__(message)
|
||||
super().__init__(
|
||||
message,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
class WorkflowDefinitionHasDuplicateParameterKeys(BaseWorkflowException):
|
||||
class WorkflowDefinitionHasDuplicateParameterKeys(BaseWorkflowHTTPException):
|
||||
def __init__(self, duplicate_keys: set[str]) -> None:
|
||||
super().__init__(
|
||||
f"WorkflowDefinition has parameters with duplicate keys. Each parameter needs to have a unique "
|
||||
f"key. Duplicate key(s): {','.join(duplicate_keys)}"
|
||||
f"key. Duplicate key(s): {','.join(duplicate_keys)}",
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
class WorkflowDefinitionHasReservedParameterKeys(BaseWorkflowHTTPException):
|
||||
def __init__(self, reserved_keys: list[str], parameter_keys: list[str]) -> None:
|
||||
super().__init__(
|
||||
f"WorkflowDefinition has parameters with reserved keys. User created parameters cannot have the following "
|
||||
f"reserved keys: {','.join(reserved_keys)}. Parameter keys: {','.join(parameter_keys)}",
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
class InvalidWorkflowDefinition(BaseWorkflowHTTPException):
|
||||
def __init__(self, message: str) -> None:
|
||||
super().__init__(
|
||||
message,
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
||||
|
||||
|
@ -36,8 +64,9 @@ class InvalidEmailClientConfiguration(BaseWorkflowException):
|
|||
super().__init__(f"Email client configuration is invalid. These parameters are missing or invalid: {problems}")
|
||||
|
||||
|
||||
class ContextParameterSourceNotDefined(BaseWorkflowException):
|
||||
class ContextParameterSourceNotDefined(BaseWorkflowHTTPException):
|
||||
def __init__(self, context_parameter_key: str, source_key: str) -> None:
|
||||
super().__init__(
|
||||
f"Source parameter key {source_key} for context parameter {context_parameter_key} does not exist."
|
||||
f"Source parameter key {source_key} for context parameter {context_parameter_key} does not exist.",
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue