"""Script to test SDF object model against official examples.

This script should be run regularly (ideally after each SDF version update) to catch cases where our
SDF implementation in sdf_schema.py does not align with the documentation or examples. Before
running, ensure each example validates against the program validator because examples can become
unmaintained or are simply slow to be updated.

kairos_pub_dir should be a path to the root of https://github.com/NextCenturyCorporation/kairos-pub.
"""

import argparse
from pathlib import Path

from sdf.sdf_schema import Library


def main() -> None:
    """Validates SDF object model against official examples."""
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("kairos_pub_dir", type=Path, help="Path to kairos-pub repository root.")
    args = p.parse_args()

    if not args.kairos_pub_dir.is_dir():
        raise OSError(f"kairos-pub directory '{args.kairos_pub_dir}' is not a valid directory")

    caci_examples_dir = args.kairos_pub_dir / "data-format" / "examples"

    examples = {
        "TA1": caci_examples_dir / "disease-outbreak-ec-ta1.json",
        "TA2": caci_examples_dir / "legionnaires-ec-ta2.json",
        "Graph G": caci_examples_dir / "task2-graphG.json",
    }

    for example, path in examples.items():
        print(f"Testing {example} example {path}")
        Library.parse_file(path)


if __name__ == "__main__":
    main()

"""Script to test SDF object model against official examples.

This script should be run regularly (ideally after each SDF version update) to catch cases where our
SDF implementation in sdf_schema.py does not align with the documentation or examples. Before
running, ensure each example validates against the program validator because examples can become
unmaintained or are simply slow to be updated.

kairos_pub_dir should be a path to the root of https://github.com/NextCenturyCorporation/kairos-pub.
"""

import argparse
from pathlib import Path

from sdf.sdf_schema import Library


def main() -> None:
    """Validates SDF object model against official examples."""
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("kairos_pub_dir", type=Path, help="Path to kairos-pub repository root.")
    args = p.parse_args()

    if not args.kairos_pub_dir.is_dir():
        raise OSError(f"kairos-pub directory '{args.kairos_pub_dir}' is not a valid directory")

    caci_examples_dir = args.kairos_pub_dir / "data-format" / "examples"

    examples = {
        "TA1": caci_examples_dir / "disease-outbreak-ec-ta1.json",
        "TA2": caci_examples_dir / "legionnaires-ec-ta2.json",
        "Graph G": caci_examples_dir / "task2-graphG.json",
    }

    for example, path in examples.items():
        print(f"Testing {example} example {path}")
        Library.parse_file(path)


if __name__ == "__main__":
    main()

Script to test SDF object model against official examples.  This script should be run regularly (ideally after each SDF version update) to catch cases where our SDF implementation in sdf_schema.py does not align with the documentation or examples. Before running, ensure each example validates against the program validator because examples can become unmaintained or are simply slow to be updated.  kairos_pub_dir should be a path to the root of https://github.com/NextCenturyCorporation/kairos-pub. Validates SDF object model against official examples.