Skip to content

Memory efficiency tweak#512

Open
rajeee wants to merge 34 commits into
developfrom
ppv2
Open

Memory efficiency tweak#512
rajeee wants to merge 34 commits into
developfrom
ppv2

Conversation

@rajeee

@rajeee rajeee commented Aug 7, 2025

Copy link
Copy Markdown
Collaborator

Fixes # .

Pull Request Description

Simplifies the postprocessing by writing partitioned annual parquet files. This reduces the memory consumption during postprocessing because it is no longer necessary to read all the results_jobxx.json files to get the result for a particular upgrade. They can be simply read by reading all the parquet files in the simulation_ouput/annual/upxx/ folder.

In addition, few other changes (probably should have been a separate PR ...)

  1. Intermediate results are no longer removed. So, postprocessing can be done again on a run.
  2. weathe_file_path can point to either a directory of weather files or a zip file. Previously, you could only point to zip file. Pointing to unzipped directory skips the unzip step and reduces the wait time before simulation is started.
  3. Add --ultra-low-disk-no-timeseries flag to buildstock_local. This was necessary to make BSB simulation sucessfully run with 37 buildings and 17 upgrades in: Better minimal buildstock resstock#1462

Checklist

Not all may apply

  • Code changes (must work)
  • Tests exercising your feature/bug fix (check coverage report on Checks -> BuildStockBatch Tests -> Artifacts)
  • Coverage has increased or at least not decreased. Update minimum_coverage in .github/workflows/coverage.yml as necessary.
  • All other unit and integration tests passing
  • Update validation for project config yaml file changes
  • Update existing documentation
  • Run a small batch run on Kestrel to make sure it all works if you made changes that will affect Kestrel
  • Add to the changelog_dev.rst file and propose migration text in the pull request

Comment thread buildstockbatch/base.py
with zipfile.ZipFile(weather_file_path, "r") as zf:
logger.debug("Extracting weather files to: {}".format(self.weather_dir))
zf.extractall(self.weather_dir)
if os.path.isdir(weather_file_path):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

weather file path now can be directory too (not just a zipfile). Will make buildstock_local much faster if using pre-unzipped directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sweet!

@rajeee rajeee requested a review from asparke2 August 15, 2025 18:36
Comment thread buildstockbatch/base.py
with zipfile.ZipFile(weather_file_path, "r") as zf:
logger.debug("Extracting weather files to: {}".format(self.weather_dir))
zf.extractall(self.weather_dir)
if os.path.isdir(weather_file_path):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sweet!

Comment thread .github/workflows/ci.yml
repository: NREL/resstock
path: resstock
ref: develop
ref: better-minimal-buildstock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Assume this gets changed back after resstock gets updated too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this PR relies on some changes on resstock currently only available on that branch. These two branches are mutually tied up together - one needs the other. So, once we are ready on both sides, we switch the branch to develop on both sides and merge both side in quick order.

Comment thread buildstockbatch/utils.py Outdated

def get_data_dict_schema(stock_type, all_cols):
if stock_type == "residential":
from resstockpostproc import get_polars_schema_from_data_dictionary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will add ComStock version of this function in comstockpostprocessing.

@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
. 81% 0
cloud 86% 0
sampler 58% 0
test 93% 0
workflow_generator 95% 0
workflow_generator.commercial 100% 0
workflow_generator.commercial.latest 73% 0
workflow_generator.commercial.v2024_07_18 73% 0
workflow_generator.residential 100% 0
workflow_generator.residential.latest 90% 0
workflow_generator.residential.latest.tests 100% 0
workflow_generator.residential.v2024_07_18 91% 0
workflow_generator.residential.v2024_07_18.tests 99% 0
workflow_generator.residential.v2024_07_19 70% 0
workflow_generator.residential.v2024_07_19.tests 99% 0
workflow_generator.residential.v2024_07_20 70% 0
workflow_generator.residential.v2024_07_20.tests 100% 0
workflow_generator.residential.v2025_01_29 70% 0
workflow_generator.residential.v2025_01_29.tests 100% 0
workflow_generator.residential.v2025_02_25 70% 0
workflow_generator.residential.v2025_02_25.tests 100% 0
Summary 86% (6021 / 6995) 0

Minimum allowed line rate is 33%

@rajeee rajeee mentioned this pull request Aug 21, 2025
8 tasks
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