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

feat: Allow adding public assets through the CLI #727

Merged
merged 15 commits into from
Jun 15, 2023

Conversation

Flix6x
Copy link
Contributor

@Flix6x Flix6x commented Jun 15, 2023

No description provided.

Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x self-assigned this Jun 15, 2023
@Flix6x Flix6x linked an issue Jun 15, 2023 that may be closed by this pull request
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>
@Flix6x Flix6x requested a review from nhoening June 15, 2023 09:38
Copy link
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

I think I want a small logging entry.

flexmeasures/cli/data_add.py Show resolved Hide resolved
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening
Copy link
Contributor

Maybe this could be a follow-up issue - I found that FM complains about an asset being added to an account if there is already a public asset with the same name (I added two debug logs for clarity, "New asset data:" and "Found asset:"):

± flexmeasures add asset --name Something --account-id 1 --asset-type-id 2
[FLEXMEASURES][2023-06-15 13:06:02,580] INFO: Loading config from /home/nicolas/.flexmeasures.cfg ...
Warning: Without complete redis connection settings, FlexMeasures will not be able to run forecasting and scheduling job queues.
Warning: Without complete mail settings, FlexMeasures will not be able to send mails to users, e.g. for password resets!
You might consider setting MAIL_USERNAME, MAIL_PASSWORD, FLEXMEASURES_REDIS_PASSWORD.
[FLEXMEASURES][2023-06-15 13:06:03,213] INFO: Loaded plugins: {}
New asset data: {'name': 'Something', 'latitude': None, 'longitude': None, 'generic_asset_type_id': 2, 'account_id': 1}
Found asset: <GenericAsset 37: 'Something' (wind)> with account_id: None ...
Please correct the following errors:
{'name': ['An asset with the name Something already exists in this account.']}.
 Use the --help flag to learn more.
Aborted!

I feel that the query in data/schemas/generic_assets.py (line 52) looks okay, currently I don't know why the public asset is found:

    asset = GenericAsset.query.filter(
        GenericAsset.name == data["name"]
        and GenericAsset.account_id == data["account_id"]
    ).one_or_none()

nhoening and others added 8 commits June 15, 2023 13:37
… special case for public assets (#728)#

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…also add special case for public assets (#728)#"

This reverts commit ba278b1.
…is more robust against duplicate asset names already being present in the database.

Signed-off-by: F.N. Claessen <felix@seita.nl>
…`first` is more robust against duplicate asset names already being present in the database."

This reverts commit 64b9632.
… special case for public assets (#728)#

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…g present in the database.

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>
@nhoening nhoening merged commit d5ea382 into main Jun 15, 2023
5 of 7 checks passed
@nhoening nhoening deleted the 726-cli-add-public-asset branch June 15, 2023 12:47
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.

CLI add public asset
2 participants