Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
python-common
Commits
4371e71e
Commit
4371e71e
authored
6 years ago
by
Markus Scheidgen
Browse files
Options
Downloads
Patches
Plain Diff
Allow for infrastructure to set logger on parsers.
parent
5a690dd1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/python/nomadcore/baseclasses.py
+24
-14
24 additions, 14 deletions
common/python/nomadcore/baseclasses.py
with
24 additions
and
14 deletions
common/python/nomadcore/baseclasses.py
+
24
−
14
View file @
4371e71e
...
...
@@ -9,7 +9,9 @@ import os
import
copy
import
numpy
as
np
import
logging
from
future.utils
import
with_metaclass
from
abc
import
ABCMeta
,
abstractmethod
from
nomadcore.unit_conversion
import
unit_conversion
from
nomadcore.simple_parser
import
mainFunction
from
nomadcore.local_backend
import
LocalBackend
...
...
@@ -17,9 +19,8 @@ from nomadcore.local_meta_info import load_metainfo
from
nomadcore.caching_backend
import
CachingLevel
from
nomadcore.simple_parser
import
extractOnCloseTriggers
,
extractOnOpenTriggers
from
nomadcore.caching_backend
import
ActiveBackend
import
nomadcore.ActivateLogging
from
future.utils
import
with_metaclass
logger
=
logging
.
getLogger
(
"
nomad
"
)
logger
=
logging
.
getLogger
(
__file__
)
class
ParserInterface
(
with_metaclass
(
ABCMeta
,
object
)):
...
...
@@ -43,22 +44,31 @@ class ParserInterface(with_metaclass(ABCMeta, object)):
"""
metainfo_env
=
None
def
__init__
(
self
,
metainfo_to_keep
=
None
,
backend
=
None
,
default_units
=
None
,
metainfo_units
=
None
,
debug
=
False
,
log_level
=
logging
.
ERROR
,
store
=
True
):
def
__init__
(
self
,
metainfo_to_keep
=
None
,
backend
=
None
,
default_units
=
None
,
metainfo_units
=
None
,
debug
=
False
,
log_level
=
logging
.
ERROR
,
store
=
True
):
"""
Args:
main_file: A special file that can be considered the main file of the
calculation.
Arguments:
metainfo_to_keep: A list of metainfo names. This list is used to
optimize the parsing process as optimally only the information
relevant to these metainfos will be parsed.
backend: An object to which the parser will give all the parsed data.
The backend will then determine where and when to output that data.
"""
self
.
debug
=
debug
try
:
logger
.
setLevel
(
log_level
)
except
Exception
:
# might fail on custom loggers
pass
self
.
store
=
store
self
.
debug
=
debug
self
.
initialize
(
metainfo_to_keep
,
backend
,
default_units
,
metainfo_units
)
def
setup_logger
(
self
,
new_logger
):
global
logger
logger
=
new_logger
def
initialize
(
self
,
metainfo_to_keep
,
backend
,
default_units
,
metainfo_units
):
"""
Initialize the parser with the given environment.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment