diff --git a/package/PartSegCore/_old_json_hooks.py b/package/PartSegCore/_old_json_hooks.py index 2f4042ccc..63161ea16 100644 --- a/package/PartSegCore/_old_json_hooks.py +++ b/package/PartSegCore/_old_json_hooks.py @@ -1,3 +1,4 @@ +import nme import numpy as np from napari.utils import Colormap @@ -90,6 +91,10 @@ def part_hook(dkt): dkt["measurement_profile"] = dkt["statistic_profile"] del dkt["statistic_profile"] except Exception as e: # pylint: disable=W0703 + problematic_fields = nme.check_for_errors_in_dkt_values(dkt2) + if problematic_fields: + dkt2["__error__"] = f"Error in fields: {', '.join(problematic_fields)}" + return dkt2 dkt = dkt2 dkt["__error__"] = str(e) @@ -149,6 +154,10 @@ def profile_hook(dkt): dkt["colors"].append(dkt["colors"][-1]) return Colormap(**dkt) except Exception as e: # pylint: disable=W0703 + problematic_fields = nme.check_for_errors_in_dkt_values(dkt2) + if problematic_fields: + dkt2["__error__"] = f"Error in fields: {', '.join(problematic_fields)}" + return dkt2 dkt = dkt2 dkt["__error__"] = str(e) diff --git a/package/PartSegCore/json_hooks.py b/package/PartSegCore/json_hooks.py index d00736142..0acc78377 100644 --- a/package/PartSegCore/json_hooks.py +++ b/package/PartSegCore/json_hooks.py @@ -12,6 +12,10 @@ def partseg_object_hook(dkt: dict): return nme.nme_object_hook(dkt) if "__ReadOnly__" in dkt or "__Serializable__" in dkt or "__Enum__" in dkt: + problematic_fields = nme.check_for_errors_in_dkt_values(dkt) + if problematic_fields: + dkt["__error__"] = f"Error in fields: {', '.join(problematic_fields)}" + return dkt is_enum = "__Enum__" in dkt for el in ("__Enum__", "__Serializable__", "__ReadOnly__"): dkt.pop(el, None) diff --git a/setup.cfg b/setup.cfg index dd9a9908e..fe1e64697 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,7 +46,7 @@ install_requires = magicgui>=0.3.3 mahotas>=1.4.9 napari>=0.4.8 - nme>=0.1.3 + nme>=0.1.4 numpy>=1.18.0 oiffile>=2020.1.18 openpyxl>=2.4.9