update gen script
This commit is contained in:
30
build.py
30
build.py
@@ -26,7 +26,6 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -219,6 +218,8 @@ def build_link(output_dir: Path, cfg_name: str):
|
|||||||
|
|
||||||
def generate_models(output_dir: Path, room: str):
|
def generate_models(output_dir: Path, room: str):
|
||||||
"""Generate models using modelgen tool."""
|
"""Generate models using modelgen tool."""
|
||||||
|
from soleprint.station.tools.modelgen import ModelGenerator, load_config
|
||||||
|
|
||||||
config_path = SPR_ROOT / "cfg" / room / "config.json"
|
config_path = SPR_ROOT / "cfg" / room / "config.json"
|
||||||
|
|
||||||
if not config_path.exists():
|
if not config_path.exists():
|
||||||
@@ -228,21 +229,18 @@ def generate_models(output_dir: Path, room: str):
|
|||||||
models_file = output_dir / "models" / "pydantic" / "__init__.py"
|
models_file = output_dir / "models" / "pydantic" / "__init__.py"
|
||||||
models_file.parent.mkdir(parents=True, exist_ok=True)
|
models_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
cmd = [
|
try:
|
||||||
sys.executable,
|
config = load_config(config_path)
|
||||||
"-m",
|
generator = ModelGenerator(
|
||||||
"soleprint.station.tools.modelgen",
|
config=config,
|
||||||
"from-config",
|
output_path=models_file,
|
||||||
"--config",
|
output_format="pydantic",
|
||||||
str(config_path),
|
)
|
||||||
"--output",
|
generator.generate()
|
||||||
str(models_file),
|
return True
|
||||||
"--format",
|
except Exception as e:
|
||||||
"pydantic",
|
log.error(f"Model generation failed: {e}")
|
||||||
]
|
return False
|
||||||
|
|
||||||
result = subprocess.run(cmd, cwd=SPR_ROOT)
|
|
||||||
return result.returncode == 0
|
|
||||||
|
|
||||||
|
|
||||||
def copy_cfg(output_dir: Path, room: str):
|
def copy_cfg(output_dir: Path, room: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user