HOPS
HOPS class reference
Static Public Member Functions | List of all members
hops::MHO_PyControlEvaluator Class Reference

Evaluates a Python control file (.py) and returns the resulting control statements in the same mho_json format produced by MHO_ControlFileParser + MHO_ControlConditionEvaluator. More...

#include <MHO_PyControlEvaluator.hh>

Static Public Member Functions

static bool Evaluate (MHO_ParameterStore *paramStore, const mho_json &control_format, mho_json &control_statements)
 Evaluate a Python control script and populate control_statements. More...
 

Detailed Description

Evaluates a Python control file (.py) and returns the resulting control statements in the same mho_json format produced by MHO_ControlFileParser + MHO_ControlConditionEvaluator.

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date

The Python control file must define a top-level function::

from hops_control import PassInfo, Config

def configure(p: PassInfo, cfg: Config):
    ...

MHO_PyControlEvaluator constructs a PassInfo object (from the current pass metadata in the parameter store) and a Config object (from the control-format dict), calls configure(pass_info, config), and then converts config.to_json() back into the mho_json control_statements consumed by MHO_ParameterManager and MHO_OperatorBuilderManager.

The Python interpreter must already be initialised before calling Evaluate() - use MHO_PythonPluginInterface::EnsureInitialized().

Member Function Documentation

◆ Evaluate()

bool hops::MHO_PyControlEvaluator::Evaluate ( MHO_ParameterStore paramStore,
const mho_json control_format,
mho_json control_statements 
)
static

Evaluate a Python control script and populate control_statements.

Parameters
paramStorePointer to the current pass parameter store.
control_formatThe canonical control-format dict (loaded from JSON files).
control_statementsOutput: populated with the applicable statements.
Returns
true on success, false if the Python script raised an exception.

The documentation for this class was generated from the following files: