Fix project reopen persistence

This commit is contained in:
=
2026-06-10 19:10:59 +08:00
parent 7195dea7cd
commit d577edf348
7 changed files with 262 additions and 53 deletions
+21 -22
View File
@@ -4,12 +4,11 @@
# Developer : Qin Yue @ 2026
# Organization : OptiHK Limited
# -----------------------------------------------------------------------------
import os
import tempfile
from dataclasses import dataclass, field
from typing import Dict, List
import yaml
from typing import List
from layout_files import load_layout_cell_files, write_layout_cells_to_directory
from router_dependency import require_router_stack
@@ -31,16 +30,25 @@ def build_project_gds(
prefer_full_gds: bool = False,
) -> BuildResult:
"""Build a hierarchical project GDS from saved cell YAML files with mxpic_router."""
cells = _load_project_cells(project_dir)
cells, warnings = _load_project_cells(project_dir)
if not cells:
raise ValueError("No saved cell YAML files found for this project")
return _build_with_mxpic_router(
project_dir,
output_path,
pdk_public_root,
technology_manifest_path,
prefer_full_gds,
with tempfile.TemporaryDirectory(prefix="mxpic_gds_project_") as staged_project_dir:
write_layout_cells_to_directory(cells, staged_project_dir)
result = _build_with_mxpic_router(
staged_project_dir,
output_path,
pdk_public_root,
technology_manifest_path,
prefer_full_gds,
)
return BuildResult(
output_path=result.output_path,
engine=result.engine,
cells_built=result.cells_built,
warnings=warnings + result.warnings,
)
@@ -70,15 +78,6 @@ def _build_with_mxpic_router(
)
def _load_project_cells(project_dir: str) -> Dict[str, dict]:
def _load_project_cells(project_dir: str):
"""Load saved cell YAML documents from a project directory."""
cells = {}
for filename in sorted(os.listdir(project_dir)):
if not filename.lower().endswith((".yml", ".yaml")):
continue
path = os.path.join(project_dir, filename)
with open(path, "r", encoding="utf-8") as file:
data = yaml.safe_load(file) or {}
cell_name = str(data.get("name") or os.path.splitext(filename)[0])
cells[cell_name] = data
return cells
return load_layout_cell_files(project_dir)