from typing import Tuple
from typing import List
import json


def read_image_ids(filename: str) -> Tuple[List, List]:
    """
    Read a JSON file that holds the image ids used for training and testing.
    Parameters
    ----------
    filename : str
        Path to JSON file describing training and testing indices.

    Returns
    -------
    Tuple[List, List]
        Tuple of two lists with frame indices for training and testing.
    """

    with open(filename, "r") as open_file:
        config = json.load(open_file)

    # assert fields "train" and "test" within JSON file
    assert "train" in config, "Field \'train\' must be given in JSON file root for specifying training IDs."
    assert "test" in config, "Field \'test\' must be given in JSON file root for specifying testing IDs."

    train_ids = config["train"]
    test_ids = config["test"]

    return train_ids, test_ids