mbdlyb_ui.functional.clusters ============================= .. py:module:: mbdlyb_ui.functional.clusters .. autoapi-nested-parse:: Copyright (c) 2023 - 2026 TNO-ESI All rights reserved. Classes ------- .. autoapisummary:: mbdlyb_ui.functional.clusters.CPTImportPage mbdlyb_ui.functional.clusters.CPTImportProps mbdlyb_ui.functional.clusters.ClusterCreatePage mbdlyb_ui.functional.clusters.ClusterDetailPage mbdlyb_ui.functional.clusters.ClusterImportPage mbdlyb_ui.functional.clusters.ClusterImportProps mbdlyb_ui.functional.clusters.ClusterProps mbdlyb_ui.functional.clusters.ClusterUpdatePage mbdlyb_ui.functional.clusters.RequiredForTablePage Functions --------- .. autoapisummary:: mbdlyb_ui.functional.clusters.cluster_form mbdlyb_ui.functional.clusters.collect_cpts mbdlyb_ui.functional.clusters.copy_cluster mbdlyb_ui.functional.clusters.cpt_import_form mbdlyb_ui.functional.clusters.cpt_import_table mbdlyb_ui.functional.clusters.download_cpt mbdlyb_ui.functional.clusters.download_cpts mbdlyb_ui.functional.clusters.handle_cpt_file_contents mbdlyb_ui.functional.clusters.handle_cpt_upload mbdlyb_ui.functional.clusters.handle_cpt_xls_file mbdlyb_ui.functional.clusters.handle_cpt_zip_file mbdlyb_ui.functional.clusters.move_cluster mbdlyb_ui.functional.clusters.show_node_details Module Contents --------------- .. py:class:: CPTImportPage(cluster_id: str) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the CPT import probability table editor. .. py:attribute:: props :type: CPTImportProps .. py:class:: CPTImportProps(cluster: mbdlyb.functional.gdb.GCluster) Hold editable CPT import form state. .. py:method:: add_cpt(origin: str, node: mbdlyb.functional.gdb.GCPTEnabledNode, cpt: mbdlyb.cpt.CPT) Register an imported CPT and set its initial validation and enabled state. :param origin: Source identifier for the imported CPT. :param node: CPT-enabled node matched to the imported table. :param cpt: Conditional probability table to import. .. py:attribute:: cluster :type: mbdlyb.functional.gdb.GCluster .. py:attribute:: cpts :type: dict[str, tuple[mbdlyb.functional.gdb.GCPTEnabledNode, mbdlyb.cpt.CPT]] .. py:attribute:: enabled :type: dict[str, bool] .. py:attribute:: nodes :type: dict[mbdlyb.functional.gdb.GCPTEnabledNode, list[str]] .. py:attribute:: validation_msg :type: dict[mbdlyb.functional.gdb.GCPTEnabledNode, Optional[str]] .. py:class:: ClusterCreatePage(parent_cluster_id: Optional[str] = None) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the cluster create editing page. .. py:attribute:: cluster :type: mbdlyb.functional.gdb.GCluster .. py:property:: parent_cluster :type: Optional[mbdlyb.functional.gdb.GCluster] Return the selected parent cluster. :returns: Selected parent cluster. .. py:attribute:: props :type: ClusterProps .. py:class:: ClusterDetailPage(cluster_id: str) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the cluster detail properties and relations. .. py:attribute:: cluster :type: mbdlyb.functional.gdb.GCluster .. py:attribute:: mmb :type: mbdlyb_ui.mermaid.MermaidBuilder .. py:class:: ClusterImportPage(cluster_id: Optional[str] = None) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the cluster import editing page. .. py:attribute:: parent :type: Optional[mbdlyb.gdb.GMBDNet] .. py:attribute:: progress_bar :type: nicegui.ui.linear_progress .. py:attribute:: props :type: ClusterImportProps .. py:attribute:: queue :type: multiprocessing.Queue .. py:attribute:: timer :type: nicegui.ui.timer .. py:class:: ClusterImportProps(parent: Optional[mbdlyb.gdb.GMBDNet] = None, capella_architecture: Optional[str] = None, default_fn_tests: bool = False, default_hl_fn_tests: bool = False, default_hw_tests: bool = False, default_ll_hw_tests: bool = False, import_opms: bool = False) Hold editable cluster import form state. .. py:attribute:: capella_architecture :value: None .. py:attribute:: default_fn_tests :value: False .. py:attribute:: default_hl_fn_tests :value: False .. py:attribute:: default_hw_tests :value: False .. py:attribute:: default_ll_hw_tests :value: False .. py:attribute:: files :type: list[pathlib.Path] :value: [] .. py:attribute:: import_opms :value: False .. py:attribute:: parent :value: None .. py:class:: ClusterProps(add_hw: bool, add_fn: bool) Hold editable cluster form state. .. py:attribute:: DEFAULT_FUNCTION_NAME :value: 'MainFunction' .. py:attribute:: add_fn .. py:attribute:: add_hw .. py:attribute:: fn_name :type: str :value: '' .. py:attribute:: hw_name :type: str :value: '' .. py:class:: ClusterUpdatePage(cluster_id: str) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the cluster update editing page. .. py:class:: RequiredForTablePage(cluster_id: str) Bases: :py:obj:`mbdlyb_ui.functional.base.FunctionalPage` Display the required for table relation table. .. py:attribute:: cluster :type: mbdlyb.functional.gdb.GCluster .. py:attribute:: functions :type: list[mbdlyb.functional.gdb.GFunction] .. py:function:: cluster_form(cluster: mbdlyb.functional.gdb.GCluster, props: Optional[ClusterProps] = None, parent: Optional[mbdlyb.functional.gdb.GCluster] = None, update: bool = True) Render the cluster name and optional default hardware and function controls. :param cluster: Cluster whose name is edited in the form. :param props: Options for adding default function and hardware to a new cluster. :param parent: Optional parent cluster for the new cluster. :param update: Whether to edit an existing cluster instead of creating one. .. py:function:: collect_cpts(cluster: mbdlyb.functional.gdb.GCluster, only_required: bool = True) -> dict[mbdlyb.functional.gdb.GFunctionalNode, mbdlyb.cpt.CPT] Collect conditional probability tables recursively from a cluster. :param cluster: Cluster to search recursively for eligible CPT nodes. :param only_required: Whether to include only nodes needing or defining a CPT. :returns: Mapping of eligible nodes to their conditional probability tables. .. py:function:: copy_cluster(obj) -> None Ask for confirmation before cloning a cluster and its relations. :param obj: Cluster whose graph and relations are cloned after confirmation. .. py:function:: cpt_import_form(props: CPTImportProps) Render the CPT upload control and the resulting import table. :param props: CPT import state bound to the uploader and table. .. py:function:: cpt_import_table(props: CPTImportProps) Display candidate CPTs and their validation and origin controls. :param props: Uploaded CPT candidates, enabled sources, and validation messages. .. py:function:: download_cpt(node: mbdlyb.functional.gdb.GCPTEnabledNode) Download the node's conditional probability table as a spreadsheet. :param node: CPT-enabled node whose table is downloaded. .. py:function:: download_cpts(cluster: mbdlyb.functional.gdb.GCluster, only_required: bool = True) Package the cluster's conditional probability tables into a ZIP download. :param cluster: Cluster whose descendant CPTs are packaged for download. :param only_required: Whether to include only nodes needing or defining a CPT. .. py:function:: handle_cpt_file_contents(filename: str, contents: io.BytesIO, props: CPTImportProps, origin: str = None) Resolve and validate a spreadsheet against its matching CPT node. :param filename: Name of the uploaded spreadsheet. :param contents: Spreadsheet contents to parse. :param props: Import state used to match and validate this CPT. :param origin: ZIP member path or uploaded filename identifying the CPT source. .. py:function:: handle_cpt_upload(e: nicegui.events.MultiUploadEventArguments, props: CPTImportProps) :async: Process each uploaded CPT file and refresh the import table. :param e: Multi-upload event containing CPT spreadsheets or ZIP archives. :param props: Import state to update with uploaded CPTs. .. py:function:: handle_cpt_xls_file(f: nicegui.ui.upload.FileUpload, props: CPTImportProps) :async: Read and process an uploaded CPT spreadsheet. :param f: Uploaded file to read. :param props: Import settings and uploaded CPT candidates. .. py:function:: handle_cpt_zip_file(f: nicegui.ui.upload.FileUpload, props: CPTImportProps) :async: Read CPT spreadsheets from an uploaded ZIP archive. :param f: Uploaded file to read. :param props: Import settings and uploaded CPT candidates. .. py:function:: move_cluster(obj) -> None Offer eligible parent clusters and move the selected cluster on confirmation. :param obj: Cluster whose parent can be changed. .. py:function:: show_node_details(node: Optional[mbdlyb.functional.gdb.GFunctionalNode | mbdlyb.functional.gdb.GCluster] = None) Render details and actions for the selected functional node. :param node: Selected tree node whose details are displayed.