Skip to content

_cli_tools

check_manifest(*, raw_package_name, manifest, ignore_keys_order)

Write manifest to file.

PARAMETER DESCRIPTION
raw_package_name

TYPE: str

manifest

The manifest object

TYPE: str

ignore_keys_order

Whether to ignore keys order.

TYPE: bool

Source code in src/fractal_task_tools/_cli_tools.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def check_manifest(
    *,
    raw_package_name: str,
    manifest: str,
    ignore_keys_order: bool,
) -> None:
    """
    Write manifest to file.

    Arguments:
        raw_package_name:
        manifest: The manifest object
        ignore_keys_order: Whether to ignore keys order.
    """

    package_name = normalize_package_name(raw_package_name)
    logging.info(f"[check_manifest] {package_name=}")

    imported_package = import_module(package_name)
    package_root_dir = Path(imported_package.__file__).parent
    manifest_path = (package_root_dir / MANIFEST_FILENAME).as_posix()
    logging.info(f"[check_manifest] {os.getcwd()=}")
    logging.info(f"[check_manifest] {package_root_dir=}")
    logging.info(f"[check_manifest] {manifest_path=}")

    with open(manifest_path, "r") as f:
        old_manifest = json.load(f)
    if manifest == old_manifest:
        logging.info("[check_manifest] On-disk manifest is up to date.")
    else:
        logging.error("[check_manifest] On-disk manifest is not up to date.")
        try:
            deepdiff(
                old_object=old_manifest,
                new_object=manifest,
                path="manifest",
                ignore_keys_order=ignore_keys_order,
            )
        except ValueError as e:
            logging.error(str(e))
            sys.exit("New/old manifests differ")

    logging.info("[check_manifest] END")

write_manifest_to_file(*, raw_package_name, manifest)

Write manifest to file.

PARAMETER DESCRIPTION
raw_package_name

TYPE: str

manifest

The manifest object

TYPE: str

Source code in src/fractal_task_tools/_cli_tools.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def write_manifest_to_file(
    *,
    raw_package_name: str,
    manifest: str,
) -> None:
    """
    Write manifest to file.

    Arguments:
        raw_package_name:
        manifest: The manifest object
    """
    logging.info("[write_manifest_to_file] START")

    package_name = normalize_package_name(raw_package_name)
    logging.info(f"[write_manifest_to_file] {package_name=}")

    imported_package = import_module(package_name)
    package_root_dir = Path(imported_package.__file__).parent
    manifest_path = (package_root_dir / MANIFEST_FILENAME).as_posix()
    logging.info(f"[write_manifest_to_file] {os.getcwd()=}")
    logging.info(f"[write_manifest_to_file] {package_root_dir=}")
    logging.info(f"[write_manifest_to_file] {manifest_path=}")

    with open(manifest_path, "w") as f:
        json.dump(manifest, f, indent=2)
        f.write("\n")

    logging.info("[write_manifest_to_file] END")