Skip to content

dizzy.generators.linkml_runner

dizzy.generators.linkml_runner

LinkML runner — shells out to gen-pydantic / gen-sqla / gen-rust / gen-typescript.

run_linkml_pydantic(def_file, output_file)

Run gen-pydantic on def_file and write the result to output_file.

Source code in dizzy/src/dizzy/generators/linkml_runner.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def run_linkml_pydantic(def_file: Path, output_file: Path) -> None:
    """Run gen-pydantic on def_file and write the result to output_file."""
    result = subprocess.run(
        ["gen-pydantic", str(def_file)],
        capture_output=True,
        text=True,
        check=True,
    )
    logger.debug(
        "gen-pydantic completed",
        extra={"command": "gen-pydantic", "input": str(def_file), "output": str(output_file)},
    )
    output_file.parent.mkdir(parents=True, exist_ok=True)
    output_file.write_text(result.stdout)

run_linkml_sqla(def_file, output_file)

Run gen-sqla on def_file and write the result to output_file.

Source code in dizzy/src/dizzy/generators/linkml_runner.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def run_linkml_sqla(def_file: Path, output_file: Path) -> None:
    """Run gen-sqla on def_file and write the result to output_file."""
    result = subprocess.run(
        ["gen-sqla", str(def_file)],
        capture_output=True,
        text=True,
        check=True,
    )
    logger.debug(
        "gen-sqla completed",
        extra={"command": "gen-sqla", "input": str(def_file), "output": str(output_file)},
    )
    output_file.parent.mkdir(parents=True, exist_ok=True)
    output_file.write_text(result.stdout)

run_linkml_rust(def_file, output_file)

Run gen-rust (file mode, serde) on def_file and write the result to output_file.

Source code in dizzy/src/dizzy/generators/linkml_runner.py
41
42
43
44
45
46
47
48
49
50
51
52
53
def run_linkml_rust(def_file: Path, output_file: Path) -> None:
    """Run gen-rust (file mode, serde) on def_file and write the result to output_file."""
    output_file.parent.mkdir(parents=True, exist_ok=True)
    subprocess.run(
        ["gen-rust", "-m", "file", "-s", "--force", "-o", str(output_file), str(def_file)],
        capture_output=True,
        text=True,
        check=True,
    )
    logger.debug(
        "gen-rust completed",
        extra={"command": "gen-rust", "input": str(def_file), "output": str(output_file)},
    )

run_linkml_typescript(def_file, output_file)

Run gen-typescript on def_file and write the result to output_file.

Source code in dizzy/src/dizzy/generators/linkml_runner.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def run_linkml_typescript(def_file: Path, output_file: Path) -> None:
    """Run gen-typescript on def_file and write the result to output_file."""
    result = subprocess.run(
        ["gen-typescript", str(def_file)],
        capture_output=True,
        text=True,
        check=True,
    )
    logger.debug(
        "gen-typescript completed",
        extra={"command": "gen-typescript", "input": str(def_file), "output": str(output_file)},
    )
    output_file.parent.mkdir(parents=True, exist_ok=True)
    output_file.write_text(result.stdout)