Commit ce4d927f authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Avoid empty section_workflow.

parent 913f82c8
Pipeline #83348 passed with stages
in 22 minutes and 20 seconds
......@@ -15,6 +15,7 @@
import numpy as np
from nomad.normalizing.normalizer import Normalizer
from nomad.datamodel import EntryArchive
from nomad.datamodel.metainfo.public import Workflow, GeometryOptimization, Phonon, Elastic,\
MolecularDynamics
......@@ -344,10 +345,6 @@ class WorkflowNormalizer(Normalizer):
if self.section_run is None:
return
workflow = self.entry_archive.section_workflow
if not workflow:
workflow = self.entry_archive.m_create(Workflow)
workflow_type = None
if self.entry_archive.section_workflow:
workflow_type = self.entry_archive.section_workflow.workflow_type
......@@ -358,6 +355,10 @@ class WorkflowNormalizer(Normalizer):
if not workflow_type:
return
workflow = self.entry_archive.section_workflow
if not workflow:
workflow = self.entry_archive.m_create(Workflow)
workflow.workflow_type = workflow_type
if workflow.workflow_type == 'geometry_optimization':
......@@ -371,3 +372,7 @@ class WorkflowNormalizer(Normalizer):
elif workflow.workflow_type == 'molecular_dynamics':
MolecularDynamicsNormalizer(self.entry_archive).normalize()
# remove the section workflow again, if the parser/normalizer could not produce a result
if workflow.calculation_result_ref is None:
self.entry_archive.m_remove_sub_section(EntryArchive.section_workflow, -1)
......@@ -27,6 +27,12 @@ def workflow_archive():
return _archive
def test_no_workflow(workflow_archive):
vasp_archive = workflow_archive(
'parsers/vaspoutcar', 'tests/data/parsers/vasp_outcar/OUTCAR')
assert vasp_archive.section_workflow is None
def test_geometry_optimization_workflow(workflow_archive):
vasp_archive = workflow_archive(
'parsers/vasp', 'tests/data/normalizers/workflow/vasp/vasprun.xml')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment