Skip to content

Conversation

@hdunham
Copy link
Collaborator

@hdunham hdunham commented Sep 25, 2025

Still TODO, some can probably wait til after FY end:

  • add sector inputs to all inputs test
  • update CHANGELOG
  • add try catches to sector defaults functions to make more robust
  • expand documentation

Please check if the PR fulfills these requirements

  • CHANGELOG.md is updated
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Any new Django model inputs have also been added to job/test/posts/all_inputs_test.json

What kind of change does this PR introduce?

feature

What is the current behavior?

1 set of defaults based on commercial/industrial analyses

What is the new behavior (if this is a feature change)?

defaults change depending on user specified sector (and additional details if sector=federal)

Does this PR introduce a breaking change?

no

Other information:

@hdunham hdunham requested review from adfarth and Copilot September 26, 2025 17:42
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 implements sector-dependent defaults for the REopt API, allowing different financial and tax parameters based on the user's sector (commercial/industrial or federal) and additional federal procurement details.

Key changes:

  • Added sector-specific default values that vary based on sector type and federal procurement parameters
  • Introduced new sector-related input fields to the Site model
  • Modified existing default values to be sector-dependent rather than hardcoded

Reviewed Changes

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

Show a summary per file
File Description
reoptjl/views.py Added new sector_defaults view function to handle sector-specific default requests
reoptjl/urls.py Added URL routing for the new sector_defaults endpoint
reoptjl/models.py Added sector fields to SiteInputs and removed hardcoded defaults from financial/tech models
reoptjl/migrations/ Database migration files for the new sector fields and nullable default values
julia_src/http.jl Added sector_defaults endpoint and expanded inputs_with_defaults_set_in_julia tracking
reoptjl/test/ Updated test files with sector defaults testing and commented out other tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if post["CHP"].get(key) is None: # Check that default got assigned consistent with /chp_defaults
if key == "max_kw":
self.assertEquals(inputs_chp[key], view_response["chp_max_size_kw"])
print(r.get("messages"))
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Debug print statements should be removed from production test code. These print statements appear to be left over from development and debugging.

Suggested change
print(r.get("messages"))

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.

will rm when I finish updates

Comment on lines +179 to +180
print(model_name)
print(input_key)
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Debug print statements should be removed from production test code. These print statements appear to be left over from development and debugging.

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +78
open("debug_reopt_inputs_to_julia.json","w") do f
JSON.print(f, d, 4)
end
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Debug file output statements should be removed from production code. These statements write debug JSON files during every optimization run, which could impact performance and disk usage in production.

Suggested change
open("debug_reopt_inputs_to_julia.json","w") do f
JSON.print(f, d, 4)
end

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hallie are you planning to remove these lines (or comment them out)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes I will rm, just waiting cause I might need them when I point to the updated julia package

Comment on lines +254 to +259
open("debug_reopt_all_inputs_from_julia.json","w") do f
JSON.print(f, struct_to_dict(model_inputs.s), 4)
end
open("debug_reopt_inputs_with_defaults_from_julia.json","w") do f
JSON.print(f, inputs_with_defaults_set_in_julia, 4)
end
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Debug file output statements should be removed from production code. These statements write debug JSON files during every optimization run, which could impact performance and disk usage in production.

Suggested change
open("debug_reopt_all_inputs_from_julia.json","w") do f
JSON.print(f, struct_to_dict(model_inputs.s), 4)
end
open("debug_reopt_inputs_with_defaults_from_julia.json","w") do f
JSON.print(f, inputs_with_defaults_set_in_julia, 4)
end

Copilot uses AI. Check for mistakes.
blank=True,
null=False,
default=SECTORS.COMMERCIAL,
help_text=("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to add help text

hot_storage_dict = Dict(key=>getfield(model_inputs.s.storage.attr["HotThermalStorage"], key) for key in inputs_with_defaults_from_julia_hot_storage)
else
hot_storage_dict = Dict()
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to merge develop and add "HighTempThermalStorage" here and anywhere else that's needed

@hdunham hdunham mentioned this pull request Oct 1, 2025
4 tasks
@hdunham hdunham merged commit 37f5c86 into develop Oct 6, 2025
2 checks passed
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