element

class virtualitics_sdk.elements.element.Element(_type, params, content, title='', description='', show_title=True, show_description=True, _id='', label='', placeholder='')

Bases: ABC

An Element in Predict.

Parameters:
  • _type (ElementType) – The type of element.

  • params (Dict[str, Any]) – The parameters for that element.

  • content (Union[dict, list, str]) – The content of the element.

  • _id (str) – The ID of the element, defaults to None.

  • title (str) – The title of the element, defaults to ‘’.

  • description (str) – The description of the element, defaults to ‘’.

  • show_title (bool) – Whether to show the title on the page when rendered, defaults to True.

  • show_description (bool) – Whether to show the description to the page when rendered, defaults to True.

  • label (str) – The label of the element, defaults to ‘’.

  • placeholder (str) – The placeholder of the element, defaults to ‘’.

activate()

Called when activating the card this element belongs to. Assigns unique a ID to the element.

add_comment(comment)
delete_comment(comment_id)
edit_comment(comment_id, new_comment_message, editor)
Return type:

Comment

get_comment(comment_id)
Return type:

Comment

save(link)

Save an element serialization into a Link.

Parameters:

link (Link) – The link to save the element to.

abstract set_content(content)

Validate and set content (python best practice is to set instance attributes in constructor).

Parameters:

kwargs – new content for the Element.

abstract set_params(params)

Validate and set params (python best practice is to set instance attributes in constructor).

Parameters:

kwargs – new params for the Element.

to_json()

Convert the element to a JSON.

Return type:

dict

Returns:

A JSON dictionary of the element.

class virtualitics_sdk.elements.element.ElementType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

ASSET_SELECTION = 'asset-select'
CUSTOM_EVENT = 'custom-event'
DASHBOARD = 'dashboard'
DATA_SOURCE = 'datasource'
DATE_TIME_RANGE = 'datetime-range'
DROPDOWN = 'dropdown'
FILTERS = 'filters'
IMAGE = 'image'
INFOGRAPHIC = 'infographic'
INPUT = 'input'
NUMERIC_RANGE = 'numeric-range'
PLOT = 'plot'
RICH_TEXT = 'rich-text'
TABLE = 'table'
TEXT_INPUT = 'text-input'
XAI_DASHBOARD = 'xai-dashboard'
class virtualitics_sdk.elements.element.InputElement(_type, params, content, title='', description='', show_title=True, show_description=True, label='', placeholder='')

Bases: Element

abstract get_value()

Get the value of an element. If the user has interacted with the value, the default will be updated.

Return type:

Union[str, dict, List[str]]

set_content(content)

Validate and set content.

Parameters:

content – New content for the element.

set_params(params)

Set params and validate keys.

Parameters:

params (dict) – New params for the Element.

abstract update_from_user_input(user_input)

Updates the element default values from user input.

Parameters:

user_input – Input from a user on the platform.