Element <execute>¶
Purpose: Execute trusted Python, SQL, or Bash code from a URI, expression, or inline body.
Why: Use it at an explicit trusted-code boundary for project scripts or client-targeted SQL.
Example¶
1 | |
Decision guide¶
Business value: Provides an explicit trust boundary for setup code or client-targeted SQL that cannot be expressed declaratively.
-
Use when
- Running a reviewed project Python or Bash script, or explicit SQL against a configured client.
-
Choose another approach when
- A built-in DSL element already expresses the behavior or the code is not trusted.
-
Prerequisites
- Choose exactly one code source and provide type or target information where required.
-
Alternatives
- Use generate for declarative record production and transformation. (See:
<generate>) - Use assert for a declarative hard quality gate. (See:
<assert>)
- Use generate for declarative record production and transformation. (See:
Complete examples¶
Register and reuse one stateful generator instance
Use a named generator when several fields or tasks must deliberately share one configured generator instance rather than create independent instances.
| named-generator/script/preflight.scr.py | |
|---|---|
1 | |
| named-generator/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 | |
Rules and invalid combinations¶
I614 β Parser Execute Invalid Source
Why:
Resolution: Provide exactly one source: uri= for a file, script= with type=, or an inline element body.
I897 β Parser Execute Type Unresolved
Why: The
Resolution: Set type= (python, sql, or bash), or use a uri with a recognised extension.
I823 β Task Execute Client Not Found
Client '{client_id}' not found for
Why: The referenced client could not be found for the task configuration.
Resolution: Ensure the referenced client exists and the identifier/path is correct.
I824 β Task Execute Script Not Found
Script file '{script_name}' not found in task workspace. Check your project environment configuration or uploaded script assets.
Why: The referenced script could not be found for the task configuration.
Resolution: Ensure the referenced script exists and the identifier/path is correct.
I873 β Task Execute SQL Failed
Failed to execute SQL script '{script_name}' on client '{client_id}': {error_type}{error_code_hint}{error_category_hint}: {error}
Why: SQL execution failed while running the
Resolution: Review client configuration, SQL statement, and database permissions before retrying.
I894 β Task Execute Bash Failed
Why: The shell command run by
Resolution: Fix the shell command or its environment; inspect the reported stderr/exit code.
Content forms¶
uriβ Load code from the uri attribute; the file extension determines its execution type.- Required attributes:
uri scriptβ Evaluate the script attribute to obtain the code to execute.- Required attributes:
script inlineβ Use the element body as the code to execute.- Required attributes: None
Allowed parents / Allowed children¶
Allowed parents: else, else-if, if, nestedKey, setup, while
Allowed children:
None
Related concepts and use cases¶
- Custom Generators and Converters β Shows the trusted-code boundary and loader-provided base classes for project-local generators and converters without exposing internal import paths.
- Use the Scripting API in a Model β Shows all read-only scripting helpers together at their real expression-evaluation boundary.
Attributes¶
Show all 4 attributes
script
Expression whose evaluated string value IS the code to run. Needs type. Mutually exclusive with uri.
optional; string; Default: null.
target
Client id to execute a SQL script against (e.g. a
optional; string; Default: null.
type
Execution type for script= (python, sql or bash). Inferred from the extension for uri=.
optional; string; Default: null; Values: python, sql, bash.
uri
URI of a script file to execute (.py or .sql). Mutually exclusive with script.
optional; string; Default: null.