diff --git a/.env.example b/.env.example index 3727fb3c4..8da78f369 100644 --- a/.env.example +++ b/.env.example @@ -69,3 +69,6 @@ PORT=8000 # Analytics configuration: # Distinct analytics ID (a UUID is generated if left blank). ANALYTICS_ID="anonymous" + +# Enable recording skyvern logs as artifacts +ENABLE_LOG_ARTIFACTS=false \ No newline at end of file diff --git a/skyvern-frontend/.env.example b/skyvern-frontend/.env.example index 6716f5c52..8a74ebe1f 100644 --- a/skyvern-frontend/.env.example +++ b/skyvern-frontend/.env.example @@ -8,4 +8,7 @@ VITE_ARTIFACT_API_BASE_URL=http://localhost:9090 VITE_WSS_BASE_URL=ws://localhost:8000/api/v1 # your api key - for x-api-key header -VITE_SKYVERN_API_KEY=YOUR_API_KEY \ No newline at end of file +VITE_SKYVERN_API_KEY=YOUR_API_KEY + +# Enable recording skyvern logs as artifacts +VITE_ENABLE_LOG_ARTIFACTS=false diff --git a/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx b/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx index b09be32ba..df7664415 100644 --- a/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx +++ b/skyvern-frontend/src/routes/tasks/detail/StepArtifacts.tsx @@ -17,6 +17,9 @@ import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat"; import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { Artifact } from "./Artifact"; +const enable_log_artifacts = + import.meta.env.VITE_ENABLE_LOG_ARTIFACTS === "true"; + type Props = { id: string; stepProps: StepApiResponse; @@ -111,7 +114,9 @@ function StepArtifacts({ id, stepProps }: Props) { Action List HTML (Raw) LLM Request (Raw) - Skyvern Log + {enable_log_artifacts && ( + Skyvern Log + )}
@@ -213,9 +218,11 @@ function StepArtifacts({ id, stepProps }: Props) { {llmRequest ? : null} - - {skyvernLog ? : null} - + {enable_log_artifacts && ( + + {skyvernLog ? : null} + + )} ); } diff --git a/skyvern/config.py b/skyvern/config.py index a1cbd4563..20ac18c0b 100644 --- a/skyvern/config.py +++ b/skyvern/config.py @@ -131,6 +131,8 @@ class Settings(BaseSettings): SVG_MAX_LENGTH: int = 100000 + ENABLE_LOG_ARTIFACTS: bool = False + def is_cloud_environment(self) -> bool: """ :return: True if env is not local, else False diff --git a/skyvern/forge/sdk/log_artifacts.py b/skyvern/forge/sdk/log_artifacts.py index 1d555abdc..11ac5e2ec 100644 --- a/skyvern/forge/sdk/log_artifacts.py +++ b/skyvern/forge/sdk/log_artifacts.py @@ -2,6 +2,8 @@ import structlog +from skyvern.config import settings + from skyvern.forge import app from skyvern.forge.sdk.artifact.models import ArtifactType, LogEntityType from skyvern.forge.sdk.core import skyvern_context @@ -10,7 +12,6 @@ LOG = structlog.get_logger() - def primary_key_from_log_entity_type(log_entity_type: LogEntityType) -> str: if log_entity_type == LogEntityType.STEP: return "step_id" @@ -25,6 +26,9 @@ def primary_key_from_log_entity_type(log_entity_type: LogEntityType) -> str: async def save_step_logs(step_id: str) -> None: + if not settings.ENABLE_LOG_ARTIFACTS: + return + context = skyvern_context.ensure_context() log = context.log organization_id = context.organization_id @@ -41,6 +45,9 @@ async def save_step_logs(step_id: str) -> None: async def save_task_logs(task_id: str) -> None: + if not settings.ENABLE_LOG_ARTIFACTS: + return + context = skyvern_context.ensure_context() log = context.log organization_id = context.organization_id @@ -57,6 +64,9 @@ async def save_task_logs(task_id: str) -> None: async def save_workflow_run_logs(workflow_run_id: str) -> None: + if not settings.ENABLE_LOG_ARTIFACTS: + return + context = skyvern_context.ensure_context() log = context.log organization_id = context.organization_id @@ -73,6 +83,9 @@ async def save_workflow_run_logs(workflow_run_id: str) -> None: async def save_workflow_run_block_logs(workflow_run_block_id: str) -> None: + if not settings.ENABLE_LOG_ARTIFACTS: + return + context = skyvern_context.ensure_context() log = context.log organization_id = context.organization_id @@ -100,6 +113,9 @@ async def _save_log_artifacts( workflow_run_block_id: str | None = None, ) -> None: try: + if not settings.ENABLE_LOG_ARTIFACTS: + return + log_json = json.dumps(log, cls=SkyvernJSONLogEncoder, indent=2) log_artifact = await app.DATABASE.get_artifact_by_entity_id(