Skip to content

Commit

Permalink
Merge pull request #396 from NREL/allow_fast_sims
Browse files Browse the repository at this point in the history
Allows non-integer minutes_per_sim
  • Loading branch information
nmerket authored Oct 10, 2023
2 parents 6e17414 + 7cee175 commit fdbeb62
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion buildstockbatch/eagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ def run_building(cls, output_dir, cfg, n_datapoints, i, upgrade_idx=None):

def queue_jobs(self, array_ids=None, hipri=False):
eagle_cfg = self.cfg['eagle']
minutes_per_sim = eagle_cfg.get('minutes_per_sim', 3)
with open(os.path.join(self.output_dir, 'job001.json'), 'r') as f:
job_json = json.load(f)
n_sims_per_job = len(job_json['batch'])
Expand All @@ -444,6 +443,7 @@ def queue_jobs(self, array_ids=None, hipri=False):

# Estimate the wall time in minutes
cores_per_node = 36
minutes_per_sim = eagle_cfg['minutes_per_sim']
walltime = math.ceil(math.ceil(n_sims_per_job / cores_per_node) * minutes_per_sim)

# Queue up simulations
Expand Down
2 changes: 1 addition & 1 deletion buildstockbatch/schemas/v0.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ aws-emr-spec:

hpc-spec:
account: str(required=True)
minutes_per_sim: int(max=480, required=False)
minutes_per_sim: num(min=0.05, max=480, required=True)
n_jobs: int(required=False)
postprocessing: include('hpc-postprocessing-spec', required=False)
sampling: include('sampling-spec', required=False)
Expand Down
1 change: 1 addition & 0 deletions buildstockbatch/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _basic_residential_project_file(update_args={}, raw=False):
'time': 20
},
'account': 'testaccount',
'minutes_per_sim': 1
},
'schema_version': '0.3'
}
Expand Down
28 changes: 27 additions & 1 deletion buildstockbatch/test/test_eagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import pandas as pd
import pathlib
import requests
import shutil
import tarfile
from unittest.mock import patch
Expand Down Expand Up @@ -195,6 +194,33 @@ def test_qos_high_job_submit(mock_subprocess, basic_residential_project_file, mo
assert '--qos=high' in mock_subprocess.run.call_args[0][0]


def test_queue_jobs_minutes_per_sim(mocker, basic_residential_project_file, monkeypatch):
mock_subprocess = mocker.patch('buildstockbatch.eagle.subprocess')
mocker.patch.object(EagleBatch, 'weather_dir', None)
mock_subprocess.run.return_value.stdout = 'Submitted batch job 1\n'
mock_subprocess.PIPE = None
project_filename, results_dir = basic_residential_project_file(update_args={
'eagle': {
'sampling': {
'time': 20
},
'account': 'testaccount',
'minutes_per_sim': 0.5
}
})
shutil.rmtree(results_dir)
monkeypatch.setenv('CONDA_PREFIX', 'something')

batch = EagleBatch(project_filename)
for i in range(1, 11):
pathlib.Path(results_dir, 'job{:03d}.json'.format(i)).touch()
with open(os.path.join(results_dir, 'job001.json'), 'w') as f:
json.dump({'batch': list(range(1000))}, f)
batch.queue_jobs()
mock_subprocess.run.assert_called_once()
assert '--time=14' in mock_subprocess.run.call_args[0][0]


def test_run_building_process(mocker, basic_residential_project_file):
project_filename, results_dir = basic_residential_project_file(raw=True)
results_dir = pathlib.Path(results_dir)
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog/changelog_dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ Development Changelog
:pullreq: 365

Upload buildstock.csv to S3 during postprocessing

.. change::
:tags: feature
:pullreq: 396
:tickets: 377

Allow fractional ``eagle.minutes_per_sim`` for simulations that run less
than a minute. Making that it a required input.
4 changes: 2 additions & 2 deletions docs/project_defn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ Under the ``eagle`` key is a list of configuration for running the batch job on
the Eagle supercomputer.

* ``n_jobs``: Number of eagle jobs to parallelize the simulation into
* ``minutes_per_sim``: Maximum allocated simulation time in minutes
* ``account``: Eagle allocation account to charge the job to
* ``minutes_per_sim``: Required. Maximum allocated simulation time in minutes.
* ``account``: Required. Eagle allocation account to charge the job to.
* ``sampling``: Configuration for the sampling in eagle

* ``time``: Maximum time in minutes to allocate to sampling job
Expand Down

0 comments on commit fdbeb62

Please sign in to comment.