Skip to content

update_investments

NexusePlugin

NexusePlugin(parameters: dict, scenario: Scenario)

Bases: Plugin

Source code in src/plugins/update_investments/nexus_e_plugin.py
def __init__(self, parameters: dict, scenario: Scenario):
    self.scenario = scenario
    self.config = Config(**parameters)
    self.__data_context = scenario.get_data_context()
    if self.__data_context.type != "mysql":
        raise ValueError("update_investments only works with a MySQL database")

config instance-attribute

config = Config(**parameters)

scenario instance-attribute

scenario = scenario

get_default_parameters classmethod

get_default_parameters() -> dict
Source code in src/plugins/update_investments/nexus_e_plugin.py
@classmethod
def get_default_parameters(cls) -> dict:
    return asdict(Config())

run

run() -> None
Source code in src/plugins/update_investments/nexus_e_plugin.py
def run(self) -> None:
    engine = self.__get_matlab_engine(self.config.matlab_engine)
    engine.addpath(engine.genpath("."))
    engine.workspace["parameters"] = { 
        "scenId": self.__get_scenario_id(),
        "startyear": self.config.startyear,
        "endyear": self.config.endyear,
        "scenYear": self.config.scenYear,
        "dbName": self.__data_context.name
    }
    engine.update_investments(
        engine.workspace["parameters"],
        engine.database(
            self.__data_context.name,
            self.__data_context.user,
            self.__data_context.password,
            "Vendor",
            "MySQL",
            "Server",
            self.__data_context.host,
        ),
        os.path.join(
            self.config.results_path,
            f"CentIv_{self.config.scenYear}"
        ),
        nargout=0
    )
    engine.quit()

Config dataclass

Config(
    startyear: int = 2020,
    endyear: int = 2020,
    scenYear: int = 2,
    results_path: str = "",
    matlab_engine: str = "matlab",
)

endyear class-attribute instance-attribute

endyear: int = 2020

matlab_engine class-attribute instance-attribute

matlab_engine: str = 'matlab'

results_path class-attribute instance-attribute

results_path: str = ''

scenYear class-attribute instance-attribute

scenYear: int = 2

startyear class-attribute instance-attribute

startyear: int = 2020