irena-flextool / flextool

IRENA FlexTool is an energy and power systems model for understanding the role of variable power generation in future energy systems.
https://www.irena.org/energytransition/Energy-System-Models-and-Data/IRENA-FlexTool
Other
21 stars 5 forks source link

Log when updating FlexTool #166

Closed e-zaline closed 5 months ago

e-zaline commented 5 months ago

When I update FlexTool I get this log:

Init.sqlite updated to version 15 Traceback (most recent call last): File "update_flextool.py", line 117, in old_dict["project"]["specifications"]["Tool"].append({"type": "path","relative": True,"path": ".spinetoolbox/specifications/Tool/open_summary.json"}) File "update_flextool.py", line 59, in update_flextool result_template_path = './version/flextool_template_results_master.json' File "C:\Users\pc\flextool\migrate_database.py", line 60, in migrate_database add_value_list_manual(db,new_value_list) File "C:\Users\pc\flextool\migrate_database.py", line 113, in add_value_list_manual db.commit_session("Added new parameter value lists") File "C:\Users\pc\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_commit_mixin.py", line 68, in commit_session self._check_commit(comment) File "C:\Users\pc\Spine-Toolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 353, in _check_commit raise SpineDBAPIError("Nothing to commit.") spinedb_api.exception.SpineDBAPIError: Nothing to commit.

FlexTool opens normally though, so I am not sure if there is an issue.

ArttuTupala commented 5 months ago

This is an actual issue as the migrations of databases are not completed because of this crash. The issue is due to the changes that it should make already been done in the database. I can make changes so that it won't crash but continue, as it should be safe to re-do the migration updates.

However, the more interesting question is that how there is a database that has a version lower than the database contents indicate. I thought about it and I can come up with two possibilities:

  1. You have manually changed the version from the parameter definitions. (Highly unlikely).
  2. You have your own input workflows right? With a database (other than Init.sqlite) connected with a merger to the Input_data? I have this understanding from some earlier issue. In this case, if that database is not migrated along with the others, it will cause problems. The merger inputs not only the parameters, but also the parameter definitions. This will lead to the database having a lower version number that for example its parameter_value_list indicate. The changes I soon make can still make the migration of this work, but having old parameter definitions in the Input_data will cause other issues. So, you should update this database along with the others. It can be done currently in two ways as stated in the update documentation:
    • manually: python migrate_database.py database_name(if in flextool folder) or path
    • put it in the folder "how to example databases" before updating (all databases there will be migrated)

We should think about a better way to set the databases to be migrated when updating

jkiviluo commented 5 months ago

The fix has been merged. @e-zaline can you check it works?

e-zaline commented 5 months ago

@ArttuTupala : thanks! Yes, that's correct, I have my own input workflow. @jkiviluo : thank you, it works, I do not have the log anymore when updating. So with this fix I don't need anymore to take the steps described by Arttu to update the db of my workflow?

ArttuTupala commented 5 months ago

Right now, it might work without updating, because we have not made that big changes to the input data. In the merging, you will get the new parameters from the updated database, the problems will be related to old parameters that are updated or removed. Now, it might result in outdated parameter descriptions, but in the future, bigger issues will arise like some of the parameters from the old database might not do anything anymore, the drop down allowed values for the parameters might not be found or errors with the exporter from parameters that should not exist.

jkiviluo commented 5 months ago

When starting a new project, the safe option is to take a copy of the input_data_template.sqlite when starting the project - that way you don't get any old parameters or parameter choices.

Anyway, I think the situation is now good enough to close the issue.