ModuleBuilder¶
Import and run a Python module as a builder.
Use this to integrate reusable external scripts that define the model logic. Helpful for sharing build logic across multiple projects.
Bases: BaseBuilder
Builder that dynamically imports a module and calls a specified function.
This allows you to build HFSS models using external, version-controlled scripts. Especially useful for reusable templates and team collaboration.
The imported function must have the following signature:
def build(hfss: Hfss, **kwargs) -> dict:
...
hfss
: The active HFSS session object.**kwargs
: Arbitrary keyword arguments, typically containing build parameters.- The function must return a dictionary with any results or output parameters.
Example
Attributes:
Name | Type | Description |
---|---|---|
type |
Literal['module_builder']
|
Identifier for this builder type. |
module |
str
|
Python module path (e.g., 'mypkg.submodule'). |
function |
str
|
Name of the function in the module to call (default: 'build'). |
args |
dict
|
Static arguments passed to the function. |
build ¶
Import the specified module, call its build function with merged arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hfss
|
Hfss
|
Active HFSS session. |
required |
parameters
|
dict | None
|
Runtime arguments to merge with predefined |
None
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Output of the module's function call. |
Raises:
Type | Description |
---|---|
ImportError
|
If the module or function cannot be imported. |
Exception
|
Any exception raised by the user-supplied function will propagate up. |