openstb.simulator.plugin.loader
Support for finding and loading plugins.
Type Aliases:
| Name | Description |
|---|---|
PluginLoader |
A callable which takes a plugin or specification and returns a plugin. |
Classes:
| Name | Description |
|---|---|
PluginSpec |
Specification for a plugin. |
Functions:
| Name | Description |
|---|---|
config_loader |
Load a configuration loader plugin. |
controller |
Load a simulation controller plugin. |
dask_cluster |
Load a Dask cluster plugin. |
distortion |
Load a distortion plugin. |
environment |
Load a environment plugin. |
load_plugin |
Load a plugin and create an instance of it. |
load_plugin_class |
Load a plugin class. |
ping_times |
Load a ping time plugin. |
point_targets |
Load a point targets plugin. |
register_loader |
Decorator to register a plugin loading function. |
registered_plugins |
List registered plugins. |
result_converter |
Load a result converter plugin. |
scattering_model |
Load a scattering model plugin. |
signal |
Load a signal plugin. |
signal_window |
Load a signal window plugin. |
system |
Load a system plugin. |
trajectory |
Load a trajectory plugin. |
transducer |
Load a transducer plugin. |
travel_time |
Load a travel time plugin. |
Attributes:
| Name | Type | Description |
|---|---|---|
registered_loaders |
dict[type, PluginLoader]
|
Available plugin loader functions. |
registered_loaders
module-attribute
registered_loaders = {}
Available plugin loader functions.
PluginLoader
PluginLoader = Callable[[PluginSpec | T], T]
A callable which takes a plugin or specification and returns a plugin.
PluginSpec
Bases: TypedDict
Specification for a plugin.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the plugin. |
parameters |
Mapping[str, Any]
|
Parameters for the plugin. |
spec_source |
NotRequired[str | PathLike[str]]
|
Source of this specification. |
name
instance-attribute
name
Name of the plugin.
This can be in any format supported by the load_plugin_class function.
parameters
instance-attribute
parameters
Parameters for the plugin.
spec_source
instance-attribute
spec_source
Source of this specification.
For example the configuration file it was loaded from. This may be used for error reporting, and it may also be used by the plugin if it needs to load data based on the original source (e.g., from a file with a filename relative to the original configuration file).
config_loader
config_loader(plugin_spec)
Load a configuration loader plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | ConfigLoader
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
ConfigLoader
|
The configuration loader instance. |
Source code in openstb/simulator/plugin/loader.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
controller
controller(plugin_spec)
Load a simulation controller plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Controller
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Controller
|
The simulation controller instance. |
Source code in openstb/simulator/plugin/loader.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
dask_cluster
dask_cluster(plugin_spec)
Load a Dask cluster plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | DaskCluster
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
DaskCluster
|
The Dask cluster instance. |
Source code in openstb/simulator/plugin/loader.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
distortion
distortion(plugin_spec)
Load a distortion plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Distortion
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Distortion
|
The distortion instance. |
Source code in openstb/simulator/plugin/loader.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
environment
environment(plugin_spec)
Load a environment plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Environment
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Environment
|
The environment instance. |
Source code in openstb/simulator/plugin/loader.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
load_plugin
load_plugin(group, plugin_spec)
Load a plugin and create an instance of it.
In general, you should call one of the more specific functions in this module to load the particular type of plugin you want.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str
|
The name of the entry point group that the plugin belongs to, e.g., "openstb.simulator.trajectory". |
required |
plugin_spec
|
PluginSpec | T
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
instance |
Plugin
|
If a plugin specification dictionary was given, an instance of the plugin it defined. Otherwise, the input object is returned unchanged. |
Source code in openstb/simulator/plugin/loader.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
load_plugin_class
load_plugin_class(group, name)
Load a plugin class.
Three formats are supported for the name of the plugin:
-
The name of an installed plugin registered under the entry point group.
-
A reference to an attribute name and the importable module it belongs to. The name "FromDisk:my_plugins.trajectories" effectively corresponds to this function being
from my_plugins.trajectories import FromDisk; return FromDisk. -
The name of an attribute in a Python file and the path of the file. The name "FromDisk:/path/to/my_plugins.py" results in the function dynamically importing the
/path/to/my_plugins.pyfile and returning theFromDiskattribute from it. Note that relative paths will be resolved relative to the current working directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str
|
The name of the entry point group that the plugin belongs to, e.g., "openstb.simulator.trajectory". |
required |
name
|
str
|
The user-specified name of the plugin. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
plugin |
class
|
|
Source code in openstb/simulator/plugin/loader.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
ping_times
ping_times(plugin_spec)
Load a ping time plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | PingTimes
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
PingTimes
|
The ping times instance. |
Source code in openstb/simulator/plugin/loader.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
point_targets
point_targets(plugin_spec)
Load a point targets plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | PointTargets
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
PointTargets
|
The point targets instance. |
Source code in openstb/simulator/plugin/loader.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
register_loader
register_loader(loader)
Decorator to register a plugin loading function.
This should be applied to a function which takes a
openstb.simulator.types.PluginOrSpec parameter and returns a plugin instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loader
|
PluginLoader[T]
|
The loader to register. |
required |
Returns:
| Type | Description |
|---|---|
PluginLoader
|
The original loader. |
Source code in openstb/simulator/plugin/loader.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
registered_plugins
registered_plugins(group, load=False)
List registered plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str
|
The name of the entry point group to list plugins for, e.g., "openstb.simulator.trajectory". |
required |
load
|
bool
|
If True, include the loaded plugins in the return. If False, only report the name and source of each plugin. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
installed |
list
|
A list of (name, src) tuples where name is the name the plugin is registered as
and src is the reference to the module and class implementing the plugin. If
|
Source code in openstb/simulator/plugin/loader.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
result_converter
result_converter(plugin_spec)
Load a result converter plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | ResultConverter
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
ResultConverter
|
The result converter instance. |
Source code in openstb/simulator/plugin/loader.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
scattering_model
scattering_model(plugin_spec)
Load a scattering model plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | ScatteringModel
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
ScatteringModel
|
The scattering model instance. |
Source code in openstb/simulator/plugin/loader.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
signal
signal(plugin_spec)
Load a signal plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Signal
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Signal
|
The signal instance. |
Source code in openstb/simulator/plugin/loader.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
signal_window
signal_window(plugin_spec)
Load a signal window plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | SignalWindow
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
SignalWindow
|
The signal window instance. |
Source code in openstb/simulator/plugin/loader.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
system
system(plugin_spec)
Load a system plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | System
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
System
|
The system instance. |
Source code in openstb/simulator/plugin/loader.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
trajectory
trajectory(plugin_spec)
Load a trajectory plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Trajectory
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Trajectory
|
The trajectory instance. |
Source code in openstb/simulator/plugin/loader.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | |
transducer
transducer(plugin_spec)
Load a transducer plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | Transducer
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
Transducer
|
The transducer instance. |
Source code in openstb/simulator/plugin/loader.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
travel_time
travel_time(plugin_spec)
Load a travel time plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_spec
|
PluginSpec | TravelTime
|
If a dictionary, this specifies the name and parameters of the plugin to load. Otherwise, it is assumed to be an instance of a compatible class and is returned unchanged. |
required |
Returns:
| Type | Description |
|---|---|
TravelTime
|
The travel time instance. |
Source code in openstb/simulator/plugin/loader.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |