-
Notifications
You must be signed in to change notification settings - Fork 38
Allow editing asset attributes in the UI #474
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
Conversation
…tes column on the generic_asset table) Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Pull Request Test Coverage Report for Build 2926558069
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a fix for validating the input.
Ideally, I'd ask for amending the test test_post_an_asset_with_invalid_data
in api/v3_0/tests/test_assets_api.py
to make sure this validation is working.
try: | ||
return json.loads(value) | ||
except ValueError: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not raise a validation error, if content is non empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this line is a problem. I edited asset attributes with invalid JSON, which got accepted.
In the database, the asset's attributes are actually null
now. Maybe this is due to this line, giving None
if the input is not valid.
Now, loading the asset page fails:
File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/ui/charts/latest_state.py", line 57, in get_latest_power_as_plot
capacity_in_mw = sensor.get_attribute("capacity_in_mw", latest_power_value)
File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/models/time_series.py", line 168, in get_attribute
if attribute in self.generic_asset.attributes:
TypeError: argument of type 'NoneType' is not iterable
The CLI also fails to show the asset now:
File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/cli/data_show.py", line 170, in show_generic_asset
"".join([f"{k}:{v}\n" for k, v in asset.attributes.items()]),
AttributeError: 'NoneType' object has no attribute 'items'
With this PR, we could add a note to the asset page's documentation, noting that one can now edit Definitely right now a feature for more professional users. But it's there. Wouldn't that tie together changes made for 0.11 nicely? |
It would definitely be nice to include. I'm on it. |
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
This PR adds an editable text field that can be used to update the asset's attributes by editing the full JSON string.