Skip to content

downloadexpviscomponent

downloadexpviscomponent

module for download experiments

Classes

DownloadVisu

DownloadVisu(
    component_name=None,
    meta_function=None,
    target_value_list=None,
    assert_on_error=False,
)

Bases: ExpVisComponent

Visualization of the download dialog

Source code in niceml/dashboard/components/expviscomponent.py
def __init__(
    self,
    component_name: Optional[str] = None,
    meta_function: Optional[MetaFunction] = None,
    target_value_list: Optional[List[Any]] = None,
    assert_on_error: bool = False,
):
    # Create empty list for chart images
    self.component_name: Optional[str] = component_name
    self.chart_images_list: List[Image.Image] = []
    self.meta_function = meta_function
    self.target_value_list = [] if target_value_list is None else target_value_list
    self.assert_on_error = assert_on_error
Functions
create_download_zip staticmethod
create_download_zip(zip_directory, zip_path, filename)

Zip a directory and provide a download link to the zipped file within a streamlit application

Parameters:

  • zip_directory (str) –

    Path of the directory that should be zipped

  • zip_path (str) –

    Path of the directory that should contain the output zip file

  • filename (str) –

    Name of the generated zip file

Source code in niceml/dashboard/components/downloadexpviscomponent.py
@staticmethod
def create_download_zip(zip_directory: str, zip_path: str, filename: str):
    """
    Zip a directory and provide a download link to the zipped
    file within a streamlit application

    Args:
        zip_directory: Path of the directory that should be zipped
        zip_path: Path of the directory that should contain the
            output zip file
        filename: Name of the generated zip file
    """
    shutil.make_archive(zip_path, "zip", zip_directory)
    with open(f"{zip_path}.zip", "rb") as file:
        st.download_button(
            label="Download ZIP",
            data=file,
            file_name=filename,
            mime="application/zip",
        )

Functions