Skip to content

Commit 9556ba3

Browse files
authored
Merge pull request #58 from edanalytics/fix/fast-fail-optional
Bugfix: make `max_failures` truly optional
2 parents 0e6cffe + 78d6f64 commit 9556ba3

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

lightbeam/validate.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class Validator:
1414
MAX_VALIDATION_ERRORS_TO_DISPLAY = 10
1515
MAX_VALIDATE_TASK_QUEUE_SIZE = 100
1616
DEFAULT_VALIDATION_METHODS = ["schema", "descriptors", "uniqueness"]
17-
DEFAULT_FAIL_FAST_THRESHOLD = 10
1817

1918
EDFI_GENERICS_TO_RESOURCES_MAPPING = {
2019
"educationOrganizations": ["localEducationAgencies", "stateEducationAgencies", "schools"],
@@ -35,7 +34,7 @@ def __init__(self, lightbeam=None):
3534
def validate(self):
3635

3736
# The below should go in __init__(), but rely on lightbeam.config which is not yet available there.
38-
self.fail_fast_threshold = self.lightbeam.config.get("validate",{}).get("references",{}).get("max_failures", self.DEFAULT_FAIL_FAST_THRESHOLD)
37+
self.fail_fast_threshold = self.lightbeam.config.get("validate",{}).get("references",{}).get("max_failures", None)
3938
self.validation_methods = self.lightbeam.config.get("validate",{}).get("methods",self.DEFAULT_VALIDATION_METHODS)
4039
if type(self.validation_methods)==str and (self.validation_methods=="*" or self.validation_methods.lower()=='all'):
4140
self.validation_methods = self.DEFAULT_VALIDATION_METHODS
@@ -219,7 +218,7 @@ async def validate_endpoint(self, endpoint):
219218
self.lightbeam.metadata["resources"][endpoint]["records_failed"] = self.lightbeam.num_errors
220219

221220
# implement "fail fast" feature:
222-
if self.lightbeam.num_errors >= self.fail_fast_threshold:
221+
if self.fail_fast_threshold is not None and self.lightbeam.num_errors >= self.fail_fast_threshold:
223222
self.lightbeam.shutdown("validate")
224223
self.logger.critical(f"... STOPPING; found {self.lightbeam.num_errors} >= validate.references.max_failures={self.fail_fast_threshold} VALIDATION ERRORS.")
225224
break
@@ -235,7 +234,7 @@ async def validate_endpoint(self, endpoint):
235234

236235

237236
async def do_validate_payload(self, endpoint, file_name, data, line_counter):
238-
if self.lightbeam.num_errors >= self.fail_fast_threshold: return
237+
if self.fail_fast_threshold is not None and self.lightbeam.num_errors >= self.fail_fast_threshold: return
239238
definition = self.get_swagger_definition_for_endpoint(endpoint)
240239
if "Descriptor" in endpoint:
241240
swagger = self.lightbeam.api.descriptors_swagger

0 commit comments

Comments
 (0)