sc2_datasets.validators.validate_chunk

Functions

validate_chunk(→ list[tuple[pathlib.Path, bool]])

Attempts to parse a chunk of replays and validates the JSON

Module Contents

validate_chunk(list_of_replays: list[pathlib.Path]) list[tuple[pathlib.Path, bool]]

Attempts to parse a chunk of replays and validates the JSON structure using SC2ReplayData parser.

Parameters:

list_of_replays (list[Path]) – Specifies the list of replays that will be validated.

Returns:

Returns a tuple of a filepath and a boolean denoting if the file should be skipped in final processing.

Return type:

list[tuple[Path, bool]]

Examples

Validate chunk is defined as a smallest piece of code that is used to build up validators. This function is especially relevant when working with multiprocessing.

>>> from pathlib import Path
>>> validated_chunk = validate_chunk(
...                         list_of_replays=[
...                               Path("./test/test_files/single_replay/test_replay.json"),
...                               Path("./test/test_files/single_replay/test_bit_flip_example.json"),
...                               ],
...                     )
>>> assert len(validated_chunk) == 2
>>> assert validated_chunk[0][1] is True
>>> assert validated_chunk[1][1] is False