-
Notifications
You must be signed in to change notification settings - Fork 14
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
ResStock-HPXML: HES Workflow Generator #252
Conversation
@nmerket I think this is ready for an initial review. The new workflow generator has been built to work just with local buildstock_docker at the moment, and I plan to have the next round of changes be focused on generalizing for Eagle/AWS. There are some CI errors right now which appear to spawn from the switch to OS-3.3.0 on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these comments are for me. There's definitely some growing pains in buildstockbatch to accommodate HEScore here. It turns out making a fully extensible batch model articulation and simulation platform is kind of hard.
buildstockbatch/base.py
Outdated
if self.cfg['workflow_generator']['type'] == 'residential_hpxml_hes': | ||
self.os_hescore_dir = path_rel_to_file('',self.cfg['workflow_generator']['args']['openstudio_hescore']['os_hescore_directory']) | ||
else: | ||
self.os_hescore_dir = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this kind of conditional thing in the base class is concerning. I'm not sure what to do about it, though. Ideally, this would be handled with some elegant inheritance mechanism, but we're pretty far off from that here.
if self.cfg['workflow_generator']['type'] == 'residential_hpxml': | ||
if 'residential_hpxml' in self.cfg['workflow_generator']['type']: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned something today that you can search for a substring using in
.
buildstockbatch/localdocker.py
Outdated
# FIXME temporary docker image for testing | ||
# return 'nrel/hescore-hpxml-openstudio' | ||
return 'nrel/openstudio:{}'.format(self.os_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out something more permanent here.
def run_building(cls, project_dir, buildstock_dir, weather_dir, docker_image, results_dir, measures_only, | ||
n_datapoints, cfg, i, upgrade_idx=None): | ||
def run_building(cls, project_dir, buildstock_dir, weather_dir, os_hescore_dir, docker_image, results_dir, | ||
measures_only, n_datapoints, cfg, i, upgrade_idx=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this was necessary to get it working, but I don't like it.
buildstockbatch/localdocker.py
Outdated
# OS-HEScore measure directories | ||
if os_hescore_dir and os.path.exists(os_hescore_dir): | ||
bind_mounts += [(os.path.join(os_hescore_dir, 'rulesets'), 'OpenStudio-HEScore/rulesets', 'ro'), | ||
(os.path.join(os_hescore_dir, 'hpxml-measures'), 'OpenStudio-HEScore/hpxml-measures', 'ro'), | ||
(os.path.join(os_hescore_dir, 'weather'), 'OpenStudio-HEScore/weather', 'ro')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking out loud here: I wonder if we could have the workflow generator define bind mounts in some generic way that could be used by both eagle.py and localdocker.py.
buildstockbatch/localdocker.py
Outdated
sim_out_tarfile_name = os.path.join(sim_out_dir, 'simulations_job0.tar.gz') | ||
logger.debug(f'Compressing simulation outputs to {sim_out_tarfile_name}') | ||
with tarfile.open(sim_out_tarfile_name, 'w:gz') as tarf: | ||
for dirname in os.listdir(sim_out_dir): | ||
if re.match(r'up\d+', dirname) and os.path.isdir(os.path.join(sim_out_dir, dirname)): | ||
tarf.add(os.path.join(sim_out_dir, dirname), arcname=dirname) | ||
shutil.rmtree(os.path.join(sim_out_dir, dirname)) | ||
# FIXME temporarily comment out for testing | ||
# sim_out_tarfile_name = os.path.join(sim_out_dir, 'simulations_job0.tar.gz') | ||
# logger.debug(f'Compressing simulation outputs to {sim_out_tarfile_name}') | ||
# with tarfile.open(sim_out_tarfile_name, 'w:gz') as tarf: | ||
# for dirname in os.listdir(sim_out_dir): | ||
# if re.match(r'up\d+', dirname) and os.path.isdir(os.path.join(sim_out_dir, dirname)): | ||
# tarf.add(os.path.join(sim_out_dir, dirname), arcname=dirname) | ||
# shutil.rmtree(os.path.join(sim_out_dir, dirname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to uncomment this at some point and if it breaks something, fix it.
osw['steps'][0]['arguments']['os_hescore_directory'] = '../../OpenStudio-HEScore' | ||
|
||
# Add measure path for reporting measure | ||
osw['measure_paths'] = ['OpenStudio-HEScore/hpxml-measures'] + osw['measure_paths'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
osw['measure_paths'] += ['OpenStudio-HEScore/hpxml-measures']
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenStudio-HEScore path needs to be first to prioritize the OS-HEScore reporting measure
Minimum allowed coverage is Generated by 🐒 cobertura-action against d8fa15f |
To run the workflow using this branch: Branches: Project File: https://github.com/NREL/buildstockbatch/blob/restructure-v3-hes/project_resstock_national_hes.yml Docker Image: https://github.com/NREL/docker-hescore-hpxml-openstudio/blob/main/Dockerfile |
@aspeake Got it to work with some minor changes. Thanks for getting it to this point. I'd like to make some more structural changes to buildstockbatch to accommodate this workflow and hopefully provide more flexibility for other workflows such as ComStock. I'd like to run this by @asparke2 and @joseph-robertson to get their thoughts. Bind MountsWhat directories get mounted where in the container is driven by what workflow you're running. ResStock legacy, ResStock-HPXML, ComStock, and now ResStock-HEScore all have potentially slightly different folders that need to be mounted in. I'm a little murky on how we're handling this in all the implementations we have going already. It's probably a lot of Custom container image built at runtimeWe'd like to use the hescore-hpxml that comes with OpenStudio-HEScore. That way everything is in sync. For it to work well it needs to be installed in the docker image so the right dependencies and module lookups happen correctly. The hescore-hpxml package isn't really meant to be run as a standalone script. The problem is that we don't know the hescore-hpxml version until runtime, so we have a complicated multistep process that's prone to error to build a docker image with the hescore-hpxml package in it. I think we can make a general capability in buildstockbatch that allows defining the image to run in three ways:
Another idea is that the docker/singularity image should be defined in the workflow generator class. In general, the workflow you're running is what drives the image needed. Not sure if this is a good idea or bad idea. Building a singularity image on the fly is a little trickier, but might still be possible. I know ComStock is using custom Singularity images on Eagle. I'm pretty sure they pre-build them. We will probably have to do the same. |
This reverts commit 0ac675a.
Some minor changes may be needed in the workflow generator to align with the latest approach for in residential_hpxml: #302 |
Thanks for the heads up @aspeake. Is that something you have time to do? |
@nmerket I can probably find some time in October to do so, however I think it may require updating all the relevant branches so that we can properly test the HES workflow. |
Replaced with #378 |
Fixes #243
Pull Request Description
New workflow generator that translates ResStock-generated xml files to HES json inputs, which are passed to the OS-HEScore workflow to simulate buildings.
This PR adds a new workflow generator that requires a new argument
os_hescore_directory
to point to a local OpenStudio-HEScore branch. The hescore-hpxml translator is installed as part of the singularity/Docker image (https://github.com/NREL/docker-hescore-hpxml-openstudio/blob/main/Dockerfile). This is accompanied by changes to the resstock repo from where the hescore-hpxml translator will be called (PR is TBA)Checklist
Not all may apply