Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ContextParameter while creating workflow from yaml #172

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions skyvern/forge/sdk/workflow/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)
from skyvern.forge.sdk.workflow.models.parameter import (
AWSSecretParameter,
ContextParameter,
OutputParameter,
Parameter,
ParameterType,
Expand Down Expand Up @@ -653,6 +654,10 @@ async def create_workflow_from_request(self, organization_id: str, request: Work
# Create parameters from the request
parameters = {}
duplicate_parameter_keys = set()

# We're going to process context parameters after other parameters since they depend on the other parameters
context_parameter_yamls = []

for parameter in request.workflow_definition.parameters:
if parameter.key in parameters:
LOG.error(f"Duplicate parameter key {parameter.key}")
Expand Down Expand Up @@ -689,6 +694,21 @@ async def create_workflow_from_request(self, organization_id: str, request: Work
key=parameter.key,
description=parameter.description,
)
elif parameter.parameter_type == ParameterType.CONTEXT:
context_parameter_yamls.append(parameter)
else:
LOG.error(f"Invalid parameter type {parameter.parameter_type}")

# Now we can process the context parameters since all other parameters have been created
for context_parameter in context_parameter_yamls:
parameters[context_parameter.key] = ContextParameter(
key=context_parameter.key,
description=context_parameter.description,
source=parameters[context_parameter.source_workflow_parameter_key],
# Context parameters don't have a default value, the value always depends on the source parameter
value=None,
)

if duplicate_parameter_keys:
raise WorkflowDefinitionHasDuplicateParameterKeys(duplicate_keys=duplicate_parameter_keys)
# Create blocks from the request
Expand Down
Loading