Remove code cache deletion confirmation from backend (#SKY-7370) (#4726)
Co-authored-by: Suchintan Singh <suchintan@skyvern.com>
This commit is contained in:
@@ -837,11 +837,6 @@ class BrowserProfileNotFound(SkyvernHTTPException):
|
|||||||
super().__init__(message, status_code=status.HTTP_404_NOT_FOUND)
|
super().__init__(message, status_code=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
|
|
||||||
class CannotUpdateWorkflowDueToCodeCache(SkyvernException):
|
|
||||||
def __init__(self, workflow_permanent_id: str) -> None:
|
|
||||||
super().__init__(f"No confirmation for code cache deletion on {workflow_permanent_id}.")
|
|
||||||
|
|
||||||
|
|
||||||
class APIKeyNotFound(SkyvernHTTPException):
|
class APIKeyNotFound(SkyvernHTTPException):
|
||||||
def __init__(self, organization_id: str) -> None:
|
def __init__(self, organization_id: str) -> None:
|
||||||
super().__init__(f"No valid API key token found for organization {organization_id}")
|
super().__init__(f"No valid API key token found for organization {organization_id}")
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ from skyvern import analytics
|
|||||||
from skyvern._version import __version__
|
from skyvern._version import __version__
|
||||||
from skyvern.config import settings
|
from skyvern.config import settings
|
||||||
from skyvern.exceptions import (
|
from skyvern.exceptions import (
|
||||||
CannotUpdateWorkflowDueToCodeCache,
|
|
||||||
MissingBrowserAddressError,
|
MissingBrowserAddressError,
|
||||||
SkyvernHTTPException,
|
SkyvernHTTPException,
|
||||||
)
|
)
|
||||||
@@ -922,7 +921,6 @@ async def update_workflow_legacy(
|
|||||||
..., description="The ID of the workflow to update. Workflow ID starts with `wpid_`.", examples=["wpid_123"]
|
..., description="The ID of the workflow to update. Workflow ID starts with `wpid_`.", examples=["wpid_123"]
|
||||||
),
|
),
|
||||||
current_org: Organization = Depends(org_auth_service.get_current_org),
|
current_org: Organization = Depends(org_auth_service.get_current_org),
|
||||||
delete_code_cache_is_ok: bool = Query(False),
|
|
||||||
) -> Workflow:
|
) -> Workflow:
|
||||||
analytics.capture("skyvern-oss-agent-workflow-update")
|
analytics.capture("skyvern-oss-agent-workflow-update")
|
||||||
# validate the workflow
|
# validate the workflow
|
||||||
@@ -938,13 +936,7 @@ async def update_workflow_legacy(
|
|||||||
organization=current_org,
|
organization=current_org,
|
||||||
request=workflow_create_request,
|
request=workflow_create_request,
|
||||||
workflow_permanent_id=workflow_id,
|
workflow_permanent_id=workflow_id,
|
||||||
delete_code_cache_is_ok=delete_code_cache_is_ok,
|
|
||||||
)
|
)
|
||||||
except CannotUpdateWorkflowDueToCodeCache as e:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=422,
|
|
||||||
detail=str(e),
|
|
||||||
) from e
|
|
||||||
except WorkflowDefinitionValidationException as e:
|
except WorkflowDefinitionValidationException as e:
|
||||||
raise e
|
raise e
|
||||||
except (SkyvernHTTPException, ValidationError) as e:
|
except (SkyvernHTTPException, ValidationError) as e:
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ from skyvern.exceptions import (
|
|||||||
BlockNotFound,
|
BlockNotFound,
|
||||||
BrowserProfileNotFound,
|
BrowserProfileNotFound,
|
||||||
BrowserSessionNotFound,
|
BrowserSessionNotFound,
|
||||||
CannotUpdateWorkflowDueToCodeCache,
|
|
||||||
FailedToSendWebhook,
|
FailedToSendWebhook,
|
||||||
InvalidCredentialId,
|
InvalidCredentialId,
|
||||||
MissingValueForParameter,
|
MissingValueForParameter,
|
||||||
@@ -2140,7 +2139,6 @@ class WorkflowService:
|
|||||||
workflow_definition: WorkflowDefinition,
|
workflow_definition: WorkflowDefinition,
|
||||||
organization_id: str,
|
organization_id: str,
|
||||||
delete_script: bool = True,
|
delete_script: bool = True,
|
||||||
delete_code_cache_is_ok: bool = False,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
if workflow_definition:
|
if workflow_definition:
|
||||||
workflow_definition.validate()
|
workflow_definition.validate()
|
||||||
@@ -2216,27 +2214,6 @@ class WorkflowService:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
if published_groups and not delete_code_cache_is_ok:
|
|
||||||
LOG.info(
|
|
||||||
"Workflow definition changed, asking user if clearing published cached blocks is ok",
|
|
||||||
workflow_id=workflow.workflow_id,
|
|
||||||
workflow_permanent_id=previous_valid_workflow.workflow_permanent_id,
|
|
||||||
organization_id=organization_id,
|
|
||||||
previous_version=previous_valid_workflow.version,
|
|
||||||
new_version=workflow.version,
|
|
||||||
invalidate_reason=plan.reason,
|
|
||||||
invalidate_label=plan.label,
|
|
||||||
invalidate_index_prev=plan.previous_index,
|
|
||||||
invalidate_index_new=plan.new_index,
|
|
||||||
block_labels_to_disable=plan.block_labels_to_disable,
|
|
||||||
to_clear_published_cnt=len(published_groups),
|
|
||||||
to_clear_non_published_cnt=len(cached_groups),
|
|
||||||
)
|
|
||||||
|
|
||||||
raise CannotUpdateWorkflowDueToCodeCache(
|
|
||||||
workflow_permanent_id=previous_valid_workflow.workflow_permanent_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
groups_to_clear = [*cached_groups, *published_groups]
|
groups_to_clear = [*cached_groups, *published_groups]
|
||||||
await self._clear_cached_block_groups(
|
await self._clear_cached_block_groups(
|
||||||
@@ -2278,38 +2255,7 @@ class WorkflowService:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
to_delete_published = [script for script in candidates if script.status == ScriptStatus.published]
|
to_delete = candidates
|
||||||
to_delete = [script for script in candidates if script.status != ScriptStatus.published]
|
|
||||||
|
|
||||||
if len(to_delete_published) > 0:
|
|
||||||
if not delete_code_cache_is_ok:
|
|
||||||
LOG.info(
|
|
||||||
"Workflow definition changed, asking user if deleting published code is ok",
|
|
||||||
workflow_id=workflow.workflow_id,
|
|
||||||
workflow_permanent_id=previous_valid_workflow.workflow_permanent_id,
|
|
||||||
organization_id=organization_id,
|
|
||||||
previous_version=previous_valid_workflow.version,
|
|
||||||
new_version=workflow.version,
|
|
||||||
to_delete_non_published_cnt=len(to_delete),
|
|
||||||
to_delete_published_cnt=len(to_delete_published),
|
|
||||||
)
|
|
||||||
|
|
||||||
raise CannotUpdateWorkflowDueToCodeCache(
|
|
||||||
workflow_permanent_id=previous_valid_workflow.workflow_permanent_id,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
LOG.info(
|
|
||||||
"Workflow definition changed, user answered yes to deleting published code",
|
|
||||||
workflow_id=workflow.workflow_id,
|
|
||||||
workflow_permanent_id=previous_valid_workflow.workflow_permanent_id,
|
|
||||||
organization_id=organization_id,
|
|
||||||
previous_version=previous_valid_workflow.version,
|
|
||||||
new_version=workflow.version,
|
|
||||||
to_delete_non_published_cnt=len(to_delete),
|
|
||||||
to_delete_published_cnt=len(to_delete_published),
|
|
||||||
)
|
|
||||||
|
|
||||||
to_delete.extend(to_delete_published)
|
|
||||||
|
|
||||||
if len(to_delete) > 0:
|
if len(to_delete) > 0:
|
||||||
try:
|
try:
|
||||||
@@ -3339,7 +3285,6 @@ class WorkflowService:
|
|||||||
request: WorkflowCreateYAMLRequest,
|
request: WorkflowCreateYAMLRequest,
|
||||||
workflow_permanent_id: str | None = None,
|
workflow_permanent_id: str | None = None,
|
||||||
delete_script: bool = True,
|
delete_script: bool = True,
|
||||||
delete_code_cache_is_ok: bool = True,
|
|
||||||
) -> Workflow:
|
) -> Workflow:
|
||||||
organization_id = organization.organization_id
|
organization_id = organization.organization_id
|
||||||
|
|
||||||
@@ -3449,7 +3394,6 @@ class WorkflowService:
|
|||||||
workflow_definition=workflow_definition,
|
workflow_definition=workflow_definition,
|
||||||
organization_id=organization_id,
|
organization_id=organization_id,
|
||||||
delete_script=delete_script,
|
delete_script=delete_script,
|
||||||
delete_code_cache_is_ok=delete_code_cache_is_ok,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return updated_workflow
|
return updated_workflow
|
||||||
|
|||||||
Reference in New Issue
Block a user