Element <execute>¶
Zweck: Führt vertrauenswürdigen Python-, SQL- oder Bash-Code aus einer URI, einem Ausdruck oder einem Inline-Body aus.
Warum: Verwende dieses Element an einer expliziten Vertrauensgrenze für Projektskripte oder clientbezogenes SQL.
Beispiel¶
1 | |
Entscheidungshilfe¶
Fachlicher Nutzen: Stellt eine explizite Vertrauensgrenze für Setup-Code oder clientbezogenes SQL bereit.
-
Verwenden, wenn
- Beim Ausführen eines geprüften Python-/Bash-Projektskripts oder expliziten SQLs.
-
Anderen Ansatz wählen, wenn
- Wenn ein eingebautes DSL-Element das Verhalten ausdrückt oder der Code nicht vertrauenswürdig ist.
-
Voraussetzungen
- Wähle genau eine Codequelle und liefere erforderliche Typ- oder Zielinformationen.
-
Alternativen
- Verwende generate für deklarative Datenerzeugung und Transformation. (Siehe:
<generate>) - Verwende assert für ein deklaratives hartes Quality Gate. (Siehe:
<assert>)
- Verwende generate für deklarative Datenerzeugung und Transformation. (Siehe:
Vollständige Beispiele¶
Eine zustandsbehaftete Generatorinstanz registrieren und wiederverwenden
Verwende einen benannten Generator, wenn mehrere Felder oder Tasks bewusst dieselbe konfigurierte Generatorinstanz statt unabhängiger Instanzen nutzen sollen.
| named-generator/script/preflight.scr.py | |
|---|---|
1 | |
| named-generator/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 | |
Regeln und ungültige Kombinationen¶
I614 — Parser Execute Invalid Source
Warum:
Lösung: Provide exactly one source: uri= for a file, script= with type=, or an inline element body.
I897 — Parser Execute Type Unresolved
Warum: The
Lösung: 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
Warum: The referenced client could not be found for the task configuration.
Lösung: 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.
Warum: The referenced script could not be found for the task configuration.
Lösung: 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}
Warum: SQL execution failed while running the
Lösung: Review client configuration, SQL statement, and database permissions before retrying.
I894 — Task Execute Bash Failed
Warum: The shell command run by
Lösung: Fix the shell command or its environment; inspect the reported stderr/exit code.
Inhaltsformen¶
uri— Load code from the uri attribute; the file extension determines its execution type.- Erforderliche Attribute:
uri script— Evaluate the script attribute to obtain the code to execute.- Erforderliche Attribute:
script inline— Use the element body as the code to execute.- Erforderliche Attribute: Keine
Erlaubte Elternelemente / Erlaubte Kindelemente¶
Erlaubte Elternelemente: else, else-if, if, nestedKey, setup, while
Erlaubte Kindelemente:
Keine
Zugehörige Konzepte und Anwendungsfälle¶
- Eigene Generatoren und Converter — Shows the trusted-code boundary and loader-provided base classes for project-local generators and converters without exposing internal import paths.
- Scripting-API in einem Modell verwenden — Shows all read-only scripting helpers together at their real expression-evaluation boundary.
Attribute¶
Alle 4 Attribute anzeigen
script
Expression whose evaluated string value IS the code to run. Needs type. Mutually exclusive with uri.
optional; string; Standardwert: null.
target
Client id to execute a SQL script against (e.g. a
optional; string; Standardwert: null.
type
Execution type for script= (python, sql or bash). Inferred from the extension for uri=.
optional; string; Standardwert: null; Werte: python, sql, bash.
uri
URI of a script file to execute (.py or .sql). Mutually exclusive with script.
optional; string; Standardwert: null.