page

class virtualitics_sdk.page.page.Page(title, type, metadata, sections)

Bases: ABC

The Page for a Step.

Parameters:
  • title (str) – The title of the Page.

  • type (PageType) – The page type (soon to be deprecated).

  • metadata (dict) – The metadata for the page.

  • sections (List[Section]) – The sections contained inside the Page.

activate()

Called when activating the step this page belongs to. Assigns unique IDs to everything in the page.

add_card_to_section(card, section_title)

Adds a Card to a specified section.

Parameters:
  • card (Card) – The Card to add.

  • section_title (str) – The title of the section the Card will be added to.

Raises:

ValueError – if no section with that title is found on the page.

add_content_to_section(elems, section_title, card_title='', card_subtitle='', card_description='', card_id='', show_card_title=True, show_card_description=True, page_update=None)

Adds content to a section. This adds the specified elements into a single Card on a Section.

Parameters:
  • elems (Union[Element, List[Element], List[Row]]) – The elements to add to the new Card in this Section.

  • section_title (str) – The title of the section to add elements to.

  • card_title (str) – The card title for the new card to be added, defaults to “”.

  • card_subtitle (str) – The subtitle for the new card to be added, defaults to “”.

  • card_description (str) – The description for the new card to be added, defaults to “”.

  • card_id (str) – The ID of the new card to be added, defaults to “”.

  • show_card_title (bool) – whether to show the title of the card on the page when rendered, defaults to True.

  • show_card_description (bool) – whether to show the description of the card to the page when rendered, defaults to True.

  • page_update (Optional[Callable]) – The page update function for the new card, defaults to None.

Raises:

ValueError – if the section title is not found on the Page.

property elements: Iterator[Element]
get_card_by_id(card_id)

Returns the Card on a Page with a specified ID.

Parameters:

card_id (str) – The ID of the card.

Raises:

CardNotFoundException – if no card exists with the specified ID.

Return type:

Card

get_card_by_title(card_title, quiet=False)

Returns the Element on a Page with a specified ID.

Parameters:
  • card_title (str) – The title of the card.

  • quiet (bool) – If True, return None if Card is not found. Defaults to False

Raises:

CardNotFoundException – if no card exists with the specified title and quiet is False.

Return type:

Card

get_element_by_id(elem_id)

Returns the Element on a Page with a specified ID.

Parameters:

elem_id (str) – The title of the element.

Raises:

ValueError – if no element exists with the specified title.

Return type:

Element

get_element_by_title(elem_title, quiet=False)

Returns the first Element on a Page with a specified title.

Parameters:
  • elem_title (str) – The title of the section to retrieve.

  • quiet (bool) – If True, return None if element is not found. Defaults to False

Raises:

ValueError – if no element exists with the specified title.

Return type:

Element

get_section_by_title(section_title)

Returns the first Section on a Page with a specified title.

Parameters:

section_title (str) – The title of the section to retrieve.

Raises:

ValueError – if no section exists with the specified title.

Return type:

Section

property has_required_input: bool
remove_card(section_title, card_title)

Remove a card from a Page. This can be called inside dynamic pages to restructure a Page. If no card exists with that title, the page will not be changed and this function will not error.

Parameters:
  • section_title (str) – The section on the page where the Card should be removed

  • card_title (str) – The title of the Card to be removed

Raises:

ValueError – If the section title does not exist on the pageQ

replace_content_in_section(elems, section_title, card_title, card_subtitle='', card_description='', show_card_title=True, show_card_description=True, page_update=None, filter_update=None, as_columns=False)

Replaces the content on a card with new content. If that card doesn’t exist, it will add the card to the section. It’s highly recommended to use this function inside of page updates because no matter how many times the page is updated, only one card will be shown.

Parameters:
  • elems (Union[Element, List[Element], List[Row]]) – The elements to replace the card with

  • section_title (str) – The title of the section the new card should exist in

  • card_title (str) – The title of the card

  • card_subtitle (str) – The subtitle of the card, defaults to “”

  • card_description (str) – The description of the card, defaults to “”

  • show_card_title (bool) – whether to show the title of the card on the page when rendered, defaults to True

  • show_card_description (bool) – whether to show the description of the card to the page when rendered, defaults to True

  • page_update (Optional[Callable]) – The page update function for the new card, defaults to None.

  • filter_update (Optional[Callable]) – The filter update function for the new card, defaults to None.

  • as_columns – whether to add content in columns instead of rows, defaults to False.

save(link, is_ssf=False, user=None)
property sections: List[Section]

Return the sections of a Page.

Returns:

The sections on a given Page.

serialize()
update_card_title(new_card_title, card_title=None, card_id=None)

Update the title of card using the card_title or the card_id

Parameters:
  • new_card_title (str) – The new title of the card.

  • card_title (Optional[str]) – The title of the card, defaults to None.

  • card_id (Optional[str]) – The ID of the card, defaults to None.

Raises:
  • PredictException – If card_title or card_id are not specified.

  • CardNotFoundException – if no card exists with the specified title or ID.

class virtualitics_sdk.page.page.PageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

DATA_LAB = 'datalab'
INPUT = 'input'
RESULTS = 'results'