Skip to content

Commit

Permalink
BSON made optional in emmet-core (#530)
Browse files Browse the repository at this point in the history
* Try except added to bson import

* Fix spglib dependency

* Remove bson from extras
  • Loading branch information
munrojm committed Sep 9, 2022
1 parent c6587a8 commit 282b625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion emmet-core/emmet/core/utils.py
Expand Up @@ -4,7 +4,6 @@
from typing import Any, Iterator, List, Tuple, Dict, Union
import copy

import bson
import numpy as np
from monty.json import MSONable
from pydantic import BaseModel
Expand All @@ -17,6 +16,11 @@

from emmet.core.settings import EmmetSettings

try:
import bson
except ImportError:
bson = None # type: ignore

SETTINGS = EmmetSettings()


Expand Down Expand Up @@ -165,6 +169,7 @@ def jsanitize(obj, strict=False, allow_bson=False):
or (bson is not None and isinstance(obj, bson.objectid.ObjectId))
):
return obj

if isinstance(obj, (list, tuple, set)):
return [jsanitize(i, strict=strict, allow_bson=allow_bson) for i in obj]
if np is not None and isinstance(obj, np.ndarray):
Expand Down
2 changes: 1 addition & 1 deletion emmet-core/setup.py
Expand Up @@ -32,7 +32,7 @@
"pydantic==1.10.1",
"pybtex~=0.24",
"typing-extensions>=3.7,<5.0",
"spglib<3.0.0",
"spglib<2.0.0",
],
extras_require={
"all": [
Expand Down

0 comments on commit 282b625

Please sign in to comment.