Skip to content

Commit eab8e6a

Browse files
committed
[section] Use custom cardinality checks validation
The cardinality checks are run quite frequently. To reduce the load of background checks on the Document, custom validations that only run the specific cardinality checks are used instead.
1 parent 5e4deed commit eab8e6a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

odml/section.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,12 @@ def _sections_cardinality_validation(self):
420420
Runs a validation to check whether the sections cardinality
421421
is respected and prints a warning message otherwise.
422422
"""
423-
valid = validation.Validation(self)
423+
# This check is run quite frequently so do not run all checks via the default validation
424+
# but use a custom validation instead.
425+
valid = validation.Validation(self, validate=False, reset=True)
426+
valid.register_custom_handler("section", validation.section_sections_cardinality)
427+
valid.run_validation()
428+
424429
val_id = validation.IssueID.section_sections_cardinality
425430

426431
# Make sure to display only warnings of the current section
@@ -475,7 +480,12 @@ def _properties_cardinality_validation(self):
475480
Runs a validation to check whether the properties cardinality
476481
is respected and prints a warning message otherwise.
477482
"""
478-
valid = validation.Validation(self)
483+
# This check is run quite frequently so do not run all checks via the default validation
484+
# but use a custom validation instead.
485+
valid = validation.Validation(self, validate=False, reset=True)
486+
valid.register_custom_handler("section", validation.section_properties_cardinality)
487+
valid.run_validation()
488+
479489
val_id = validation.IssueID.section_properties_cardinality
480490

481491
# Make sure to display only warnings of the current section

0 commit comments

Comments
 (0)