mbdlyb_ui.functional.clusters

Copyright (c) 2023 - 2026 TNO-ESI All rights reserved.

Classes

CPTImportPage

Display the CPT import probability table editor.

CPTImportProps

Hold editable CPT import form state.

ClusterCreatePage

Display the cluster create editing page.

ClusterDetailPage

Display the cluster detail properties and relations.

ClusterImportPage

Display the cluster import editing page.

ClusterImportProps

Hold editable cluster import form state.

ClusterProps

Hold editable cluster form state.

ClusterUpdatePage

Display the cluster update editing page.

RequiredForTablePage

Display the required for table relation table.

Functions

cluster_form(cluster[, props, parent, update])

Render the cluster name and optional default hardware and function controls.

collect_cpts(...)

Collect conditional probability tables recursively from a cluster.

copy_cluster(→ None)

Ask for confirmation before cloning a cluster and its relations.

cpt_import_form(props)

Render the CPT upload control and the resulting import table.

cpt_import_table(props)

Display candidate CPTs and their validation and origin controls.

download_cpt(node)

Download the node's conditional probability table as a spreadsheet.

download_cpts(cluster[, only_required])

Package the cluster's conditional probability tables into a ZIP download.

handle_cpt_file_contents(filename, contents, props[, ...])

Resolve and validate a spreadsheet against its matching CPT node.

handle_cpt_upload(e, props)

Process each uploaded CPT file and refresh the import table.

handle_cpt_xls_file(f, props)

Read and process an uploaded CPT spreadsheet.

handle_cpt_zip_file(f, props)

Read CPT spreadsheets from an uploaded ZIP archive.

move_cluster(→ None)

Offer eligible parent clusters and move the selected cluster on confirmation.

show_node_details([node])

Render details and actions for the selected functional node.

Module Contents

class mbdlyb_ui.functional.clusters.CPTImportPage(cluster_id: str)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the CPT import probability table editor.

props: CPTImportProps
class mbdlyb_ui.functional.clusters.CPTImportProps(cluster: mbdlyb.functional.gdb.GCluster)

Hold editable CPT import form state.

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.

Parameters:
  • origin – Source identifier for the imported CPT.

  • node – CPT-enabled node matched to the imported table.

  • cpt – Conditional probability table to import.

cluster: mbdlyb.functional.gdb.GCluster
cpts: dict[str, tuple[mbdlyb.functional.gdb.GCPTEnabledNode, mbdlyb.cpt.CPT]]
enabled: dict[str, bool]
nodes: dict[mbdlyb.functional.gdb.GCPTEnabledNode, list[str]]
validation_msg: dict[mbdlyb.functional.gdb.GCPTEnabledNode, str | None]
class mbdlyb_ui.functional.clusters.ClusterCreatePage(parent_cluster_id: str | None = None)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the cluster create editing page.

cluster: mbdlyb.functional.gdb.GCluster
property parent_cluster: mbdlyb.functional.gdb.GCluster | None

Return the selected parent cluster.

Returns:

Selected parent cluster.

props: ClusterProps
class mbdlyb_ui.functional.clusters.ClusterDetailPage(cluster_id: str)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the cluster detail properties and relations.

cluster: mbdlyb.functional.gdb.GCluster
mmb: mbdlyb_ui.mermaid.MermaidBuilder
class mbdlyb_ui.functional.clusters.ClusterImportPage(cluster_id: str | None = None)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the cluster import editing page.

parent: mbdlyb.gdb.GMBDNet | None
progress_bar: nicegui.ui.linear_progress
props: ClusterImportProps
queue: multiprocessing.Queue
timer: nicegui.ui.timer
class mbdlyb_ui.functional.clusters.ClusterImportProps(parent: mbdlyb.gdb.GMBDNet | None = None, capella_architecture: str | None = 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.

capella_architecture = None
default_fn_tests = False
default_hl_fn_tests = False
default_hw_tests = False
default_ll_hw_tests = False
files: list[pathlib.Path] = []
import_opms = False
parent = None
class mbdlyb_ui.functional.clusters.ClusterProps(add_hw: bool, add_fn: bool)

Hold editable cluster form state.

DEFAULT_FUNCTION_NAME = 'MainFunction'
add_fn
add_hw
fn_name: str = ''
hw_name: str = ''
class mbdlyb_ui.functional.clusters.ClusterUpdatePage(cluster_id: str)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the cluster update editing page.

class mbdlyb_ui.functional.clusters.RequiredForTablePage(cluster_id: str)

Bases: mbdlyb_ui.functional.base.FunctionalPage

Display the required for table relation table.

cluster: mbdlyb.functional.gdb.GCluster
functions: list[mbdlyb.functional.gdb.GFunction]
mbdlyb_ui.functional.clusters.cluster_form(cluster: mbdlyb.functional.gdb.GCluster, props: ClusterProps | None = None, parent: mbdlyb.functional.gdb.GCluster | None = None, update: bool = True)

Render the cluster name and optional default hardware and function controls.

Parameters:
  • cluster – Cluster whose name is edited in the form.

  • props – Options for adding default function and hardware to a new cluster.

  • parent – Optional parent cluster for the new cluster.

  • update – Whether to edit an existing cluster instead of creating one.

mbdlyb_ui.functional.clusters.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.

Parameters:
  • cluster – Cluster to search recursively for eligible CPT nodes.

  • only_required – Whether to include only nodes needing or defining a CPT.

Returns:

Mapping of eligible nodes to their conditional probability tables.

mbdlyb_ui.functional.clusters.copy_cluster(obj) → None

Ask for confirmation before cloning a cluster and its relations.

Parameters:

obj – Cluster whose graph and relations are cloned after confirmation.

mbdlyb_ui.functional.clusters.cpt_import_form(props: CPTImportProps)

Render the CPT upload control and the resulting import table.

Parameters:

props – CPT import state bound to the uploader and table.

mbdlyb_ui.functional.clusters.cpt_import_table(props: CPTImportProps)

Display candidate CPTs and their validation and origin controls.

Parameters:

props – Uploaded CPT candidates, enabled sources, and validation messages.

mbdlyb_ui.functional.clusters.download_cpt(node: mbdlyb.functional.gdb.GCPTEnabledNode)

Download the node’s conditional probability table as a spreadsheet.

Parameters:

node – CPT-enabled node whose table is downloaded.

mbdlyb_ui.functional.clusters.download_cpts(cluster: mbdlyb.functional.gdb.GCluster, only_required: bool = True)

Package the cluster’s conditional probability tables into a ZIP download.

Parameters:
  • cluster – Cluster whose descendant CPTs are packaged for download.

  • only_required – Whether to include only nodes needing or defining a CPT.

mbdlyb_ui.functional.clusters.handle_cpt_file_contents(filename: str, contents: io.BytesIO, props: CPTImportProps, origin: str = None)

Resolve and validate a spreadsheet against its matching CPT node.

Parameters:
  • filename – Name of the uploaded spreadsheet.

  • contents – Spreadsheet contents to parse.

  • props – Import state used to match and validate this CPT.

  • origin – ZIP member path or uploaded filename identifying the CPT source.

async mbdlyb_ui.functional.clusters.handle_cpt_upload(e: nicegui.events.MultiUploadEventArguments, props: CPTImportProps)

Process each uploaded CPT file and refresh the import table.

Parameters:
  • e – Multi-upload event containing CPT spreadsheets or ZIP archives.

  • props – Import state to update with uploaded CPTs.

async mbdlyb_ui.functional.clusters.handle_cpt_xls_file(f: nicegui.ui.upload.FileUpload, props: CPTImportProps)

Read and process an uploaded CPT spreadsheet.

Parameters:
  • f – Uploaded file to read.

  • props – Import settings and uploaded CPT candidates.

async mbdlyb_ui.functional.clusters.handle_cpt_zip_file(f: nicegui.ui.upload.FileUpload, props: CPTImportProps)

Read CPT spreadsheets from an uploaded ZIP archive.

Parameters:
  • f – Uploaded file to read.

  • props – Import settings and uploaded CPT candidates.

mbdlyb_ui.functional.clusters.move_cluster(obj) → None

Offer eligible parent clusters and move the selected cluster on confirmation.

Parameters:

obj – Cluster whose parent can be changed.

mbdlyb_ui.functional.clusters.show_node_details(node: mbdlyb.functional.gdb.GFunctionalNode | mbdlyb.functional.gdb.GCluster | None = None)

Render details and actions for the selected functional node.

Parameters:

node – Selected tree node whose details are displayed.