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

Support pandas 1.4 #525

Merged
merged 8 commits into from Nov 10, 2022
Merged

Conversation

Flix6x
Copy link
Contributor

@Flix6x Flix6x commented Nov 1, 2022

You've implemented some of this in #511, too. The new part is the pandas version check in initialize_index. We may consider merging this with #511 instead of main.

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 self-assigned this Nov 1, 2022
@Flix6x Flix6x marked this pull request as ready for review November 1, 2022 14:01
@Flix6x Flix6x requested a review from nhoening November 1, 2022 14:01
@coveralls
Copy link
Collaborator

coveralls commented Nov 1, 2022

Pull Request Test Coverage Report for Build 3436325982

  • 20 of 23 (86.96%) changed or added relevant lines in 11 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 65.258%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flexmeasures/api/common/schemas/sensor_data.py 1 2 50.0%
flexmeasures/cli/data_add.py 2 3 66.67%
flexmeasures/data/models/planning/utils.py 4 5 80.0%
Files with Coverage Reduction New Missed Lines %
flexmeasures/api/common/schemas/sensor_data.py 1 66.84%
Totals Coverage Status
Change from base Build 3392429513: 0.02%
Covered Lines: 6610
Relevant Lines: 9510

💛 - Coveralls

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.

Looks good! Merging into 511 seems like a good idea.

@Flix6x Flix6x changed the base branch from main to refactor-scheduling-storage-specs November 10, 2022 08:31
…s' into support-pandas-1.4

# Conflicts:
#	flexmeasures/data/models/planning/utils.py
#	flexmeasures/data/services/scheduling.py
…sed keyword argument was used

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 merged commit 22cb852 into refactor-scheduling-storage-specs Nov 10, 2022
@Flix6x Flix6x deleted the support-pandas-1.4 branch November 10, 2022 11:44
@Flix6x Flix6x added this to the 0.12.0 milestone Nov 10, 2022
nhoening added a commit that referenced this pull request Nov 18, 2022
)

* Better documentation of flexibility model for storage in endpoint; refactor its parameters and handling within the code for readability

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* add changelog entry

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* make tests work, include updating older API versions, make prefer_charging_sooner part of storage specs & an optional parameter in API v3

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* use storage_specs in CLI command, as well

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* remove default resolution of 15M, for now pass in what you want

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* various review comments

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* black

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* fix tests

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* always load sensor when checking storage specs

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* begin to handle source model and version during scheduling

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* we can get multiple sources from our query (in the old setting, when we use name, but also in the new setting, unless we always include the user_id)

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* give our two in-built schedulers an official __author__ and __version__

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* review comments

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* refactor getting data source for a job to util function; use the actual data source ID for this lookup if possible

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* pass sensor to check_storage_specs, as we always have it already

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* wrap Scheduler in classes, unify data source handling a bit more

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* Support pandas 1.4 (#525)

Add a pandas version check in initialize_index.


* Use initialize_series util function

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

* Update initialize_index for pandas>=1.4

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

* flake8

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

* Use initialize_index or initialize_series in all places where the closed keyword argument was used

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

* flake8

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

* mypy: PEP 484 prohibits implicit Optional

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

* black after mypy

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

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

* Stop requiring min/max SoC attributes, which have defaults:
- Default min = 0
- Default max = the highest target value, or np.nan if there are no targets, which subsequently maps to infinity in our solver

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

* Set up device constraint columns for efficiencies in Charge Point scheduler, too

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

* Derive flow constraints for battery scheduling, too (copied from Charge Point scheduler)

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

* Refactor: rename BatteryScheduler to StorageScheduler

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

* Warn for deprecation of
schedule_battery and schedule_charging_station

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

* Use StorageScheduler instead of ChargingStationScheduler

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

* Deprecate ChargingStationScheduler

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

* Refactor: move StorageScheduler to dedicated module

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

* Update docstring

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

* fix test

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

* flake8

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

* Lose the v in version strings; prefer versions showing up as 'version: 3' over 'version: v3'.

Even though Scheduler versioning does not necessarily need to follow semantic versioning (see discussion here: semver/semver#235), the v is still redundant.

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

* Refactor: rename module

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

* Deal with empty SoC targets

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

* Stop wrapping DataFrame representations in logging

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

* Log warning instead of raising UnknownForecastException, and assume zero power values for missing values

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

* mention scheduler merging in changelog

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* amend existing data source information to reflect our StorageScheduler

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* add db upgrade notice to changelog

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* more specific downgrade command

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Co-authored-by: F.N. Claessen <felix@seita.nl>
Flix6x added a commit that referenced this pull request Nov 21, 2022
Add scheduling test for maximizing self-consumption, and improve time series db queries for fixed tariffs (and other long-term constants).


* Better documentation of flexibility model for storage in endpoint; refactor its parameters and handling within the code for readability

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* add changelog entry

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* make tests work, include updating older API versions, make prefer_charging_sooner part of storage specs & an optional parameter in API v3

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* use storage_specs in CLI command, as well

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* remove default resolution of 15M, for now pass in what you want

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* various review comments

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* black

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* fix tests

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* always load sensor when checking storage specs

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* begin to handle source model and version during scheduling

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* we can get multiple sources from our query (in the old setting, when we use name, but also in the new setting, unless we always include the user_id)

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* give our two in-built schedulers an official __author__ and __version__

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* review comments

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* refactor getting data source for a job to util function; use the actual data source ID for this lookup if possible

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* pass sensor to check_storage_specs, as we always have it already

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* wrap Scheduler in classes, unify data source handling a bit more

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* Support pandas 1.4 (#525)

Add a pandas version check in initialize_index.


* Use initialize_series util function

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

* Update initialize_index for pandas>=1.4

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

* flake8

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

* Use initialize_index or initialize_series in all places where the closed keyword argument was used

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

* flake8

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

* mypy: PEP 484 prohibits implicit Optional

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

* black after mypy

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

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

* Stop requiring min/max SoC attributes, which have defaults:
- Default min = 0
- Default max = the highest target value, or np.nan if there are no targets, which subsequently maps to infinity in our solver

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

* Set up device constraint columns for efficiencies in Charge Point scheduler, too

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

* Derive flow constraints for battery scheduling, too (copied from Charge Point scheduler)

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

* Refactor: rename BatteryScheduler to StorageScheduler

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

* Warn for deprecation of
schedule_battery and schedule_charging_station

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

* Use StorageScheduler instead of ChargingStationScheduler

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

* Deprecate ChargingStationScheduler

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

* Refactor: move StorageScheduler to dedicated module

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

* Update docstring

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

* fix test

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

* flake8

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

* Lose the v in version strings; prefer versions showing up as 'version: 3' over 'version: v3'.

Even though Scheduler versioning does not necessarily need to follow semantic versioning (see discussion here: semver/semver#235), the v is still redundant.

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

* Refactor: rename module

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

* Deal with empty SoC targets

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

* Stop wrapping DataFrame representations in logging

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

* Log warning instead of raising UnknownForecastException, and assume zero power values for missing values

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

* Workaround for GH #484

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

* Test maximizing self-consumption

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

* Refactor: a single parameterized test instead of 2 tests with a lot of duplicate code

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

* Remove debug statements

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

* black

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

* Correct mistake while refactoring

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

* Check default price sensor in both scenarios

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

* Expand explanation of optimization context

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

* Reorder assertions and add more comments

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

* Upgrade timely-beliefs to partly resolve workaround

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

* changelog entry

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

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Co-authored-by: Nicolas Höning <nicolas@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants