Skip to content
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

[CLI] flexmeasures show beliefs entity path in case of duplicated sensors #1026

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

victorgarcia98
Copy link
Contributor

Description

The command flexmeasures show beliefs adds the sensor ID in case of trying to export sensors with the same name. However, if we want to hand this over to a third-party, it would be nicer if it included the asset names or its ancestry.

This PR changes the appended sensor ID to a string representing the "path" of the entity.

Related Items

Closes #1023


  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Could you add docstrings to the new methods?

flexmeasures/cli/utils.py Outdated Show resolved Hide resolved
flexmeasures/cli/utils.py Outdated Show resolved Hide resolved
flexmeasures/cli/utils.py Outdated Show resolved Hide resolved
flexmeasures/cli/utils.py Outdated Show resolved Hide resolved
flexmeasures/cli/utils.py Outdated Show resolved Hide resolved
flexmeasures/cli/tests/test_utils.py Show resolved Hide resolved
… their entity path.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Don't forget the changelog entry.

flexmeasures/data/models/user.py Show resolved Hide resolved
flexmeasures/data/models/generic_assets.py Show resolved Hide resolved
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing, instead of suggesting changes, I had a go at trying out some changes myself (see #1031).

Comment on lines +241 to +252
Examples:
>>> reduce_entity_paths([["Account1", "Asset1"], ["Account2", "Asset2"]])
[["Account1", "Asset1"], ["Account2", "Asset2"]]

>>> reduce_entity_paths([["Asset1"], ["Asset2"]])
[["Asset1"], ["Asset2"]]

>>> reduce_entity_paths([["Asset1"], ["Asset1"]])
[["Asset1"], ["Asset1"]]

>>> reduce_entity_paths([["Asset1", "Asset2"], ["Asset1"]])
[["Asset1"], ["Asset1", "Asset2"]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these examples seem to actually reduce anything.

* docs: clarify flag option

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: improve title

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: harmonize how two CLI options work together (show path vs. show ID)

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: harmonize how paths are shown in case of having only a part of the sensor names be duplicated

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: repurpose util function

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: simplify logic

Signed-off-by: F.N. Claessen <felix@seita.nl>

* docs: fix typos

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
@Flix6x Flix6x added this to the 0.21.0 milestone May 6, 2024
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, albeit the docstring example of reduce_entity_paths could be better.

Signed-off-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flexmeasures show beliefs duplicated sensor names
2 participants