Skip to content

Commit

Permalink
Validate var/equ data only for non-empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Dec 19, 2024
1 parent eedc846 commit a0adcd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions ixmp4/data/db/optimization/equation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),)
11 changes: 6 additions & 5 deletions ixmp4/data/db/optimization/variable/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),)

0 comments on commit a0adcd5

Please sign in to comment.