Commit 82efe21c authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added more structure log output for easier monitoring.

parent e1e59adb
Pipeline #70669 failed with stages
in 17 minutes and 55 seconds
......@@ -130,7 +130,7 @@ class EncyclopediaNormalizer(Normalizer):
except KeyError:
self.logger.info(
"Cannot determine encyclopedia run type because missing "
"value for frame_sequence_to_sampling_ref"
"value for frame_sequence_to_sampling_ref."
)
return run_type
......@@ -140,11 +140,11 @@ class EncyclopediaNormalizer(Normalizer):
except KeyError:
self.logger.info(
"section_frame_sequence_local_frames not found although a "
"frame_sequence exists"
"frame_sequence exists."
)
return run_type
if len(frames) == 0:
self.logger.info("No frames referenced in section_frame_sequence_local_frames")
self.logger.info("No frames referenced in section_frame_sequence_local_frames.")
return run_type
section_sampling_method = self._backend[s_sampling_method][i_sampling_method]
......@@ -290,56 +290,74 @@ class EncyclopediaNormalizer(Normalizer):
properties.normalize(ctx)
def normalize(self, logger=None) -> None:
super().normalize(logger)
# Initialise metainfo structure
sec_enc = Encyclopedia()
material = sec_enc.m_create(Material)
method = sec_enc.m_create(Method)
sec_enc.m_create(Properties)
run_type = sec_enc.m_create(RunType)
# Get generic data
self.mainfile_uri(sec_enc)
# Determine run type, stop if unknown
run_type_name = self.run_type(run_type)
if run_type_name == config.services.unavailable_value:
self.logger.info("unknown run type for encyclopedia, encyclopedia metainfo not created")
return
try:
super().normalize(logger)
# Get the system type, stop if unknown
system_enums = Material.system_type.type
representative_system, system_type = self.system_type(material)
if system_type != system_enums.bulk and system_type != system_enums.two_d and system_type != system_enums.one_d:
self.logger.info("unknown system type for encyclopedia, encyclopedia metainfo not created")
return
# Initialise metainfo structure
sec_enc = Encyclopedia()
material = sec_enc.m_create(Material)
method = sec_enc.m_create(Method)
sec_enc.m_create(Properties)
run_type = sec_enc.m_create(RunType)
# Get the method type, stop if unknown
representative_method, method_type = self.method_type(method)
# Get generic data
self.mainfile_uri(sec_enc)
# Get representative scc
try:
representative_scc_idx = self._backend[s_run][0].tmp["representative_scc_idx"]
representative_scc = self._backend[s_scc][representative_scc_idx]
except (KeyError, IndexError):
representative_scc = None
representative_scc_idx = None
# Create one context that holds all details
context = Context(
system_type=system_type,
method_type=method_type,
run_type=run_type_name,
representative_system=representative_system,
representative_method=representative_method,
representative_scc=representative_scc,
representative_scc_idx=representative_scc_idx,
)
# Determine run type, stop if unknown
run_type_name = self.run_type(run_type)
if run_type_name == config.services.unavailable_value:
self.logger.info(
"Unknown run type for encyclopedia, encyclopedia metainfo not created.",
enc_status="unknown_run_type"
)
return
# Put the encyclopedia section into backend
self._backend.add_mi2_section(sec_enc)
self.fill(context)
# Get the system type, stop if unknown
system_enums = Material.system_type.type
representative_system, system_type = self.system_type(material)
if system_type != system_enums.bulk and system_type != system_enums.two_d and system_type != system_enums.one_d:
self.logger.info(
"Unknown system type for encyclopedia, encyclopedia metainfo not created.",
enc_status="unknown_system_type"
)
return
# Get the method type, stop if unknown
representative_method, method_type = self.method_type(method)
# Get representative scc
try:
representative_scc_idx = self._backend[s_run][0].tmp["representative_scc_idx"]
representative_scc = self._backend[s_scc][representative_scc_idx]
except (KeyError, IndexError):
representative_scc = None
representative_scc_idx = None
# Create one context that holds all details
context = Context(
system_type=system_type,
method_type=method_type,
run_type=run_type_name,
representative_system=representative_system,
representative_method=representative_method,
representative_scc=representative_scc,
representative_scc_idx=representative_scc_idx,
)
# Put the encyclopedia section into backend
self._backend.add_mi2_section(sec_enc)
self.fill(context)
self.logger.info(
"Successfully created metainfo for Encyclopedia.",
enc_status="success"
)
except Exception as e:
self.logger.info(
"Failed to create an Encyclopedia entry due to an unhandlable exception.",
enc_status="failure",
exc_info=e,
)
class MaterialNormalizer():
......
Supports Markdown
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