make templating strictness easy to switch between (#3835)
This commit is contained in:
@@ -114,6 +114,7 @@ class Settings(BaseSettings):
|
||||
|
||||
# Workflow constant parameters
|
||||
WORKFLOW_DOWNLOAD_DIRECTORY_PARAMETER_KEY: str = "SKYVERN_DOWNLOAD_DIRECTORY"
|
||||
WORKFLOW_TEMPLATING_STRICTNESS: str = "strict" # options: "strict", "lax"
|
||||
WORKFLOW_WAIT_BLOCK_MAX_SEC: int = 30 * 60
|
||||
|
||||
# Saved browser session settings
|
||||
|
||||
@@ -96,7 +96,11 @@ from skyvern.webeye.browser_factory import BrowserState
|
||||
from skyvern.webeye.utils.page import SkyvernFrame
|
||||
|
||||
LOG = structlog.get_logger()
|
||||
jinja_sandbox_env = SandboxedEnvironment(undefined=StrictUndefined)
|
||||
|
||||
if settings.WORKFLOW_TEMPLATING_STRICTNESS == "strict":
|
||||
jinja_sandbox_env = SandboxedEnvironment(undefined=StrictUndefined)
|
||||
else:
|
||||
jinja_sandbox_env = SandboxedEnvironment()
|
||||
|
||||
|
||||
# Mapping from TaskV2Status to the corresponding BlockStatus. Declared once at
|
||||
@@ -249,11 +253,12 @@ class Block(BaseModel, abc.ABC):
|
||||
if "workflow_run_id" not in template_data:
|
||||
template_data["workflow_run_id"] = workflow_run_context.workflow_run_id
|
||||
|
||||
if missing_variables := get_missing_variables(potential_template, template_data):
|
||||
raise MissingJinjaVariables(
|
||||
template=potential_template,
|
||||
variables=missing_variables,
|
||||
)
|
||||
if settings.WORKFLOW_TEMPLATING_STRICTNESS == "strict":
|
||||
if missing_variables := get_missing_variables(potential_template, template_data):
|
||||
raise MissingJinjaVariables(
|
||||
template=potential_template,
|
||||
variables=missing_variables,
|
||||
)
|
||||
|
||||
return template.render(template_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user