Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
e7b711ea
Commit
e7b711ea
authored
Apr 01, 2022
by
Markus Scheidgen
Browse files
Resolve "Plug-and-play metainfo not working on v1.1.0"
parent
51fbe2ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
nomad/app/main.py
View file @
e7b711ea
...
...
@@ -68,6 +68,9 @@ app.mount(app_base, WSGIMiddleware(flask_app))
@
app
.
on_event
(
'startup'
)
async
def
startup_event
():
from
nomad.parsing.parsers
import
import_all_parsers
import_all_parsers
()
from
nomad
import
infrastructure
# each subprocess is supposed disconnect connect again: https://jira.mongodb.org/browse/PYTHON-2090
try
:
...
...
nomad/cli/dev.py
View file @
e7b711ea
...
...
@@ -77,8 +77,8 @@ def _all_metainfo_packages():
# TODO similar to before, due to lazyloading, we need to explicily access parsers
# to actually import all parsers and indirectly all metainfo packages
from
nomad.parsing
import
parsers
parsers
.
parsers
from
nomad.parsing
.parsers
import
import_all_
parsers
import_all_
parsers
()
# Create the ES mapping to populate ES annoations with search keys.
from
nomad.search
import
entry_type
...
...
nomad/parsing/parser.py
View file @
e7b711ea
...
...
@@ -237,18 +237,27 @@ class MatchingParserInterface(MatchingParser):
def
mainfile_parser
(
self
):
if
self
.
_mainfile_parser
is
None
:
try
:
module_path
,
parser_class
=
self
.
_parser_class_name
.
rsplit
(
'.'
,
1
)
module
=
importlib
.
import_module
(
module_path
)
self
.
_mainfile_parser
=
getattr
(
module
,
parser_class
)()
Parser
=
self
.
import_parser_class
()
self
.
_mainfile_parser
=
Parser
()
except
Exception
as
e
:
logger
=
utils
.
get_logger
(
__name__
)
logger
.
error
(
'
Error importing
parser.'
,
exc_info
=
e
)
logger
.
error
(
'
cannot instantiate
parser.'
,
exc_info
=
e
)
raise
e
return
self
.
_mainfile_parser
def
parse
(
self
,
mainfile
:
str
,
archive
:
EntryArchive
,
logger
=
None
):
self
.
mainfile_parser
.
parse
(
mainfile
,
archive
,
logger
)
def
import_parser_class
(
self
):
try
:
module_path
,
parser_class
=
self
.
_parser_class_name
.
rsplit
(
'.'
,
1
)
module
=
importlib
.
import_module
(
module_path
)
return
getattr
(
module
,
parser_class
)
except
Exception
as
e
:
logger
=
utils
.
get_logger
(
__name__
)
logger
.
error
(
'cannot import parser'
,
exc_info
=
e
)
raise
e
class
ArchiveParser
(
MatchingParser
):
def
__init__
(
self
):
...
...
nomad/parsing/parsers.py
View file @
e7b711ea
...
...
@@ -545,3 +545,13 @@ for parser in parsers:
code_names
=
sorted
(
set
(
code_names
),
key
=
lambda
code_name
:
code_name
.
lower
())
results
.
Simulation
.
program_name
.
a_elasticsearch
[
0
].
values
=
code_names
+
[
config
.
services
.
unavailable_value
,
config
.
services
.
not_processed_value
]
def
import_all_parsers
():
'''
Imports all the parsers. This will instantiate all parser metainfo as a side
effect.
'''
for
parser
in
parsers
:
if
isinstance
(
parser
,
MatchingParserInterface
):
parser
.
import_parser_class
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment