OpenEnergyPlatform / oeplatform

Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
http://openenergyplatform.org/
GNU Affero General Public License v3.0
61 stars 19 forks source link

toep: scenario bundle won't save #1464

Closed han-f closed 7 months ago

han-f commented 7 months ago

Description of the issue

I created a new scenario bundle. I successfully saved the "basic information", but any other edits seem to produce an endless "saving wheel"

Steps to Reproduce

  1. Create new scenario bundle
  2. Edit basic information - > save
  3. Edit an other information -> try to save

Ideas of solution

?

Context and Environment

Workflow checklist

adelmemariani commented 7 months ago

Thank you @han-f for highlighting this issue. I reproduced the error. While the "saving weel" never ended, the bundle is saved in the background. The main reason of this error is that the update method has changed in the bundles because of the new way of storing the history of the oekg: #1448. As this is a newly added feature, it is currently experiencing some bugs. I will investigate more and fix this issue. The production server is functioning properly since the "history" feature has not been applied there. Adding bundles to the real oep seems to be a good idea.

adelmemariani commented 7 months ago

Update: It seems the problem is not related to the code but it is related to the Python version and the packages installed on the server.

jh-RLI commented 7 months ago

Thanks for looking into this @adelmemariani we would need to fix this bug to deploy the release on Monday, do you think we can fix it? If it's related to the python version, we might have to remove the history updates because we can't update the python version :/

adelmemariani commented 7 months ago

@jh-RLI I think it is related to the rdflib package, but we may need to upgrade the Python as well. I am trying to see if upgrading the pip and python is possible during the remaining time before our release.

adelmemariani commented 7 months ago

In the bundle update code, I used the JSON-LD format to serialize the modifications in the OEKG.

As explained here JSON-LD has been incorporated into RDFLib since v6.0.0.

And RDFLib v6.0.0 needs Python version >=3.7. But the server has Python 3.6.7

I will try to find a solution.

adelmemariani commented 7 months ago

Solved!

I changed the code to use another serialization. The bundle update now works and the modifications can be seen here.

jh-RLI commented 7 months ago

Great!!! Are there any downsides to this solution? It would still be good if we could just update the Python version. But I don't have much hope that we will be allowed to do this.

jh-RLI commented 7 months ago

Please also add this fix to the development branch by creating a new branch and a pull request :) You can reference this issue in the branch name and in the commit messages.

adelmemariani commented 7 months ago

Great!!! Are there any downsides to this solution? It would still be good if we could just update the Python version. But I don't have much hope that we will be allowed to do this.

Since we have to use RDFLib version 5.0.0 and the current version of the RDFLib is 7.0.0, we can not store the modifications as JSON-LD objects. The model.py in our Django app uses JSONField() for the modifications and since a JSON object is not an option for us, I had to use the NTSerializer and convert the outcome to string and store them like here, which might not be as readable as JSON-LD format.

adelmemariani commented 7 months ago

I think it is a temporary solution. Storing JSON objects makes it easier to undo the changes, but currently, we store strings and it makes it difficult to extract values for rolling back the OEKG to a previous state. We should upgrade Python in the future.

jh-RLI commented 7 months ago

I will close this issue as the issue was solved. @adelmemariani to save some time on monday it would be great if this fix is already submitted as PR to develop branch i think there is none so far? :)