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

177 upgrade the python version of rules engine to 3.11.3 #179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules-engine/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name="rules-engine"
version="0.0.1"
requires-python=">=3.8"
requires-python=">=3.11.3"
dependencies = [
"pydantic"
]
Expand Down
9 changes: 1 addition & 8 deletions rules-engine/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
Expand All @@ -10,8 +10,6 @@ black==23.3.0
# via rules-engine (pyproject.toml)
click==8.1.3
# via black
exceptiongroup==1.1.1
# via pytest
iniconfig==2.0.0
# via pytest
isort==5.12.0
Expand Down Expand Up @@ -42,11 +40,6 @@ pytest==7.3.2
# via rules-engine (pyproject.toml)
snowballstemmer==2.2.0
# via pydocstyle
tomli==2.0.1
# via
# black
# mypy
# pytest
typing-extensions==4.6.3
# via
# mypy
Expand Down
2 changes: 1 addition & 1 deletion rules-engine/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile pyproject.toml
Expand Down
20 changes: 10 additions & 10 deletions rules-engine/src/rules_engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bisect
import statistics as sts
from datetime import date, timedelta
from typing import Any, List, Optional, Tuple
from typing import Any, Optional

from rules_engine.pydantic_models import (
AnalysisType,
Expand Down Expand Up @@ -35,7 +35,7 @@ def get_outputs_oil_propane(
"""
Analyze the heat load for a home that is using oil or propane as its current heating system fuel.
"""
billing_periods: List[NormalizedBillingPeriodRecordBase] = []
billing_periods: list[NormalizedBillingPeriodRecordBase] = []

last_date = oil_propane_billing_input.preceding_delivery_date
for input_val in oil_propane_billing_input.records:
Expand Down Expand Up @@ -69,7 +69,7 @@ def get_outputs_natural_gas(
"""
Analyze the heat load for a home that is using natural gas as its current heating system fuel.
"""
billing_periods: List[NormalizedBillingPeriodRecordBase] = []
billing_periods: list[NormalizedBillingPeriodRecordBase] = []

for input_val in natural_gas_billing_input.records:
billing_periods.append(
Expand All @@ -91,7 +91,7 @@ def get_outputs_normalized(
summary_input: SummaryInput,
dhw_input: Optional[DhwInput],
temperature_input: TemperatureInput,
billing_periods: List[NormalizedBillingPeriodRecordBase],
billing_periods: list[NormalizedBillingPeriodRecordBase],
) -> RulesEngineResult:
"""
Analyze the heat load for a home based on normalized, fuel-type-agnostic billing records.
Expand Down Expand Up @@ -171,8 +171,8 @@ def get_outputs_normalized(

def convert_to_intermediate_billing_periods(
temperature_input: TemperatureInput,
billing_periods: List[NormalizedBillingPeriodRecordBase],
) -> List[BillingPeriod]:
billing_periods: list[NormalizedBillingPeriodRecordBase],
) -> list[BillingPeriod]:
"""
Converts temperature data and billing period inputs into internal classes used for heat loss calculations.

Expand Down Expand Up @@ -243,7 +243,7 @@ def hdd(avg_temp: float, balance_point: float) -> float:
return max(0, balance_point - avg_temp)


def period_hdd(avg_temps: List[float], balance_point: float) -> float:
def period_hdd(avg_temps: list[float], balance_point: float) -> float:
"""
Sum up total heating degree days in a given time period for a given
home.
Expand Down Expand Up @@ -364,7 +364,7 @@ class Home:
def __init__(
self,
summary_input: SummaryInput,
billing_periods: List[BillingPeriod],
billing_periods: list[BillingPeriod],
dhw_input: Optional[DhwInput],
initial_balance_point: float = 60,
):
Expand All @@ -375,7 +375,7 @@ def __init__(
self.dhw_input = dhw_input
self._initialize_billing_periods(billing_periods)

def _initialize_billing_periods(self, billing_periods: List[BillingPeriod]) -> None:
def _initialize_billing_periods(self, billing_periods: list[BillingPeriod]) -> None:
self.bills_winter = []
self.bills_summer = []
self.bills_shoulder = []
Expand Down Expand Up @@ -608,7 +608,7 @@ class BillingPeriod:
def __init__(
self,
input: NormalizedBillingPeriodRecordBase,
avg_temps: List[float],
avg_temps: list[float],
usage: float,
analysis_type: AnalysisType,
) -> None:
Expand Down
4 changes: 2 additions & 2 deletions rules-engine/src/rules_engine/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import csv
import io
from datetime import datetime, timedelta
from enum import Enum
from enum import StrEnum

from .pydantic_models import NaturalGasBillingInput, NaturalGasBillingRecordInput


class NaturalGasCompany(str, Enum):
class NaturalGasCompany(StrEnum):
EVERSOURCE = "eversource"
NATIONAL_GRID = "national_grid"

Expand Down
14 changes: 7 additions & 7 deletions rules-engine/src/rules_engine/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from datetime import date
from enum import Enum
from typing import Annotated, Any, List, Optional
from typing import Annotated, Any, Optional

from pydantic import BaseModel, BeforeValidator, ConfigDict, Field

Expand Down Expand Up @@ -88,7 +88,7 @@ class OilPropaneBillingRecordInput(BaseModel):
class OilPropaneBillingInput(BaseModel):
"""From Oil-Propane tab. Container for holding all rows of the billing input table."""

records: List[OilPropaneBillingRecordInput]
records: list[OilPropaneBillingRecordInput]
preceding_delivery_date: date = Field(description="Oil-Propane!B6")


Expand All @@ -104,7 +104,7 @@ class NaturalGasBillingRecordInput(BaseModel):
class NaturalGasBillingInput(BaseModel):
"""From Natural Gas tab. Container for holding all rows of the billing input table."""

records: List[NaturalGasBillingRecordInput]
records: list[NaturalGasBillingRecordInput]


class NormalizedBillingPeriodRecordBase(BaseModel):
Expand Down Expand Up @@ -143,8 +143,8 @@ class NormalizedBillingPeriodRecord(NormalizedBillingPeriodRecordBase):


class TemperatureInput(BaseModel):
dates: List[date]
temperatures: List[float]
dates: list[date]
temperatures: list[float]


class SummaryOutput(BaseModel):
Expand Down Expand Up @@ -184,13 +184,13 @@ class BalancePointGraphRow(BaseModel):
class BalancePointGraph(BaseModel):
"""From Summary page"""

records: List[BalancePointGraphRow]
records: list[BalancePointGraphRow]


class RulesEngineResult(BaseModel):
summary_output: SummaryOutput
balance_point_graph: BalancePointGraph
billing_records: List[NormalizedBillingPeriodRecord]
billing_records: list[NormalizedBillingPeriodRecord]


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion rules-engine/tests/test_rules_engine/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import pathlib
from datetime import date, datetime, timedelta
from typing import Any, List, Literal, Optional
from typing import Any, Literal, Optional

import pytest
from pydantic import BaseModel
Expand Down
Loading