Feat: Cleanup stale assets in graphs and configs#2210
Conversation
…d improving error handling for asset fetching Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Ignore stale asset references in sensors_to_show for usability and automatic pruning when deleting assets. Signed-off-by: JDev <45713692+joshuaunity@users.noreply.github.com>
…r stale asset references Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
…exMeasures/flexmeasures into feat/stale-asset-references-in-graphs
…h database context Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
… deletion Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
nhoening
left a comment
There was a problem hiding this comment.
I re-did the initial setup, and the deleted asset reference was removed befire the graph page could even get in trouble, nice.
I need some examples in two utils, as they are not easy to grasp without. Then I know better what I approve.
Also, I ran into a separate but related problem: When a config setting is removed from its asset after it was added to some sensor_to_show, we also get an error when that graph dialogue is opened. Is that better to do in a follow-up PR?
…amples Signed-off-by: Joshua Edward <oghenerobojosh01@gmail.com>
nhoening
left a comment
There was a problem hiding this comment.
Thanks for the examples.
Please check failing tests, it might just have to do with quotes:
Expected:
[{"title": "Power", "plots": [{"sensor": 1}]}, {"title": "Price", "plots": [{"sensor": 3}]}]
Got:
[{'title': 'Power', 'plots': [{'sensor': 1}]}, {'title': 'Price', 'plots': [{'sensor': 3}]}]
And do check the diff - do you know why we are deleting a lot of code in flexmeasures/data/tests/test_belief_charts.py? That seems unrelated to this PR.
…r consistency Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
nhoening
left a comment
There was a problem hiding this comment.
This looks okay to me, I just have questions.
We can probably merge this today :)
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
nhoening
left a comment
There was a problem hiding this comment.
This is great and can be merged :)
All the JSON structures & dialogues are getting much safer against deletions.
Maybe the only thing left is when I delete an asset directly in the DB, then the flex-context dialogue which references a sensor of the asset will still have that reference, and it can from then on not be saved with new changes anymore.
Let's create a new issue for that, and I'm curious how you would solve that - probably we should do a similar fix in the flex-context and flex-model dialogues, only for direct sensor references?
ok, i can make the issue, or would you want to writ eit up? Also ill test myself to understand it better, casue if a asset is mising the UI should still save... |
The UI opened nicely, it also saved, but only when no real change was necessary. When I made some other change, the API complained that the referenced sensor doesn't exist. |
Description
documentation/changelog.rstLook & Feel
getAssetinflexmeasures/ui/static/js/ui-utils.jsnow throws descriptive errors on non-2xx responses, enabling robust fallback renderingHow to test
.venv/bin/python -m pytest flexmeasures/api/v3_0/tests/test_assets_api.py -k delete_asset_cleans_stale_asset_references_in_sensors_to_showsensors_to_showcontains an asset plot referencesensors_to_showsensors_to_showFurther Improvements
Related Items
Sign-off