Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in B0_data_input_json.py cause a simulation termination #813

Open
TheOneAndra opened this issue Mar 2, 2021 · 1 comment · May be fixed by #814
Open

Changes in B0_data_input_json.py cause a simulation termination #813

TheOneAndra opened this issue Mar 2, 2021 · 1 comment · May be fixed by #814
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@TheOneAndra
Copy link
Collaborator

TheOneAndra commented Mar 2, 2021

Changes in B0_data_input_json.py
line 29:

    KPI,
    KPI_COST_MATRIX,
    KPI_SCALAR_MATRIX,
    LABEL,

line 343:

for kpi in (KPI_COST_MATRIX, KPI_SCALAR_MATRIX):

     if not isinstance(dict_values[KPI][kpi], pd.DataFrame):
         dict_values[KPI][kpi] = pd.DataFrame.from_records(dict_values[KPI][kpi])

     if LABEL not in dict_values[KPI][kpi].columns:
         dict_values[KPI][kpi][LABEL] = dict_values[KPI][kpi].index

These changes result in a simulation termination:

(MVS) C:\Andra\MVS_GitHub>python mvs_tool.py -i C:\Andra\RLI\Master_Thesis\Data\MVS\Input_templates\Greenfield_sector_coupling -ext csv -o C:\Andra\RLI\Master_Thesis\Data\MVS\Simulations\Greenfield\210205_sector_coupled_syst\random_test -f -pdf
12:13:28-INFO-Path for logging: C:\Andra\RLI\Master_Thesis\Data\MVS\Simulations\Greenfield\210205_sector_coupled_syst\random_test\mvs_logfile.log
12:13:28-INFO-

 Multi-Vector Simulation Tool (MVS) V0.5.5dev
 Version: 2020-12-18
 Part of the toolbox of H2020 project "E-LAND", Integrated multi-vector management system for Energy isLANDs
 Coded at: Reiner Lemoine Institute (Berlin)
 Contributors: Martha M. Hoffmann


12:13:28-INFO-loading and converting all csv's from C:\Andra\RLI\Master_Thesis\Data\MVS\Input_templates\Greenfield_sector_coupling\csv_elements into one json
c:\andra\mvs_github\src\multi_vector_simulator\A1_csv_to_json.py:283: WrongParameterWarning:

The parameter minimal_degree_of_autonomy in the fileC:\Andra\RLI\Master_Thesis\Data\MVS\Input_templates\Greenfield_sector_coupling\csv_elements\constraints.csv is not expected.
Expected parameters are ['minimal_renewable_factor', 'maximum_emissions']

12:13:28-INFO-Json file created successfully from csv's and stored into C:\Andra\RLI\Master_Thesis\Data\MVS\Input_templates\Greenfield_sector_coupling\csv_elements\mvs_csv_config.json

Traceback (most recent call last):
  File "mvs_tool.py", line 4, in <module>
    main()
  File "c:\andra\mvs_github\src\multi_vector_simulator\cli.py", line 149, in main
    set_default_values=True,
  File "c:\andra\mvs_github\src\multi_vector_simulator\B0_data_input_json.py", line 345, in load_json
    if not isinstance(dict_values[KPI][kpi], pd.DataFrame):
KeyError: 'kpi'

The log stops at:

2021-03-02 12:13:28,949 - INFO - A1_csv_to_json - Json file created successfully from csv's and stored into C:\Andra\RLI\Master_Thesis\Data\MVS\Input_templates\Greenfield_sector_coupling\csv_elements\mvs_csv_config.json

2021-03-02 12:13:28,955 - DEBUG - A1_csv_to_json - Json created successfully from csv.
2021-03-02 12:13:28,955 - DEBUG - cli - Accessing script: B0_data_input_json

And indeed in mvs_csv_config.json there is no KPI.

Would the solution be to add an exception when loading mvs_csv_config.json ?

@TheOneAndra TheOneAndra added the enhancement New feature or request label Mar 2, 2021
@Bachibouzouk
Copy link
Collaborator

Bachibouzouk commented Mar 2, 2021

A solution would be to ignore if the key KPI is not in the dict_values

--> add an if statement before if not isinstance(dict_values[KPI][kpi], pd.DataFrame):

if KPI in dict_values:
    if not isinstance(dict_values[KPI][kpi], pd.DataFrame):
    # of course indent accordingly

@TheOneAndra TheOneAndra linked a pull request Mar 2, 2021 that will close this issue
9 tasks
@smartie2076 smartie2076 added the bug Something isn't working label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants