Automatically write workflow_run_id if one isn't specified for a specific artifact (#2767)
This commit is contained in:
@@ -6,6 +6,7 @@ import structlog
|
|||||||
|
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
from skyvern.forge.sdk.artifact.models import Artifact, ArtifactType, LogEntityType
|
from skyvern.forge.sdk.artifact.models import Artifact, ArtifactType, LogEntityType
|
||||||
|
from skyvern.forge.sdk.core import skyvern_context
|
||||||
from skyvern.forge.sdk.db.id import generate_artifact_id
|
from skyvern.forge.sdk.db.id import generate_artifact_id
|
||||||
from skyvern.forge.sdk.models import Step
|
from skyvern.forge.sdk.models import Step
|
||||||
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestion
|
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestion
|
||||||
@@ -25,6 +26,7 @@ class ArtifactManager:
|
|||||||
artifact_id: str,
|
artifact_id: str,
|
||||||
artifact_type: ArtifactType,
|
artifact_type: ArtifactType,
|
||||||
uri: str,
|
uri: str,
|
||||||
|
organization_id: str,
|
||||||
step_id: str | None = None,
|
step_id: str | None = None,
|
||||||
task_id: str | None = None,
|
task_id: str | None = None,
|
||||||
workflow_run_id: str | None = None,
|
workflow_run_id: str | None = None,
|
||||||
@@ -32,7 +34,6 @@ class ArtifactManager:
|
|||||||
thought_id: str | None = None,
|
thought_id: str | None = None,
|
||||||
task_v2_id: str | None = None,
|
task_v2_id: str | None = None,
|
||||||
ai_suggestion_id: str | None = None,
|
ai_suggestion_id: str | None = None,
|
||||||
organization_id: str | None = None,
|
|
||||||
data: bytes | None = None,
|
data: bytes | None = None,
|
||||||
path: str | None = None,
|
path: str | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
@@ -40,6 +41,13 @@ class ArtifactManager:
|
|||||||
raise ValueError("Either data or path must be provided to create an artifact.")
|
raise ValueError("Either data or path must be provided to create an artifact.")
|
||||||
if data and path:
|
if data and path:
|
||||||
raise ValueError("Both data and path cannot be provided to create an artifact.")
|
raise ValueError("Both data and path cannot be provided to create an artifact.")
|
||||||
|
|
||||||
|
if not workflow_run_id:
|
||||||
|
context = skyvern_context.current()
|
||||||
|
|
||||||
|
if context:
|
||||||
|
workflow_run_id = context.workflow_run_id
|
||||||
|
|
||||||
artifact = await app.DATABASE.create_artifact(
|
artifact = await app.DATABASE.create_artifact(
|
||||||
artifact_id,
|
artifact_id,
|
||||||
artifact_type,
|
artifact_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user