spine-tools / Spine-Toolbox

Spine Toolbox is an open source Python package to manage data, scenarios and workflows for modelling and simulation. You can have your local workflow, but work as a team through version control and SQL databases.
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
73 stars 18 forks source link

Parameter type validation #2912

Closed soininen closed 3 months ago

soininen commented 3 months ago

This PR implements parameter type validation in Database editor. Parameter definition table now has a new column, "valid types" which lists accepted value types for the parameter. If any types are specified in the column, both values and default values are validated against the types. Invalid types are marked by an exclamation icon and a tool tip provides more information.

As much of the validation as possible has been offloaded to a worker process so the validation should not affect DB editor's responsiveness too much.

spinedb_api side PR: spine-tools/Spine-Database-API#439

Implements #2791

Checklist before merging

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 77.32181% with 105 lines in your changes missing coverage. Please review.

Project coverage is 66.96%. Comparing base (1b51b6a) to head (5567426).

Files Patch % Lines
...etoolbox/spine_db_editor/widgets/custom_editors.py 67.10% 22 Missing and 3 partials :warning:
...oolbox/spine_db_editor/widgets/custom_delegates.py 45.00% 22 Missing :warning:
spinetoolbox/parameter_type_validation.py 77.77% 16 Missing and 2 partials :warning:
...olbox/spine_db_editor/mvcmodels/compound_models.py 50.00% 12 Missing and 4 partials :warning:
spinetoolbox/spine_db_manager.py 76.11% 15 Missing and 1 partial :warning:
...toolbox/spine_db_editor/mvcmodels/single_models.py 88.33% 5 Missing and 2 partials :warning:
...oolbox/spine_db_editor/ui/parameter_type_editor.py 98.98% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2912 +/- ## ========================================== + Coverage 66.90% 66.96% +0.05% ========================================== Files 187 189 +2 Lines 36464 36878 +414 Branches 6241 6312 +71 ========================================== + Hits 24398 24695 +297 - Misses 10764 10871 +107 - Partials 1302 1312 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.