@@ -37,6 +37,8 @@ def ecalc_pareto_npv(pred_data, kwargs):
37
37
38
38
from libecalc .application .energy_calculator import EnergyCalculator
39
39
from libecalc .common .time_utils import Frequency
40
+ from ecalc_cli .infrastructure .file_resource_service import FileResourceService
41
+ from libecalc .presentation .yaml .file_configuration_service import FileConfigurationService
40
42
from libecalc .presentation .yaml .model import YamlModel
41
43
42
44
# Get the necessary input
@@ -91,11 +93,21 @@ def ecalc_pareto_npv(pred_data, kwargs):
91
93
92
94
# Config
93
95
model_path = HERE / "ecalc_config.yaml" # "drogn.yaml"
94
- yaml_model = YamlModel (path = model_path , output_frequency = Frequency .NONE )
96
+ configuration_service = FileConfigurationService (configuration_path = model_path )
97
+ resource_service = FileResourceService (working_directory = model_path .parent )
98
+ yaml_model = YamlModel (
99
+ configuration_service = configuration_service ,
100
+ resource_service = resource_service ,
101
+ output_frequency = Frequency .NONE ,
102
+ )
103
+ #yaml_model = YamlModel(path=model_path, output_frequency=Frequency.NONE)
95
104
# comps = {c.name: id_hash for (id_hash, c) in yaml_model.graph.components.items()}
96
105
97
106
# Compute energy, emissions
98
- model = EnergyCalculator (graph = yaml_model .graph )
107
+ # model = EnergyCalculator(energy_model=yaml_model, expression_evaluator=yaml_model.variables)
108
+ # consumer_results = model.evaluate_energy_usage()
109
+ # emission_results = model.evaluate_emissions()
110
+ model = EnergyCalculator (graph = yaml_model .get_graph ())
99
111
consumer_results = model .evaluate_energy_usage (yaml_model .variables )
100
112
emission_results = model .evaluate_emissions (yaml_model .variables , consumer_results )
101
113
@@ -151,7 +163,7 @@ def results_as_df(yaml_model, results, getter) -> pd.DataFrame:
151
163
for id_hash in results :
152
164
res = results [id_hash ]
153
165
res = getter (res )
154
- component = yaml_model .graph .get_node (id_hash )
166
+ component = yaml_model .get_graph () .get_node (id_hash )
155
167
df [component .name ] = res .values
156
168
attrs [component .name ] = {'id_hash' : id_hash ,
157
169
'kind' : type (component ).__name__ ,
0 commit comments