From 7f598adf1958112c8790f1d4135199518dfec426 Mon Sep 17 00:00:00 2001 From: Kalev Takkis Date: Tue, 14 Nov 2023 14:39:34 +0000 Subject: [PATCH] fix: target loader can process most recent data --- viewer/target_loader.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/viewer/target_loader.py b/viewer/target_loader.py index ae243593..56fac359 100644 --- a/viewer/target_loader.py +++ b/viewer/target_loader.py @@ -814,10 +814,17 @@ def process_metadata( # add xtalform fk to experiment for _, obj in experiment_objects.items(): - obj.instance.xtalform = xtalform_objects[ - assigned_xtalforms[obj.instance.code] - ].instance - obj.instance.save() + try: + obj.instance.xtalform = xtalform_objects[ + assigned_xtalforms[obj.instance.code] + ].instance + obj.instance.save() + except KeyError: + # TODO: don't know at this point whether ignoring this + # error is a right thing to do + msg = f"xtalform {obj.instance.code} undefined for {obj}" + result.append(msg) + logger.warning(msg) quat_assembly_objects = {} for idx, obj in assemblies.items(): @@ -1332,6 +1339,8 @@ def load_target( update_task(task, "SUCCESS", upload_report) target_loader.experiment_upload.message = upload_report + logger.debug("%s", upload_report) + target_loader.experiment_upload.save()