Skip to main content

Func

Represents a function in the Datagrok platform. In Grok, nearly every executable action—whether it's a data query, a script, a UI action, or a predictive model—is represented as a Func. This unified abstraction provides a consistent way to define, discover, secure, and execute platform capabilities. Examples of functions in Grok include: * Querying an external PostgreSQL database * Executing JavaScript code in the browser that uses Grok APIs * Performing mathematical calculations (e.g., Sin(PI)) * Modifying datasets (e.g., deleting a column) * Sending an email * Applying a predictive model to a dataset * Calculating molecular properties via a Python script * Displaying interactive dialogs Despite their differences (server-side vs client-side execution, computational vs UI-based tasks), all functions share a common set of capabilities: * Scriptable: Callable from the console or scripts. * Findable: Searchable through the "Help | Functions" interface. * Introspectable: Metadata about parameters is programmatically accessible. * Secure: Access can be restricted via privileges or user groups. * Auditable: Execution history and parameters are tracked. * Runnable: The platform can dynamically generate UI for parameters. * Linkable: Functions can be linked in dashboards, conversations, etc. * Composable: Usable in workflow designers and query transformations.

Attributes

NameTypeDescription
sourceOptional[str]Identifies the origin or type of function (e.g., "function", "sql-query", "js-script").
optionsOptional[Dict[str, Any]]Arbitrary function-specific configuration options.
tagsOptional[List[str]]Keywords or categories associated with the function.
descriptionOptional[str]A human-readable description of the function's purpose.
paramsOptional[List[FuncParam]]List of parameter definitions for the function. **kwargs Additional arguments passed to the parent NamedModel initializer, such as id, name, friendly_name, created_on, updated_on, and namespace.
paramslist of FuncParamParameter definitions (both input and output).
sourcestrFunction type or origin.
tagslist of strFunction categories or keywords.
descriptionstrHuman-readable description.
optionsdictFunction-specific settings.
input_paramslist of FuncParamParameters marked as inputs to the function.
output_paramslist of FuncParamParameters marked as outputs from the function.

Methods

__init__()

input_params()

output_params()

to_dict()

register_subclass()

from_dict()