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

Fix the ability to skip baseline sims in Docker-based implementations #52

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Changes from 1 commit
Commits
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
12 changes: 9 additions & 3 deletions buildstockbatch/cloud/docker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ def _prep_jobs_for_batch(self, tmppath):
self.validate_buildstock_csv(self.project_filename, df)
building_ids = df.index.tolist()
n_datapoints = len(building_ids)
n_sims = n_datapoints * (len(self.cfg.get("upgrades", [])) + 1)
if self.skip_baseline_sims:
lathanh marked this conversation as resolved.
Show resolved Hide resolved
n_sims = n_datapoints * len(self.cfg.get("upgrades", []))
else:
n_sims = n_datapoints * (len(self.cfg.get("upgrades", [])) + 1)
logger.debug("Total number of simulations = {}".format(n_sims))

# This is the maximum number of jobs that can be in an array
Expand All @@ -327,9 +330,12 @@ def _prep_jobs_for_batch(self, tmppath):
logger.debug("Number of simulations per array job = {}".format(n_sims_per_job))

# Create list of (building ID, upgrade to apply) pairs for all simulations to run.
baseline_sims = zip(building_ids, itertools.repeat(None))
upgrade_sims = itertools.product(building_ids, range(len(self.cfg.get("upgrades", []))))
all_sims = list(itertools.chain(baseline_sims, upgrade_sims))
if not self.skip_baseline_sims:
baseline_sims = zip(building_ids, itertools.repeat(None))
all_sims = list(itertools.chain(baseline_sims, upgrade_sims))
else:
all_sims = list(itertools.chain(upgrade_sims))
lathanh marked this conversation as resolved.
Show resolved Hide resolved
random.shuffle(all_sims)
all_sims_iter = iter(all_sims)

Expand Down
Loading