Skip to content

selectionviscomponent

selectionviscomponent

Module for SelectionVisComponent for the dashboard

Classes

SelectionVisComponent

SelectionVisComponent(
    component_name,
    vis_components,
    expanded=False,
    subset_names=None,
    use_subset_selection=True,
    **kwargs
)

Bases: ExpVisComponent

Dashboard component where one can select one subcomponent to visualize

Source code in niceml/dashboard/components/selectionviscomponent.py
def __init__(  # pylint: disable=too-many-arguments
    self,
    component_name: str,
    vis_components: List[SingleExpVisComponent],
    expanded: bool = False,
    subset_names: Optional[List[str]] = None,
    use_subset_selection: bool = True,
    **kwargs,
):
    super().__init__(component_name=component_name, **kwargs)
    self.vis_components: List[SingleExpVisComponent] = vis_components
    self.expanded = expanded
    self.subset_names = subset_names or get_eval_save_names()
    self.use_subset_selection = use_subset_selection
Functions
get_exp_id_and_subset_name
get_exp_id_and_subset_name(exp_ids)

Gets the experiment id and subset name from the user selection via streamlit

Source code in niceml/dashboard/components/selectionviscomponent.py
def get_exp_id_and_subset_name(self, exp_ids: List[str]) -> Tuple[str, str]:
    """Gets the experiment id and subset name from the user selection via streamlit"""
    if self.use_subset_selection:
        col1, col2 = st.columns(2)
        exp_id = col1.selectbox(
            "Select ExpID",
            options=exp_ids,
            key=f"selectbox-expid-{self.component_name}",
        )
        subset_name = col2.selectbox(
            "Select subset",
            options=self.subset_names,
            key=f"selectbox-subset" f"-{self.component_name}",
        )
    else:
        exp_id = st.selectbox(
            "Select ExpID",
            options=exp_ids,
            key=f"selectbox-expid-{self.component_name}",
        )
        subset_name = ""

    return exp_id, subset_name
get_images
get_images()

Returns images from subcomponents

Source code in niceml/dashboard/components/selectionviscomponent.py
def get_images(self) -> List[Image.Image]:
    """Returns images from subcomponents"""
    images: List[Image.Image] = []
    for _, vis_comp in self.vis_components:
        images += vis_comp.get_images()
    return images

Functions