diff --git a/.gitignore b/.gitignore index ee9ae770e9..e9ede979b0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ compile_commands.json *.lo *.o *.obj +*.pyc # Precompiled Headers *.gch diff --git a/scripts/JSON_data_files_validator.py b/scripts/JSON_data_files_validator.py index 1f6301592f..9bed3eb368 100644 --- a/scripts/JSON_data_files_validator.py +++ b/scripts/JSON_data_files_validator.py @@ -15,7 +15,8 @@ import brotli from schema import And, Optional, Schema - +# Import VT related schemas +import LBDatafile_schema def exc_handler(exception_type, exception, traceback): """ Exception handler for hiding traceback. """ @@ -38,91 +39,7 @@ def get_error_message(iterable_collection: Iterable) -> str: def _get_valid_schema(self) -> Schema: """ Returns representation of a valid schema """ - allowed_types_data = ("LBDatafile") - valid_schema_data = Schema( - { - Optional('type'): And(str, lambda a: a in allowed_types_data, - error=f"{self.get_error_message(allowed_types_data)} must be chosen"), - Optional('metadata'): { - Optional('type'): And(str, lambda a: a in allowed_types_data, - error=f"{self.get_error_message(allowed_types_data)} must be chosen"), - Optional('rank'): int, - Optional('shared_node'): { - 'id': int, - 'size': int, - 'rank': int, - 'num_nodes': int, - }, - Optional('phases'): { - Optional('count'): int, - 'skipped': { - 'list': [int], - 'range': [[int]], - }, - 'identical_to_previous': { - 'list': [int], - 'range': [[int]], - }, - }, - Optional('attributes'): dict - }, - 'phases': [ - { - 'id': int, - 'tasks': [ - { - 'entity': { - Optional('collection_id'): int, - 'home': int, - 'id': int, - Optional('index'): [int], - 'type': str, - 'migratable': bool, - Optional('objgroup_id'): int - }, - 'node': int, - 'resource': str, - Optional('subphases'): [ - { - 'id': int, - 'time': float, - } - ], - 'time': float, - Optional('user_defined'): dict, - Optional('attributes'): dict - }, - ], - Optional('communications'): [ - { - 'type': str, - 'to': { - 'type': str, - 'id': int, - Optional('home'): int, - Optional('collection_id'): int, - Optional('migratable'): bool, - Optional('index'): [int], - Optional('objgroup_id'): int, - }, - 'messages': int, - 'from': { - 'type': str, - 'id': int, - Optional('home'): int, - Optional('collection_id'): int, - Optional('migratable'): bool, - Optional('index'): [int], - Optional('objgroup_id'): int, - }, - 'bytes': float - } - ], - Optional('user_defined'): dict - }, - ] - } - ) + valid_schema_data = LBDatafile_schema.LBDatafile_schema allowed_types_stats = ("LBStatsfile") valid_schema_stats = Schema( { diff --git a/scripts/LBDatafile_schema.py b/scripts/LBDatafile_schema.py new file mode 100644 index 0000000000..fadb471b32 --- /dev/null +++ b/scripts/LBDatafile_schema.py @@ -0,0 +1,84 @@ +from schema import And, Optional, Schema + +LBDatafile_schema = Schema( + { + Optional('type'): And(str, "LBDatafile", error="'LBDatafile' must be chosen."), + Optional('metadata'): { + Optional('type'): And(str, "LBDatafile", error="'LBDatafile' must be chosen."), + Optional('rank'): int, + Optional('shared_node'): { + 'id': int, + 'size': int, + 'rank': int, + 'num_nodes': int, + }, + Optional('phases'): { + Optional('count'): int, + 'skipped': { + 'list': [int], + 'range': [[int]], + }, + 'identical_to_previous': { + 'list': [int], + 'range': [[int]], + }, + }, + Optional('attributes'): dict + }, + 'phases': [ + { + 'id': int, + 'tasks': [ + { + 'entity': { + Optional('collection_id'): int, + 'home': int, + 'id': int, + Optional('index'): [int], + 'type': str, + 'migratable': bool, + Optional('objgroup_id'): int + }, + 'node': int, + 'resource': str, + Optional('subphases'): [ + { + 'id': int, + 'time': float, + } + ], + 'time': float, + Optional('user_defined'): dict, + Optional('attributes'): dict + }, + ], + Optional('communications'): [ + { + 'type': str, + 'to': { + 'type': str, + 'id': int, + Optional('home'): int, + Optional('collection_id'): int, + Optional('migratable'): bool, + Optional('index'): [int], + Optional('objgroup_id'): int, + }, + 'messages': int, + 'from': { + 'type': str, + 'id': int, + Optional('home'): int, + Optional('collection_id'): int, + Optional('migratable'): bool, + Optional('index'): [int], + Optional('objgroup_id'): int, + }, + 'bytes': float + } + ], + Optional('user_defined'): dict + }, + ] + } +) \ No newline at end of file