feat(projects): automate project infrastructure provisioning
Generic Container CI/CD / test-build-publish (push) Successful in 1m13s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m13s

This commit is contained in:
2026-09-11 10:57:51 +08:00
parent 10a7a66a41
commit 90b02057bc
38 changed files with 2345 additions and 189 deletions
+35
View File
@@ -0,0 +1,35 @@
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from tempfile import NamedTemporaryFile
from app.native.wndb.inp.exporter import dump_inp
PROJECT_INP_DIRECTORY = Path("db_inp")
@contextmanager
def temporary_project_inp(
project_code: str,
*,
purpose: str,
version: str = "2",
) -> Iterator[Path]:
"""Export one project model to an isolated INP and remove it afterwards."""
PROJECT_INP_DIRECTORY.mkdir(parents=True, exist_ok=True)
with NamedTemporaryFile(
dir=PROJECT_INP_DIRECTORY,
prefix=f"{purpose}_",
suffix=".inp",
delete=False,
) as temporary_file:
path = Path(temporary_file.name).resolve()
try:
dump_inp(project_code, str(path), version)
if not path.is_file() or path.stat().st_size == 0:
raise ValueError(f"项目 {project_code!r} 的 INP 导出失败")
yield path
finally:
path.unlink(missing_ok=True)