Skip to content

Commit

Permalink
Chunking bug fix (#265)
Browse files Browse the repository at this point in the history
* Ensure mpid can be pulled from static calcs

* Linting

* Fix prechunking on materials and thermo

* Ensure -N arg is passed to prechunk properly
  • Loading branch information
Jason Munro authored Sep 9, 2021
1 parent 023da8a commit 1aaeed1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion emmet-builders/emmet/builders/vasp/materials.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
from itertools import chain
from math import ceil
from typing import Dict, Iterable, Iterator, List, Optional

from maggma.builders import Builder
Expand Down Expand Up @@ -107,7 +108,10 @@ def prechunk(self, number_splits: int) -> Iterable[Dict]:
if d[self.tasks.key] in to_process_tasks
}

for formula_chunk in grouper(to_process_forms, number_splits):
N = ceil(len(to_process_forms) / number_splits)

for formula_chunk in grouper(to_process_forms, N):

yield {"query": {"formula_pretty": {"$in": list(formula_chunk)}}}

def get_items(self) -> Iterator[List[Dict]]:
Expand Down
6 changes: 5 additions & 1 deletion emmet-builders/emmet/builders/vasp/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
from itertools import chain
from typing import Dict, Iterable, Iterator, List, Optional, Set
from math import ceil

from maggma.core import Builder, Store
from maggma.utils import grouper
Expand Down Expand Up @@ -82,7 +83,10 @@ def prechunk(self, number_splits: int) -> Iterable[Dict]:
if chemsys not in to_process_chemsys:
to_process_chemsys |= chemsys_permutations(chemsys)

for chemsys_chunk in grouper(to_process_chemsys, number_splits):
N = ceil(len(to_process_chemsys) / number_splits)

for chemsys_chunk in grouper(to_process_chemsys, N):

yield {"query": {"chemsys": {"$in": list(chemsys_chunk)}}}

def get_items(self) -> Iterator[List[Dict]]:
Expand Down

0 comments on commit 1aaeed1

Please sign in to comment.