Skip to main content

ContextArgs (class)

ContextArgs is the class type of the "sqrl" argument for the main function of context.py, which runs per (uncached) API request for data results.

The class can be imported from the squirrels.arguments or squirrels module.

Attributes​

Attributes of ContextArgs that can be accessed.

project_path​

The path to the project directory.

Type: str

proj_vars​

A dictionary to access a project variable defined in squirrels.yml.

Type: dict[str, Any]

env_vars​

A dictionary of environment variables.

Type: dict[str, str]

user​

The authenticated user of type BaseUser or User (defined in user.py, if applicable), or None if no user authenticated.

Type: BaseUser | None

prms​

A dictionary of Parameter objects (containing the real-time parameter selections) by parameter name.

Type: dict[str, squirrels.types.Parameter]

traits​

A dictionary of the dataset traits.

Type: dict[str, Any]

Methods​

Methods that can be invoked from ContextArgs.

set_placeholder​

def set_placeholder(self, placeholder: str, value: squirrels.types.TextValue | Any) -> str:

Sets a placeholder value, including a TextValue object.

Required Arguments:

  • placeholder: A string for the placeholder name
  • value: A value (a TextValue object or any primitive type) for the placeholder.

Returns: An empty string

param_exists​

def param_exists(self, param_name: str) -> bool:

Checks whether a parameter exists and is enabled

Required Arguments:

  • param_name: A string for the parameter name

Returns: A boolean for whether the parameter name exists and is enabled