generated from coulomb/repo-seed
Add small SaaS profile proof
This commit is contained in:
@@ -6,9 +6,8 @@ from pathlib import Path
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
|
||||
from . import generation
|
||||
from . import profiles
|
||||
from .bench import (
|
||||
Infospace,
|
||||
KnowledgeArtifact,
|
||||
@@ -230,15 +229,53 @@ def profile_inspect(
|
||||
f"Profile not found: {profile}",
|
||||
{"profile": profile, "path": str(profile_path)},
|
||||
)
|
||||
with profile_path.open("r", encoding="utf-8") as handle:
|
||||
data = yaml.safe_load(handle) or {}
|
||||
if not isinstance(data, dict):
|
||||
try:
|
||||
return profiles.inspect_profile(context, profile)
|
||||
except ValueError as exc:
|
||||
raise CanonServiceError(
|
||||
"invalid_profile",
|
||||
f"Profile must be a YAML mapping: {profile}",
|
||||
{"profile": profile, "path": str(profile_path)},
|
||||
) from exc
|
||||
|
||||
|
||||
def profile_validate(
|
||||
profile: str,
|
||||
root: Path | str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
context = load_context(root)
|
||||
profile_path = context.infospace_root / "profiles" / profile / "profile.yaml"
|
||||
if not profile_path.is_file():
|
||||
raise CanonServiceError(
|
||||
"missing_profile",
|
||||
f"Profile not found: {profile}",
|
||||
{"profile": profile, "path": str(profile_path)},
|
||||
)
|
||||
return {"ok": True, "profile": data, "path": str(profile_path)}
|
||||
return profiles.validate_profile(context, profile)
|
||||
|
||||
|
||||
def profile_graph(
|
||||
profile: str,
|
||||
root: Path | str | None = None,
|
||||
*,
|
||||
output_format: str = "json",
|
||||
) -> dict[str, Any]:
|
||||
context = load_context(root)
|
||||
profile_path = context.infospace_root / "profiles" / profile / "profile.yaml"
|
||||
if not profile_path.is_file():
|
||||
raise CanonServiceError(
|
||||
"missing_profile",
|
||||
f"Profile not found: {profile}",
|
||||
{"profile": profile, "path": str(profile_path)},
|
||||
)
|
||||
try:
|
||||
return profiles.profile_graph(context, profile, output_format=output_format)
|
||||
except ValueError as exc:
|
||||
raise CanonServiceError(
|
||||
"unsupported_graph_format",
|
||||
str(exc),
|
||||
{"supported": ["json", "mermaid"]},
|
||||
) from exc
|
||||
|
||||
|
||||
def generate_indexes(root: Path | str | None = None) -> dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user