Skip to content

Conversation

@Bill-Becker
Copy link
Collaborator

@Bill-Becker Bill-Becker commented Dec 9, 2025

This pull request focuses on improving input validation and updating migration files for the Django models related to load inputs. The main changes are lowering the minimum allowed values for several annual energy fields from 1 to 0, updating their maximum limits, and ensuring consistency between models and migrations. Additionally, there are minor updates to the way pandas date ranges are created in utility functions.

Model and Validation Updates:

  • Changed minimum allowed value for annual_tonhour in CoolingLoadInputs from 1 to 0.0, and set the maximum to 1e9 for improved flexibility and error handling. (reoptjl/models.py)
  • Changed minimum allowed value for annual_mmbtu in SpaceHeatingLoadInputs, DomesticHotWaterLoadInputs, and ProcessHeatLoadInputs from 1 to 0.0 for better input validation. (reoptjl/models.py) [1] [2] [3]

Migration Updates:

  • Added migration 0105_alter_coolingloadinputs_annual_tonhour_and_more.py to reflect the new validation rules and help text for the affected fields. (reoptjl/migrations/0105_alter_coolingloadinputs_annual_tonhour_and_more.py)
  • Added merge migration 0113_merge_20251209_2338.py to resolve migration dependencies. (reoptjl/migrations/0113_merge_20251209_2338.py)

Utility Function Updates:

  • Updated pandas date_range calls to use freq="1h" and inclusive="left" instead of deprecated arguments for better compatibility. (reo/utilities.py) [1] [2]

@Bill-Becker Bill-Becker changed the title Allow zero min value for heating and cooling load energy, increase ma… Thermal Load Energy Min/Max Updates Dec 10, 2025
@Bill-Becker Bill-Becker changed the title Thermal Load Energy Min/Max Updates Thermal Load Energy Min/Max Updates, Fix /schedule_stats Dec 10, 2025
@Bill-Becker Bill-Becker marked this pull request as ready for review December 10, 2025 22:37
@Bill-Becker Bill-Becker changed the title Thermal Load Energy Min/Max Updates, Fix /schedule_stats Minor Fixes December 2025 Dec 10, 2025
@Bill-Becker Bill-Becker requested a review from Copilot December 10, 2025 22:38
Copy link
Contributor

Copilot AI left a comment

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 includes validation improvements for energy load inputs, pandas compatibility updates, and API enhancements. The changes allow zero values for annual energy fields in heating and cooling models, update pandas date range calls to use current syntax, and enable blended building type support in the POST endpoint for simulated loads.

Key changes:

  • Updated minimum validators from 1 to 0.0 for annual energy fields across cooling, space heating, domestic hot water, and process heat load models
  • Increased annual_tonhour maximum limit from 1.0e8 to 1.0e9 for better flexibility
  • Added percent_share support to the POST handler in /simulated_load endpoint to enable campus/blended building types
  • Updated pandas date_range calls from deprecated freq="1H", closed="left" to freq="1h", inclusive="left"

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
reoptjl/models.py Changed minimum validators from 1 to 0.0 for annual_tonhour and annual_mmbtu fields; increased annual_tonhour max to 1.0e9
reoptjl/views.py Added percent_share as an optional parameter in POST request handler for simulated_load endpoint
reoptjl/migrations/0105_alter_coolingloadinputs_annual_tonhour_and_more.py Migration file reflecting model validation changes for annual energy fields
reoptjl/migrations/0113_merge_20251209_2338.py Merge migration to resolve dependency conflicts between migration branches
reo/utilities.py Updated pandas date_range syntax from deprecated parameters to current ones (freq="1h", inclusive="left")
CHANGELOG.md Documented all changes including pandas syntax fix, percent_share addition, and validation updates

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

@@ -0,0 +1,34 @@
# Generated by Django 4.0.7 on 2025-09-26 14:42
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

This migration was generated with Django 4.0.7, while the merge migration (0113) was generated with Django 4.2.26. This version inconsistency suggests the migration might have been generated some time ago. Consider regenerating this migration with the current Django version being used in the project to ensure consistency across migrations.

Suggested change
# Generated by Django 4.0.7 on 2025-09-26 14:42
# Generated by Django 4.2.26 on 2025-09-26 14:42

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we want to do this, as it might make the production database think these migrations did not happen yet and then try to re-apply them.

@Bill-Becker Bill-Becker requested a review from adfarth December 10, 2025 23:20
Copy link
Collaborator

@adfarth adfarth 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!

@Bill-Becker Bill-Becker merged commit aa1ea8b into develop Dec 16, 2025
7 checks passed
@Bill-Becker Bill-Becker deleted the zero-thermal branch December 16, 2025 15:32
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.

3 participants