Script
Represents a script-based function in the Datagrok platform. Script is a specialized subclass of Func that encapsulates executable code written in a supported scripting language. Scripts can be run in various environments (server-side or client-side) depending on the language and platform configuration.
Examples
Creating and serializing a Python script function:
>>> script_code = "print('Hello from Datagrok!')"
>>> s = Script(script=script_code, language=ScriptLanguage.Python, name="Hello Script")
>>> s.to_dict()
... {
... "id": None,
... "name": "Hello Script",
... "friendlyName": None,
... "createdOn": None,
... "updatedOn": None,
... "source": "script",
... "description": None,
... "params": [],
... "namespace": None,
... "tags": [],
... "options": {},
... "script": "print('Hello from Datagrok!')",
... "language": "python"
... }
Attributes
| Name | Type | Description |
|---|---|---|
| script | str | The source code of the script. Can contain special annotations that will be parsed by platform into script paramerters. |
| language | ScriptLanguage, optional | The language in which the script is written. Defaults to ScriptLanguage.Python. **kwargs Additional arguments passed to the base Func class, such as: - id : Optional[str] - name : Optional[str] - friendly_name : Optional[str] - description : Optional[str] - created_on : Optional[datetime] - updated_on : Optional[datetime] - params : Optional[List[FuncParam]] - namespace : Optional[str] - tags : Optional[List[str]] - options : Optional[Dict[str, Any]] |
| script | str | The script source code. |
| language | ScriptLanguage | The programming language used for the script. |