generated from coulomb/repo-seed
Improved datamodel and deterministic generation
This commit is contained in:
@@ -161,6 +161,8 @@ class CandidateFeature:
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
confidence_label: str = ""
|
||||
primary_class: str = ""
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -174,6 +176,8 @@ class CandidateCapability:
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
confidence_label: str = ""
|
||||
primary_class: str = "capability"
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
features: list[CandidateFeature] = field(default_factory=list)
|
||||
evidence: list[CandidateEvidence] = field(default_factory=list)
|
||||
|
||||
@@ -187,6 +191,8 @@ class CandidateAbility:
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
confidence_label: str = ""
|
||||
primary_class: str = "ability"
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
capabilities: list[CandidateCapability] = field(default_factory=list)
|
||||
|
||||
|
||||
@@ -228,6 +234,8 @@ class Feature:
|
||||
confidence: float
|
||||
confidence_label: str = ""
|
||||
source_refs: list[SourceReference] = field(default_factory=list)
|
||||
primary_class: str = ""
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -239,6 +247,8 @@ class Capability:
|
||||
outputs: list[str]
|
||||
confidence: float
|
||||
confidence_label: str = ""
|
||||
primary_class: str = "capability"
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
features: list[Feature] = field(default_factory=list)
|
||||
evidence: list[Evidence] = field(default_factory=list)
|
||||
|
||||
@@ -250,6 +260,8 @@ class Ability:
|
||||
description: str
|
||||
confidence: float
|
||||
confidence_label: str = ""
|
||||
primary_class: str = "ability"
|
||||
attributes: list[str] = field(default_factory=list)
|
||||
capabilities: list[Capability] = field(default_factory=list)
|
||||
|
||||
|
||||
|
||||
@@ -369,6 +369,8 @@ class RegistryService:
|
||||
location=feature.location,
|
||||
confidence=feature.confidence,
|
||||
source_refs=feature.source_refs,
|
||||
primary_class=feature.primary_class,
|
||||
attributes=feature.attributes,
|
||||
)
|
||||
for evidence in capability.evidence:
|
||||
if evidence.status != "candidate":
|
||||
@@ -512,6 +514,8 @@ class RegistryService:
|
||||
location=feature.location,
|
||||
confidence=feature.confidence,
|
||||
source_refs=feature.source_refs,
|
||||
primary_class=feature.primary_class,
|
||||
attributes=feature.attributes,
|
||||
)
|
||||
self.store.mark_candidate_feature_status(
|
||||
repository_id,
|
||||
@@ -655,6 +659,8 @@ class RegistryService:
|
||||
inputs=capability.inputs,
|
||||
outputs=capability.outputs,
|
||||
confidence=capability.confidence,
|
||||
primary_class=capability.primary_class,
|
||||
attributes=capability.attributes,
|
||||
)
|
||||
for feature in capability.features:
|
||||
if feature.status != "candidate":
|
||||
@@ -667,6 +673,8 @@ class RegistryService:
|
||||
location=feature.location,
|
||||
confidence=feature.confidence,
|
||||
source_refs=feature.source_refs,
|
||||
primary_class=feature.primary_class,
|
||||
attributes=feature.attributes,
|
||||
)
|
||||
for evidence in capability.evidence:
|
||||
if evidence.status != "candidate":
|
||||
@@ -702,6 +710,8 @@ class RegistryService:
|
||||
name=candidate_ability.name,
|
||||
description=candidate_ability.description,
|
||||
confidence=candidate_ability.confidence,
|
||||
primary_class=candidate_ability.primary_class,
|
||||
attributes=candidate_ability.attributes,
|
||||
)
|
||||
|
||||
def _ensure_approved_capability(
|
||||
@@ -726,6 +736,8 @@ class RegistryService:
|
||||
inputs=candidate_capability.inputs,
|
||||
outputs=candidate_capability.outputs,
|
||||
confidence=candidate_capability.confidence,
|
||||
primary_class=candidate_capability.primary_class,
|
||||
attributes=candidate_capability.attributes,
|
||||
)
|
||||
|
||||
def _candidate_capability_with_parent(
|
||||
@@ -884,6 +896,8 @@ class RegistryService:
|
||||
name: str,
|
||||
description: str,
|
||||
confidence: float,
|
||||
primary_class: str = "ability",
|
||||
attributes: Sequence[str] = (),
|
||||
notes: str = "",
|
||||
) -> CandidateGraph:
|
||||
self.store.update_candidate_ability(
|
||||
@@ -893,6 +907,8 @@ class RegistryService:
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
self.store.create_review_decision(
|
||||
repository_id,
|
||||
@@ -912,6 +928,8 @@ class RegistryService:
|
||||
name: str,
|
||||
description: str,
|
||||
confidence: float,
|
||||
primary_class: str = "capability",
|
||||
attributes: Sequence[str] = (),
|
||||
notes: str = "",
|
||||
) -> CandidateGraph:
|
||||
self.store.update_candidate_capability(
|
||||
@@ -921,6 +939,8 @@ class RegistryService:
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
self.store.create_review_decision(
|
||||
repository_id,
|
||||
@@ -931,6 +951,40 @@ class RegistryService:
|
||||
self.store.update_repository_status(repository_id, "reviewing")
|
||||
return self.store.get_candidate_graph(repository_id, analysis_run_id)
|
||||
|
||||
def edit_candidate_feature(
|
||||
self,
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
candidate_feature_id: int,
|
||||
*,
|
||||
name: str,
|
||||
type: str,
|
||||
location: str,
|
||||
confidence: float,
|
||||
primary_class: str | None = None,
|
||||
attributes: Sequence[str] = (),
|
||||
notes: str = "",
|
||||
) -> CandidateGraph:
|
||||
self.store.update_candidate_feature(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
candidate_feature_id,
|
||||
name=name,
|
||||
type=type,
|
||||
location=location,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
self.store.create_review_decision(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
action="edit_candidate_feature",
|
||||
notes=notes,
|
||||
)
|
||||
self.store.update_repository_status(repository_id, "reviewing")
|
||||
return self.store.get_candidate_graph(repository_id, analysis_run_id)
|
||||
|
||||
def relink_candidate_capability(
|
||||
self,
|
||||
repository_id: int,
|
||||
@@ -1106,6 +1160,8 @@ class RegistryService:
|
||||
name: str,
|
||||
description: str = "",
|
||||
confidence: float = 1.0,
|
||||
primary_class: str = "ability",
|
||||
attributes: Sequence[str] = (),
|
||||
) -> int:
|
||||
self.store.get_repository(repository_id)
|
||||
return self.store.create_ability(
|
||||
@@ -1113,6 +1169,8 @@ class RegistryService:
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
|
||||
def update_ability(
|
||||
@@ -1123,6 +1181,8 @@ class RegistryService:
|
||||
name: str | None = None,
|
||||
description: str | None = None,
|
||||
confidence: float | None = None,
|
||||
primary_class: str | None = None,
|
||||
attributes: Sequence[str] | None = None,
|
||||
) -> RepositoryAbilityMap:
|
||||
self.store.update_ability(
|
||||
repository_id,
|
||||
@@ -1130,6 +1190,8 @@ class RegistryService:
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes) if attributes is not None else None,
|
||||
)
|
||||
return self.store.get_ability_map(repository_id)
|
||||
|
||||
@@ -1151,6 +1213,8 @@ class RegistryService:
|
||||
inputs: Sequence[str] = (),
|
||||
outputs: Sequence[str] = (),
|
||||
confidence: float = 1.0,
|
||||
primary_class: str = "capability",
|
||||
attributes: Sequence[str] = (),
|
||||
) -> int:
|
||||
self.store.ensure_ability(repository_id, ability_id)
|
||||
return self.store.create_capability(
|
||||
@@ -1161,6 +1225,8 @@ class RegistryService:
|
||||
inputs=list(inputs),
|
||||
outputs=list(outputs),
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
|
||||
def update_capability(
|
||||
@@ -1173,6 +1239,8 @@ class RegistryService:
|
||||
inputs: Sequence[str] | None = None,
|
||||
outputs: Sequence[str] | None = None,
|
||||
confidence: float | None = None,
|
||||
primary_class: str | None = None,
|
||||
attributes: Sequence[str] | None = None,
|
||||
) -> RepositoryAbilityMap:
|
||||
self.store.update_capability(
|
||||
repository_id,
|
||||
@@ -1182,6 +1250,8 @@ class RegistryService:
|
||||
inputs=list(inputs) if inputs is not None else None,
|
||||
outputs=list(outputs) if outputs is not None else None,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes) if attributes is not None else None,
|
||||
)
|
||||
return self.store.get_ability_map(repository_id)
|
||||
|
||||
@@ -1202,6 +1272,8 @@ class RegistryService:
|
||||
type: str,
|
||||
location: str = "",
|
||||
confidence: float = 1.0,
|
||||
primary_class: str | None = None,
|
||||
attributes: Sequence[str] = (),
|
||||
) -> int:
|
||||
self.store.ensure_capability(repository_id, capability_id)
|
||||
return self.store.create_feature(
|
||||
@@ -1211,6 +1283,8 @@ class RegistryService:
|
||||
type=type,
|
||||
location=location,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes),
|
||||
)
|
||||
|
||||
def update_feature(
|
||||
@@ -1222,6 +1296,8 @@ class RegistryService:
|
||||
type: str | None = None,
|
||||
location: str | None = None,
|
||||
confidence: float | None = None,
|
||||
primary_class: str | None = None,
|
||||
attributes: Sequence[str] | None = None,
|
||||
) -> RepositoryAbilityMap:
|
||||
self.store.update_feature(
|
||||
repository_id,
|
||||
@@ -1230,6 +1306,8 @@ class RegistryService:
|
||||
type=type,
|
||||
location=location,
|
||||
confidence=confidence,
|
||||
primary_class=primary_class,
|
||||
attributes=list(attributes) if attributes is not None else None,
|
||||
)
|
||||
return self.store.get_ability_map(repository_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user