Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
saving only one JSON file with all the information
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorpm committed Feb 9, 2024
1 parent 8773286 commit da4cc8f
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions bg_atlasgen/validate_atlases.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,51 +152,45 @@ def validate_atlas(atlas_name, version, validation_functions):
if not updated:
update_atlas(atlas_name)

# dictionary of lists to store the errors of the failed validations
failed_validations = {atlas_name: []}
successful_validations = {atlas_name: []}
validation_results = {atlas_name: []}

for i, validation_function in enumerate(validation_functions):
for i, validation_function in enumerate(all_validation_functions):
try:
validation_function(BrainGlobeAtlas(atlas_name))
successful_validations[atlas_name].append(
validation_function.__name__
validation_results[atlas_name].append(
(validation_function.__name__, None, str("Pass"))
)
except AssertionError as error:
failed_validations[atlas_name].append(
(validation_function.__name__, str(error))
validation_results[atlas_name].append(
(validation_function.__name__, str(error), str("Fail"))
)

return successful_validations, failed_validations
return validation_results


if __name__ == "__main__":
# list to store the validation functions
all_validation_functions = [
validate_atlas_files,
validate_mesh_matches_image_extents,
open_for_visual_check,
validate_checksum,
# validate_atlas_files,
# validate_mesh_matches_image_extents,
# open_for_visual_check,
# validate_checksum,
check_additional_references,
validate_mesh_structure_pairs,
]

valid_atlases = []
invalid_atlases = []
successful_validations = {}
failed_validations = {}
validation_results = {}

for atlas_name, version in get_all_atlases_lastversions().items():
temp_successful_validations, temp_failed_validations = validate_atlas(
atlas_name, version, all_validation_functions
)
temp_validation_results = validate_atlas(atlas_name, version, all_validation_functions)
validation_results.update(temp_validation_results)

successful_validations.update(temp_successful_validations)
failed_validations.update(temp_failed_validations)

print("Validation has been completed")
print(
"Find successful_validations.json and failed_validations.json in ~/.brainglobe/atlases/validation/"
"Find validation_results.json in ~/.brainglobe/atlases/validation/"
)

# Get the directory path
Expand All @@ -209,19 +203,8 @@ def validate_atlas(atlas_name, version, validation_functions):
# Open a file for writing (will overwrite any files from previous runs!)
with open(
str(
get_brainglobe_dir() / "atlases/validation/failed_validations.json"
),
"w",
) as file:
# Write the dictionary to the file in JSON format
json.dump(failed_validations, file)

with open(
str(
get_brainglobe_dir()
/ "atlases/validation/successful_validations.json"
get_brainglobe_dir() / "atlases/validation/validation_results.json"
),
"w",
) as file:
# Write the dictionary to the file in JSON format
json.dump(successful_validations, file)
json.dump(validation_results, file)

0 comments on commit da4cc8f

Please sign in to comment.