Skip to content
Snippets Groups Projects
Commit 27739e4b authored by Theodore Chang's avatar Theodore Chang
Browse files

Merge branch '2100-some-of-the-example-archive-cannot-be-parsed-anymore' into 'develop'

Resolve "Some of the example archive cannot be parsed anymore"

See merge request !2130
parents b66d2d60 c90a7020
No related branches found
No related tags found
1 merge request!2130Resolve "Some of the example archive cannot be parsed anymore"
Pipeline #221882 failed
...@@ -70,6 +70,25 @@ except Exception: ...@@ -70,6 +70,25 @@ except Exception:
run_def = None run_def = None
has_mongo = False
logger = utils.get_logger(__name__)
def _check_mongo_connection():
from nomad.infrastructure import mongo_client
global has_mongo
if has_mongo or mongo_client is None:
return
try:
mongo_client.server_info()
has_mongo = True
except Exception as e:
logger.warning('MongoDB connection failed.', exc_info=e)
class AuthLevel(int, Enum): class AuthLevel(int, Enum):
""" """
Used to decorate fields with the authorization level required to edit them (using `a_auth_level`). Used to decorate fields with the authorization level required to edit them (using `a_auth_level`).
...@@ -922,6 +941,8 @@ class EntryMetadata(MSection): ...@@ -922,6 +941,8 @@ class EntryMetadata(MSection):
search_quantities = [] search_quantities = []
keywords_set = set() keywords_set = set()
_check_mongo_connection()
def get_section_path(section): def get_section_path(section):
section_path = section_paths.get(section) section_path = section_paths.get(section)
if section_path is None: if section_path is None:
...@@ -1001,6 +1022,9 @@ class EntryMetadata(MSection): ...@@ -1001,6 +1022,9 @@ class EntryMetadata(MSection):
Receives a definition of a quantity 'current_def' and checks if it is a reference to another entry. Receives a definition of a quantity 'current_def' and checks if it is a reference to another entry.
If yes, add the value to 'ref_pool'. If yes, add the value to 'ref_pool'.
""" """
if not has_mongo:
return
if isinstance(current_def, Quantity): if isinstance(current_def, Quantity):
# for quantities # for quantities
if not isinstance(current_def.type, Reference): if not isinstance(current_def.type, Reference):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment