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