Skip to content

Commit

Permalink
Pre-filter remove.set to speed up the build process
Browse files Browse the repository at this point in the history
  • Loading branch information
adrivinca committed Dec 10, 2024
1 parent 875b01a commit 135f090
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions message_ix_models/model/water/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ def get_spec(context: Context) -> Mapping[str, ScenarioInfo]:
# Sets to add
add.set[set_name].extend(config)

# clean the remove.set from things that are actually not in the scenario
# this saves building time significantly, as remove is slow
scen = context.get_scenario()
for category, elements in ((k, v) for k, v in remove.set.items() if k != "unit"):
# Get the corresponding set from the scenario
scen_set = scen.set(category)

# Filter elements to keep only those present in the scenario set
remove.set[category] = [elem for elem in elements if elem in scen_set.values]

return dict(require=require, remove=remove, add=add)


Expand Down

0 comments on commit 135f090

Please sign in to comment.