Skip to content

Commit 1396cf2

Browse files
committed
Dry_run affecting success()
Allows dry_run to affect success: report.success() to return true if dry_run is true as well.
1 parent 9a73735 commit 1396cf2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

_delphi_utils_python/delphi_utils/validator/report.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
class ValidationReport:
88
"""Class for reporting the results of validation."""
99

10-
def __init__(self, errors_to_suppress: List[ValidationFailure], data_source: str = ""):
10+
def __init__(self, errors_to_suppress: List[ValidationFailure],
11+
data_source: str = "", dry_run: bool = False):
1112
"""Initialize a ValidationReport.
1213
1314
Parameters
@@ -41,6 +42,7 @@ def __init__(self, errors_to_suppress: List[ValidationFailure], data_source: str
4142
self.raised_errors = []
4243
self.raised_warnings = []
4344
self.unsuppressed_errors = []
45+
self.dry_run = dry_run
4446

4547
def add_raised_error(self, error):
4648
"""Add an error to the report.
@@ -120,4 +122,4 @@ def print_and_exit(self, logger=None, die_on_failures=True):
120122

121123
def success(self):
122124
"""Determine if the report corresponds to a successful validation run."""
123-
return len(self.unsuppressed_errors) == 0
125+
return len(self.unsuppressed_errors) == 0 or self.dry_run

_delphi_utils_python/delphi_utils/validator/validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, params):
3939
self.time_window = TimeWindow.from_params(validation_params["common"]["end_date"],
4040
validation_params["common"]["span_length"])
4141
self.data_source = validation_params["common"].get("data_source", "")
42+
self.dry_run = validation_params["common"].get("dry_run", False)
4243

4344
self.static_validation = StaticValidator(validation_params)
4445
self.dynamic_validation = DynamicValidator(validation_params)
@@ -53,7 +54,7 @@ def validate(self):
5354
Returns:
5455
- ValidationReport collating the validation outcomes
5556
"""
56-
report = ValidationReport(self.suppressed_errors, self.data_source)
57+
report = ValidationReport(self.suppressed_errors, self.data_source, self.dry_run)
5758
frames_list = load_all_files(self.export_dir, self.time_window.start_date,
5859
self.time_window.end_date)
5960
self.static_validation.validate(frames_list, report)

0 commit comments

Comments
 (0)