spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
73 stars 18 forks source link

Running SpineOpt model generates traceback in SpineDBAPI #2942

Closed DillonJ closed 1 month ago

DillonJ commented 1 month ago

Trying to run SpineOpt in latest toolbox master.

Fresh install of latest version of everything.

Julia 1.10.14 Python 3.8.10

This is the exception:

Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Python\Python38\lib\threading.py", line 870, in run self._target(*self._args, *self._kwargs) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\spine_db_server.py", line 372, in _do_work result = handler(args, kwargs) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\spine_db_server.py", line 411, in _do_export_data return {"result": export_data(self._db_map, parse_value=_parse_value, kwargs)} File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\export_functions.py", line 68, in export_data "entity_alternatives": export_entity_alternatives(db_map, entity_alternative_ids), File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\export_functions.py", line 176, in export_entity_alternatives return sorted( File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\export_functions.py", line 176, in return sorted( File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\export_functions.py", line 89, in _get_items for item in _get_items_from_db_map(db_map, tablename, ids): File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\export_functions.py", line 95, in _get_items_from_db_map db_map.fetch_all(tablename) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\db_mapping.py", line 794, in fetch_all self.do_fetch_all(item_type, commit_count) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 372, in do_fetch_all self.do_fetch_more(item_type, offset=0, limit=None, real_commit_count=commit_count) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 342, in do_fetch_more item.become_referrer() File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 1128, in become_referrer add_self_as_referrer(field_value) File "C:\Workspace\Spine\spinetoolbox\src\spinedb-api\spinedb_api\db_mapping_base.py", line 1116, in add_self_as_referrer raise RuntimeError(f"Reference id {ref_id} not found") RuntimeError: Reference id 64 not found

Karlis-Baltputnis commented 1 month ago

I had the same problem today on a fresh install, trying to run SpineOpt on an older database (just upgraded). In my case the issue was somehow connected to the scenario filter, because when I used the alternative filter instead, the workflow succeeded and the model ran successfully. I could easily try this, because in my model there were only two alternatives and one scenario, and the scenario only contained one alternative (the other is essentially a leftover from long ago).

soininen commented 1 month ago

Thanks a lot for the hint that this is connected to scenario filter! Now I can reproduce the issue and hopefully fix it.