Skip to content

Commit

Permalink
Add last updated query to task search
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Jan 5, 2024
1 parent 09bdd4f commit 8a84e76
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mp_api/client/routes/materials/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import warnings
from datetime import datetime

from emmet.core.tasks import TaskDoc

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

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

if last_updated:
query_params.update(
{
"last_updated_min": last_updated[0],
"last_updated_max": last_updated[1],
}
)

return super()._search(
num_chunks=num_chunks,
chunk_size=chunk_size,
Expand Down

0 comments on commit 8a84e76

Please sign in to comment.