Skip to content

Feat/register account for data source#13

Merged
Flix6x merged 15 commits into
mainfrom
feat/register-account-for-data-source
May 13, 2026
Merged

Feat/register account for data source#13
Flix6x merged 15 commits into
mainfrom
feat/register-account-for-data-source

Conversation

@BelhsanHmida

@BelhsanHmida BelhsanHmida commented Apr 13, 2026

Copy link
Copy Markdown

Summary

  • register a dedicated account for the weather provider data source
  • create the raw weather provider source with the version-aware weather source type (forecaster on newer FlexMeasures, forecasting script on older versions)
  • keep derived FlexMeasures weather data under the same version-aware source type
  • branch account-linked source setup explicitly on FlexMeasures >= 0.32
  • add tests covering account registration and source creation behavior across the version branches

Manual Testing

  • checked out flexmeasures branch feat/sensor-data-source-filtering
  • installed local flexmeasures and flexmeasures-weather in the same virtualenv
  • ran flexmeasures db upgrade against the target database
  • enabled required PostgreSQL extensions: cube and earthdistance
  • ran:
    • flexmeasures weather register-weather-sensor --name "temperature" --latitude 30 --longitude 40
    • flexmeasures weather register-weather-sensor --name "wind speed" --latitude 30 --longitude 40
    • flexmeasures weather register-weather-sensor --name "irradiance" --latitude 30 --longitude 40
    • flexmeasures weather get-weather-forecasts --location 30,40
  • verified the command completed successfully and forecasts were saved
  • verified in the database/app shell that:
    • account OpenWeatherMap exists
    • source OpenWeatherMap exists with type forecaster and is linked to the OpenWeatherMap account
    • source FlexMeasures OpenWeatherMap exists with type forecaster and is linked to the same account

closes #12

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the weather plugin’s modeling utilities to ensure a dedicated account exists for the weather provider data source, splits the “raw provider” source from “derived FlexMeasures” source types, and adds tests to validate the new behavior.

Changes:

  • Add get_or_create_weather_account and (when supported) link created Sources to this Account.
  • Create the raw provider Source as type market, while keeping derived data under a forecaster (or legacy equivalent) Source.
  • Add tests for account registration and source creation/linking behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
flexmeasures_weather/utils/modeling.py Adds dedicated account creation and conditionally associates it to Sources; changes raw source type to market.
flexmeasures_weather/utils/tests/test_modeling.py Adds tests covering account creation and source/account linkage (with compatibility branching).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread flexmeasures_weather/utils/modeling.py Outdated
Comment thread flexmeasures_weather/utils/modeling.py Outdated
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

BelhsanHmida commented Apr 13, 2026

Copy link
Copy Markdown
Author

I tested this manually end to end against a local FlexMeasures checkout on feat/sensor-data-source-filtering.

Manual test steps:

  • registered nearby weather sensors
  • ran:
    flexmeasures weather get-weather-forecasts --location 30,40

What I verified:

  • forecast ingestion completed successfully
  • a weather-provider account was created:
    Account OpenWeatherMap (ID: 7)
  • the raw provider source was created and linked correctly:
    • name: OpenWeatherMap
    • type: market -> forecaster
    • account_id: 7
  • the derived FlexMeasures source was linked correctly:
    • name: FlexMeasures OpenWeatherMap
    • type: forecaster
    • account_id: 7

This confirms the new account-linked source behavior works as intended for both the raw provider source and the derived FlexMeasures source.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Comment thread flexmeasures_weather/utils/modeling.py Outdated
Comment thread flexmeasures_weather/utils/tests/test_modeling.py Outdated
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Author

@Flix6x I applied the same explicit FlexMeasures 0.32.0 version check as in flexmeasures-entsoe pr, and updated the tests to follow the version branches with pytest.mark.skipif(...).

@BelhsanHmida BelhsanHmida requested a review from Flix6x April 22, 2026 16:55
@nhoening nhoening removed their request for review May 7, 2026 13:01
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x merged commit 8e74ee9 into main May 13, 2026
5 checks passed
@Flix6x Flix6x deleted the feat/register-account-for-data-source branch May 13, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Register an account to use for the data source

4 participants