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

use bson.json_util.loads for S3 #933

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions mp_api/client/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
API v3 to enable the creation of data structures and pymatgen objects using
Materials Project data.
"""

from __future__ import annotations

import itertools
Expand All @@ -21,6 +22,7 @@
from urllib.parse import quote, urljoin

import requests
from bson import json_util
from emmet.core.utils import jsanitize
from monty.json import MontyDecoder
from pydantic import BaseModel, create_model
Expand Down Expand Up @@ -494,7 +496,7 @@ def _query_resource(
)
suffix = suffix.replace("_", "-")

# Paginate over all entried in the bucket.
# Paginate over all entries in the bucket.
# This will have to change for when a subset of entries from
# the DB is needed.
is_tasks = "tasks" in suffix
Expand All @@ -516,7 +518,9 @@ def _query_resource(
if key:
keys.append(key)

decoder = MontyDecoder().decode if self.monty_decode else json.loads
decoder = (
MontyDecoder().decode if self.monty_decode else json_util.loads
)

# Multithreaded function inputs
s3_params_list = {
Expand Down
4 changes: 3 additions & 1 deletion mp_api/client/mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,9 @@ def get_charge_density_from_material_id(
if self.use_document_model
else x["last_updated"], # type: ignore
)
task_id = latest_doc.task_id if self.use_document_model else latest_doc["task_id"]
task_id = (
latest_doc.task_id if self.use_document_model else latest_doc["task_id"]
)
return self.get_charge_density_from_task_id(task_id, inc_task_doc)

def get_download_info(self, material_ids, calc_types=None, file_patterns=None):
Expand Down
Loading