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

Rename classes #278

Merged
merged 26 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
df902c5
Refactor Home.calculate
stemgene Nov 21, 2024
8422c68
Refactor "SummaryInput" to "HeatLoadInput", "summary_input" to "heat_…
stemgene Nov 25, 2024
3249f4d
(Issue #264) Refactor: Rename "SummaryOnput" to "HeatLoadOuput", "sum…
stemgene Nov 25, 2024
9baddc9
(Issue #264) Refactor: Rename "ProcessedBill" to "ProcessedEnergyBill…
stemgene Nov 26, 2024
e131eea
add "balance_point = 0"
stemgene Nov 27, 2024
480e905
update the return type annotation of class Home._init [no-untyped-def]
stemgene Nov 27, 2024
599adf8
update
stemgene Nov 27, 2024
2aac1b7
update
stemgene Nov 27, 2024
eae5cb0
(Issue #264) Refactor: Rename "NormalizedBillingPeriodRecordBase" to …
stemgene Nov 27, 2024
cd09dd5
(Issue #264) Refactor: Rename "NormalizedBillingPeriodRecord" to "Pro…
stemgene Nov 27, 2024
39baa04
(Issue #264) Refactor: Rename "NormalizedBillingPeriodRecord" to "Pro…
stemgene Nov 27, 2024
84bb5b6
Update the "recommendations.json"
stemgene Dec 2, 2024
2c5d0b5
Refactor: rename + setup-python.sh
stemgene Dec 2, 2024
dc8a6d2
Refactor: rename
stemgene Dec 2, 2024
fa70e09
Refactor: rename
stemgene Dec 4, 2024
a6778ee
Refactor: rename
stemgene Dec 4, 2024
421ac4e
update the Lint format
stemgene Dec 4, 2024
97ff4af
Refactor: rename
stemgene Dec 4, 2024
b6733be
temporary save
stemgene Dec 5, 2024
c5eba9b
Refactor: fix "billing_period" renaming issue.
stemgene Dec 6, 2024
c9ed49a
Refactor: fix "billing_period" renaming issue.
stemgene Dec 6, 2024
d34e900
Refactor: removed the commented out code
stemgene Dec 6, 2024
be7ab41
Refactor: fix "billing_records" renaming issue.
stemgene Dec 6, 2024
ec82535
Refactor: Rename "sample_summary_inputs" to "sample_heat_load_inputs"
stemgene Dec 10, 2024
196d584
Refactor: Rename "dummy_processed_energy_bill_input_record" to "_dumm…
stemgene Dec 10, 2024
14f235c
Refactor: corrected variable naming issue of "IntermediateEnergyBill"
stemgene Dec 10, 2024
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
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"qwtel.sqlite-viewer",
"yoavbls.pretty-ts-errors",
"github.vscode-github-actions",
"ms-vsliveshare.vsliveshare"
"ms-vsliveshare.vsliveshare",
"ms-python.python",
"eamodio.gitlens",
"MS-vsliveshare.vsliveshare"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export function AnalysisHeader({ usage_data }: { usage_data: UsageDataSchema}) {
// 3312125.0171753373
// ]])

// Extract the summary_output from usage_data
const summaryOutputs = usage_data?.summary_output;
// Extract the heat_load_output from usage_data
const summaryOutputs = usage_data?.heat_load_output;

const totalRecords = usage_data?.billing_records?.length || "-"
const totalRecords = usage_data?.processed_energy_bills?.length || "-"

// Calculate the number of billing periods included in Heating calculations
const heatingAnalysisTypeRecords = usage_data?.billing_records?.filter(
const heatingAnalysisTypeRecords = usage_data?.processed_energy_bills?.filter(
(billingRecord) => billingRecord.analysis_type === 1,
// Do wee need this code instead? (billingRecord) => billingRecord.analysis_type !== "NOT_ALLOWED_IN_CALCULATIONS",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import NonHeatingUsage from './assets/NonHeatingUsage.svg'
import NotAllowedInCalculations from './assets/NotAllowedInCalculations.svg'

import { tr } from '@faker-js/faker'

Check warning on line 20 in heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx

View workflow job for this annotation

GitHub Actions / ⬣ Heat-Stack - ESLint

`@faker-js/faker` import should occur before import of `react`

// type NaturalGasBillRecord = z.infer<typeof NaturalGasBillRecordZod>
// const naturalGasBillRecord01: NaturalGasBillRecord = {
Expand Down Expand Up @@ -59,9 +59,9 @@
const [billingRecords, setBillingRecords] = useState<BillingRecordsSchema>([])

useEffect(() => {
if (usage_data?.billing_records) {
if (usage_data?.processed_energy_bills) {
// Process the billing records directly without converting from Map
setBillingRecords(usage_data.billing_records)
setBillingRecords(usage_data.processed_energy_bills)
}
}, [usage_data])

Expand Down
56 changes: 25 additions & 31 deletions heat-stack/app/routes/_heat+/single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
from rules_engine import parser
from rules_engine.pydantic_models import (
FuelType,
SummaryInput,
HeatLoadInput,
TemperatureInput
)
from rules_engine import engine
Expand Down Expand Up @@ -302,7 +302,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
from rules_engine import parser
from rules_engine.pydantic_models import (
FuelType,
SummaryInput,
HeatLoadInput,
TemperatureInput
)
from rules_engine import engine, helpers
Expand All @@ -313,7 +313,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
# two new geocode parameters may be needed for design temp:
# watch out for helpers.get_design_temp( addressMatches[0].geographies.counties[0]['STATE'] , addressMatches[0].geographies.counties[0]['COUNTY'] county_id)
# in addition to latitude and longitude from GeocodeUtil.ts object .
# pack the get_design_temp output into summary_input
# pack the get_design_temp output into heat_load_input
"""

summaryInputFromJs = summaryInputJs.as_object_map().values()._mapping
Expand All @@ -323,7 +323,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
naturalGasInputRecords = parser.parse_gas_bill(csvDataJs, parser.NaturalGasCompany.NATIONAL_GRID)

design_temp_looked_up = helpers.get_design_temp(state_id, county_id)
summaryInput = SummaryInput( **summaryInputFromJs, design_temperature=design_temp_looked_up)
summaryInput = HeatLoadInput( **summaryInputFromJs, design_temperature=design_temp_looked_up)

temperatureInput = TemperatureInput(**temperatureInputFromJs)

Expand All @@ -335,7 +335,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
// type Analytics = z.infer<typeof Analytics>;
const foo: any = executeGetAnalyticsFromFormJs(parsedAndValidatedFormSchema, convertedDatesTIWD, uploadedTextFile, state_id, county_id).toJs()

//console.log("foo billing records [0]", foo.get('billing_records')[0] )
//console.log("foo billing records [0]", foo.get('processed_energy_bills')[0] )

/**
* second time and after, when table is modified, this becomes entrypoint
Expand All @@ -344,40 +344,34 @@ export async function action({ request, params }: ActionFunctionArgs) {
from rules_engine import parser
from rules_engine.pydantic_models import (
FuelType,
SummaryInput,
HeatLoadInput,
TemperatureInput,
NormalizedBillingPeriodRecordBase
ProcessedEnergyBillInput
)
from rules_engine import engine, helpers

# def get_outputs_normalized(
# summary_input: SummaryInput,
# dhw_input: Optional[DhwInput],
# temperature_input: TemperatureInput,
# billing_periods: list[NormalizedBillingPeriodRecordBase],
# )

def executeRoundtripAnalyticsFromForm(summaryInputJs, temperatureInputJs, userAdjustedData, state_id, county_id):
"""
"billing_records" is the "roundtripping" parameter to be passed as userAdjustedData.
"processed_energy_bills" is the "roundtripping" parameter to be passed as userAdjustedData.
"""

summaryInputFromJs = summaryInputJs.as_object_map().values()._mapping
temperatureInputFromJs =temperatureInputJs.as_object_map().values()._mapping

design_temp_looked_up = helpers.get_design_temp(state_id, county_id)
# expect 1 for middlesex county: print("design temp check ",design_temp_looked_up, state_id, county_id)
summaryInput = SummaryInput( **summaryInputFromJs, design_temperature=design_temp_looked_up)
summaryInput = HeatLoadInput( **summaryInputFromJs, design_temperature=design_temp_looked_up)

temperatureInput = TemperatureInput(**temperatureInputFromJs)

# third step, re-run of the table data
userAdjustedDataFromJsToPython = [NormalizedBillingPeriodRecordBase(**record) for record in userAdjustedData['billing_records'] ]
userAdjustedDataFromJsToPython = [ProcessedEnergyBillInput(**record) for record in userAdjustedData['processed_energy_bills'] ]
# print("py", userAdjustedDataFromJsToPython[0])

outputs2 = engine.get_outputs_normalized(summaryInput, None, temperatureInput, userAdjustedDataFromJsToPython)

# print("py2", outputs2.billing_records[0])
# print("py2", outputs2.processed_energy_bills[0])
return outputs2.model_dump(mode="json")
executeRoundtripAnalyticsFromForm
`)
Expand All @@ -390,7 +384,7 @@ Traceback (most recent call last): File "<exec>", line 32,
*/
/*
For
'billing_records' => [
'processed_energy_bills' => [
Map(9) {
'period_start_date' => '2020-10-02',
'period_end_date' => '2020-11-04',
Expand All @@ -403,22 +397,22 @@ Traceback (most recent call last): File "<exec>", line 32,
'whole_home_heat_loss_rate' => undefined
}, */

const gasBillDataWithUserAdjustments = foo; /* billing_records is untested here */
const gasBillDataWithUserAdjustments = foo; /* processed_energy_bills is untested here */

const billingRecords = foo.get('billing_records')
const billingRecords = foo.get('processed_energy_bills')
billingRecords.forEach((record: any) => {
record.set('inclusion_override', true);
});
// foo.set('billing_records', null)
// foo.set('billing_records', billingRecords)
//console.log("(after customization) gasBillDataWithUserAdjustments billing records[0]", gasBillDataWithUserAdjustments.get('billing_records')[0])
// foo.set('processed_energy_bills', null)
// foo.set('processed_energy_bills', billingRecords)
//console.log("(after customization) gasBillDataWithUserAdjustments billing records[0]", gasBillDataWithUserAdjustments.get('processed_energy_bills')[0])
/* why is inclusion_override still false after roundtrip */

const foo2: any = executeRoundtripAnalyticsFromFormJs(parsedAndValidatedFormSchema, convertedDatesTIWD, gasBillDataWithUserAdjustments, state_id, county_id).toJs()

// console.log("foo2 billing records[0]", foo2.get('billing_records')[0]);
// console.log("foo2 billing records[0]", foo2.get('processed_energy_bills')[0]);
// console.log("foo2", foo2);
// console.log("(after round trip) gasBillDataWithUserAdjustments billing records[0]", gasBillDataWithUserAdjustments.get('billing_records')[0])
// console.log("(after round trip) gasBillDataWithUserAdjustments billing records[0]", gasBillDataWithUserAdjustments.get('processed_energy_bills')[0])

// const otherResult = executePy(summaryInput, convertedDatesTIWD, exampleNationalGridCSV);

Expand Down Expand Up @@ -496,22 +490,22 @@ export default function Inputs() {
/**
* Where temp1 is a temporary variable with the main Map of Maps (or undefined if page not yet submitted).
*
* temp1.get('summary_output'): Map(9) { estimated_balance_point → 61.5, other_fuel_usage → 0.2857142857142857, average_indoor_temperature → 67, difference_between_ti_and_tbp → 5.5, design_temperature → 1, whole_home_heat_loss_rate → 48001.81184312083, standard_deviation_of_heat_loss_rate → 0.08066745182677547, average_heat_load → 3048115.0520381727, maximum_heat_load → 3312125.0171753373 }
* temp1.get('heat_load_output'): Map(9) { estimated_balance_point → 61.5, other_fuel_usage → 0.2857142857142857, average_indoor_temperature → 67, difference_between_ti_and_tbp → 5.5, design_temperature → 1, whole_home_heat_loss_rate → 48001.81184312083, standard_deviation_of_heat_loss_rate → 0.08066745182677547, average_heat_load → 3048115.0520381727, maximum_heat_load → 3312125.0171753373 }
*/
/* @ts-ignore */
// console.log("Summary Output", lastResult !== undefined ? JSON.parse(lastResult.data, reviver)?.get('summary_output'): undefined)
// console.log("Summary Output", lastResult !== undefined ? JSON.parse(lastResult.data, reviver)?.get('heat_load_output'): undefined)

/**
* Where temp1 is a temporary variable with the main Map of Maps (or undefined if page not yet submitted).
* temp1.get('billing_records')
* temp1.get('processed_energy_bills')
* Array(25) [ Map(9), Map(9), Map(9), Map(9), Map(9), Map(9), Map(9), Map(9), Map(9), Map(9), … ]
* temp1.get('billing_records')[0]
* temp1.get('processed_energy_bills')[0]
* Map(9) { period_start_date → "2020-10-02", period_end_date → "2020-11-04", usage → 29, analysis_type_override → null, inclusion_override → true, analysis_type → 0, default_inclusion_by_calculation → false, eliminated_as_outlier → false, whole_home_heat_loss_rate → null }
* temp1.get('billing_records')[0].get('period_start_date')
* temp1.get('processed_energy_bills')[0].get('period_start_date')
* "2020-10-02"
*/
/* @ts-ignore */
// console.log("EnergyUseHistoryChart table data", lastResult !== undefined ? JSON.parse(lastResult.data, reviver)?.get('billing_records'): undefined)
// console.log("EnergyUseHistoryChart table data", lastResult !== undefined ? JSON.parse(lastResult.data, reviver)?.get('processed_energy_bills'): undefined)

/**
* Where temp1 is a temporary variable with the main Map of Maps (or undefined if page not yet submitted).
Expand Down
Loading
Loading