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
7dc42708
Commit
7dc42708
authored
Jul 27, 2020
by
Markus Scheidgen
Browse files
Fixed resoursive adding of sections to resources.
parent
2207138a
Changes
3
Show whitespace changes
Inline
Side-by-side
nomad/metainfo/metainfo.py
View file @
7dc42708
...
...
@@ -521,8 +521,23 @@ class MResource():
return
cast
(
MSectionBound
,
result
)
def
add
(
self
,
section
):
section
.
m_resource
=
self
self
.
__data
.
setdefault
(
section
.
m_def
,
[]).
append
(
section
)
'''
Add the given section to this resource. Will also add all its contents to the
resource and make all contest available for :func:`all`. Will also remove
all contents from possible other resources. A section can only be contained in
one resource at a time.
This is potentially expensive. Do not add a section that already has a deep tree
of sub-sections. Ideally, add the root section first. If you create sub sections
afterwards, they will be automatically added to this resource.
'''
if
section
.
m_resource
is
not
None
:
section
.
m_resource
.
remove
(
section
)
for
content
in
section
.
m_all_contents
(
include_self
=
True
):
content
.
m_resource
=
self
self
.
__data
.
setdefault
(
content
.
m_def
,
[]).
append
(
content
)
if
section
.
m_parent
is
None
:
self
.
contents
.
append
(
section
)
...
...
nomad/processing/data.py
View file @
7dc42708
...
...
@@ -414,7 +414,7 @@ class Calc(Proc):
information in section_encyclopedia as well as the DFT domain metadata.
"""
try
:
logger
=
self
.
get_logger
(
**
context
)
logger
=
self
.
get_logger
(
parser
=
self
.
parser
,
step
=
self
.
parser
)
# Open the archive of the phonon calculation.
upload_files
=
StagingUploadFiles
(
self
.
upload_id
,
is_authorized
=
lambda
:
True
)
...
...
@@ -425,7 +425,6 @@ class Calc(Proc):
self
.
_calc_proc_logs
=
phonon_archive
.
processing_logs
# Re-create a backend
context
=
dict
(
parser
=
self
.
parser
,
step
=
self
.
parser
)
metainfo
=
phonopyparser
.
metainfo
.
m_env
self
.
_parser_backend
=
Backend
(
metainfo
,
logger
=
logger
,
domain
=
"dft"
)
self
.
_parser_backend
.
entry_archive
=
phonon_archive
...
...
tests/metainfo/test_metainfo.py
View file @
7dc42708
...
...
@@ -519,6 +519,22 @@ class TestM1:
assert
len
(
resource
.
all
(
System
))
==
2
def
test_resource_add
(
self
):
# adding
resource
=
MResource
()
run
=
Run
()
resource
.
add
(
run
)
run
.
m_create
(
System
)
run
.
m_create
(
System
)
assert
len
(
resource
.
all
(
Run
))
==
1
assert
len
(
resource
.
all
(
System
))
==
2
# implicitly moving to another resource
resource
=
MResource
()
resource
.
add
(
run
)
assert
len
(
resource
.
all
(
Run
))
==
1
assert
len
(
resource
.
all
(
System
))
==
2
def
test_resource_move
(
self
):
resource
=
MResource
()
run
=
resource
.
create
(
Run
)
...
...
Write
Preview
Markdown
is supported
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