From a0adcd5a75ee3db87df4735958df803f2303dd80 Mon Sep 17 00:00:00 2001 From: Fridolin Glatter Date: Thu, 28 Nov 2024 12:38:30 +0100 Subject: [PATCH] Validate var/equ data only for non-empty data --- ixmp4/data/db/optimization/equation/model.py | 11 ++++++----- ixmp4/data/db/optimization/variable/model.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ixmp4/data/db/optimization/equation/model.py b/ixmp4/data/db/optimization/equation/model.py index e7588043..ee8d2898 100644 --- a/ixmp4/data/db/optimization/equation/model.py +++ b/ixmp4/data/db/optimization/equation/model.py @@ -31,11 +31,12 @@ def validate_data(self, key: Any, data: dict[str, Any]) -> dict[str, Any]: data_to_validate = copy.deepcopy(data) del data_to_validate["levels"] del data_to_validate["marginals"] - _ = utils.validate_data( - host=self, - data=data_to_validate, - columns=self.columns, - ) + if data_to_validate != {}: + _ = utils.validate_data( + host=self, + data=data_to_validate, + columns=self.columns, + ) return data __table_args__ = (db.UniqueConstraint("name", "run__id"),) diff --git a/ixmp4/data/db/optimization/variable/model.py b/ixmp4/data/db/optimization/variable/model.py index 32cfae59..548e7499 100644 --- a/ixmp4/data/db/optimization/variable/model.py +++ b/ixmp4/data/db/optimization/variable/model.py @@ -32,11 +32,12 @@ def validate_data(self, key: Any, data: dict[str, Any]) -> dict[str, Any]: data_to_validate = copy.deepcopy(data) del data_to_validate["levels"] del data_to_validate["marginals"] - _ = utils.validate_data( - host=self, - data=data_to_validate, - columns=self.columns, - ) + if data_to_validate != {}: + _ = utils.validate_data( + host=self, + data=data_to_validate, + columns=self.columns, + ) return data __table_args__ = (db.UniqueConstraint("name", "run__id"),)