Skip to content

Commit 8a84e76

Browse files
author
munrojm
committed
Add last updated query to task search
1 parent 09bdd4f commit 8a84e76

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: mp_api/client/routes/materials/tasks.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import warnings
4+
from datetime import datetime
45

56
from emmet.core.tasks import TaskDoc
67

@@ -48,6 +49,7 @@ def search(
4849
elements: list[str] | None = None,
4950
exclude_elements: list[str] | None = None,
5051
formula: str | list[str] | None = None,
52+
last_updated: tuple[datetime, datetime] | None = None,
5153
num_chunks: int | None = None,
5254
chunk_size: int = 1000,
5355
all_fields: bool = True,
@@ -64,6 +66,7 @@ def search(
6466
formula (str, List[str]): A formula including anonymized formula
6567
or wild cards (e.g., Fe2O3, ABO3, Si*). A list of chemical formulas can also be passed
6668
(e.g., [Fe2O3, ABO3]).
69+
last_updated (tuple[datetime, datetime]): A tuple of min and max UTC formatted datetimes.
6770
num_chunks (int): Maximum number of chunks of data to yield. None will yield all possible.
6871
chunk_size (int): Number of data entries per chunk. Max size is 100.
6972
all_fields (bool): Whether to return all fields in the document. Defaults to True.
@@ -93,6 +96,14 @@ def search(
9396

9497
query_params.update({"chemsys": ",".join(chemsys)})
9598

99+
if last_updated:
100+
query_params.update(
101+
{
102+
"last_updated_min": last_updated[0],
103+
"last_updated_max": last_updated[1],
104+
}
105+
)
106+
96107
return super()._search(
97108
num_chunks=num_chunks,
98109
chunk_size=chunk_size,

0 commit comments

Comments
 (0)