Dev’s digest can now load the peak chart only when it’s requested. The controller parsers have another reason to load at runtime: each plant’s entry in plants.json names the make to use. The main boiler and sports hall need Halden’s parser, while the science block needs Ostra’s. You’ll let that name select the module, replacing the digest’s hand-maintained parser table.
Build the Module Name
The Python package already keeps one parser module per controller make. In boiler/controllers/__init__.py, the loader builds a dotted module name:
import importlib
def load_controller(make):
return importlib.import_module(f"{__name__}.{make}")
Here __name__ is "boiler.controllers", so "halden" selects boiler.controllers.halden. The function returns that module, leaving the caller to use its parser.
JavaScript’s import() also accepts a string built at runtime. Save this complete loader as boiler/controllers/index.js:
boiler/controllers/index.js
export async function loadController(make) {
return import(`./${make}.js`);
}