Skip to content

Commit

Permalink
rename overlay to extended_data .
Browse files Browse the repository at this point in the history
throw_errors is more pythonic in code
  • Loading branch information
MohitYadav-codes committed May 15, 2024
1 parent 12d0a15 commit 4900b2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions akm_tools/akm_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def create_and_combine_json_from_a_folder(dir_path):
return list_to_return


def parse_and_validate_data(model_folder, schema, extended_schema_dir, overlays,silent_mode):
def parse_and_validate_data(model_folder, schema, extended_schema_dir, extended_data_dir,raise_errors):
model_data_list = create_and_combine_json_from_a_folder(model_folder)
overlay_data_list = create_and_combine_json_from_a_folder(overlays)
all_data = model_data_list + overlay_data_list
extended_data_list = create_and_combine_json_from_a_folder(extended_data_dir)
all_data = model_data_list + extended_data_list
validator_object = AKMDataValidator(schema=schema)
validated_model_data = validator_object.validate_data_instances(all_data, extended_schema_dir=extended_schema_dir)
validated_model_data = validator_object.validate_contexts(all_data=validated_model_data) ## passing valid instances
validator_object.log_errors(silent_mode)
validator_object.log_errors(raise_errors)

return validated_model_data

Expand Down Expand Up @@ -111,7 +111,11 @@ def main():
with open(args.schema, "r") as f:
schema = json.load(f)
validated_model_data = parse_and_validate_data(
args.model_data_folder, schema, args.extended_schema_dir, args.extended_data_dir,args.silent_mode
model_folder=args.model_data_folder,
schema=schema,
extended_schema_dir=args.extended_schema_dir,
extended_data_dir=args.extended_data_dir,
raise_errors=not(args.silent_mode)
)

if args.export_format:
Expand Down
4 changes: 2 additions & 2 deletions akm_tools/validation/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def _configure_data_instance_validators(self):
]
return data_instance_validator_objects

def log_errors(self,silent_mode):
def log_errors(self,raise_errors):
for error_msg in self.validation_errors:
logging.error(error_msg)
if len (self.validation_errors)>0:
if not(silent_mode):
if raise_errors:
raise Exception('There were errors during vaidaiton, please check the log file')

def validate_contexts(self, all_data: List[Dict]):
Expand Down

0 comments on commit 4900b2b

Please sign in to comment.