e2e backend test
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
This commit is contained in:
@@ -64,20 +64,20 @@ async def init_dependencies(app_settings: KGSettings) -> None:
|
||||
shapes_graph = None
|
||||
|
||||
|
||||
async def startup_event() -> None:
|
||||
"""Initialize service dependencies"""
|
||||
await init_dependencies(cast(KGSettings, _settings))
|
||||
|
||||
|
||||
app, _settings = create_app(
|
||||
service_name="svc-kg",
|
||||
title="Tax Agent Knowledge Graph Service",
|
||||
description="Service for managing and validating the Knowledge Graph",
|
||||
settings_class=KGSettings,
|
||||
startup_hooks=[startup_event],
|
||||
)
|
||||
|
||||
|
||||
# Initialize dependencies immediately
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
await init_dependencies(cast(KGSettings, _settings))
|
||||
|
||||
|
||||
tracer = get_tracer("svc-kg")
|
||||
metrics = get_metrics()
|
||||
|
||||
@@ -100,7 +100,7 @@ async def _handle_kg_upsert_ready(topic: str, payload: EventPayload) -> None:
|
||||
data = payload.data
|
||||
nodes = data.get("nodes", [])
|
||||
relationships = data.get("relationships", [])
|
||||
document_id = data.get("document_id")
|
||||
doc_id = data.get("doc_id")
|
||||
tenant_id = data.get("tenant_id")
|
||||
|
||||
if not nodes and not relationships:
|
||||
@@ -108,7 +108,7 @@ async def _handle_kg_upsert_ready(topic: str, payload: EventPayload) -> None:
|
||||
return
|
||||
|
||||
with tracer.start_as_current_span("upsert_kg_data") as span:
|
||||
span.set_attribute("document_id", document_id)
|
||||
span.set_attribute("doc_id", doc_id)
|
||||
span.set_attribute("tenant_id", tenant_id)
|
||||
span.set_attribute("node_count", len(nodes))
|
||||
span.set_attribute("relationship_count", len(relationships))
|
||||
@@ -121,12 +121,12 @@ async def _handle_kg_upsert_ready(topic: str, payload: EventPayload) -> None:
|
||||
if not conforms:
|
||||
logger.error(
|
||||
"SHACL validation failed",
|
||||
document_id=document_id,
|
||||
doc_id=doc_id,
|
||||
validation_report=validation_report,
|
||||
)
|
||||
metrics.counter("kg_validation_errors_total").labels(
|
||||
tenant_id=tenant_id
|
||||
).inc()
|
||||
metrics.counter(
|
||||
"kg_validation_errors_total", labelnames=["tenant_id"]
|
||||
).labels(tenant_id=tenant_id).inc()
|
||||
return
|
||||
|
||||
# 2. Write data to Neo4j
|
||||
@@ -144,31 +144,30 @@ async def _handle_kg_upsert_ready(topic: str, payload: EventPayload) -> None:
|
||||
# 3. Publish kg.upserted event
|
||||
event_payload = EventPayload(
|
||||
data={
|
||||
"document_id": document_id,
|
||||
"doc_id": doc_id,
|
||||
"tenant_id": tenant_id,
|
||||
"taxpayer_id": data.get("taxpayer_id"),
|
||||
"tax_year": data.get("tax_year"),
|
||||
"node_count": len(nodes),
|
||||
"relationship_count": len(relationships),
|
||||
"success": True,
|
||||
},
|
||||
actor=payload.actor,
|
||||
tenant_id=tenant_id,
|
||||
tenant_id=str(tenant_id),
|
||||
trace_id=str(span.get_span_context().trace_id),
|
||||
)
|
||||
await event_bus.publish(EventTopics.KG_UPSERTED, event_payload) # type: ignore
|
||||
|
||||
metrics.counter("kg_upserts_total").labels(tenant_id=tenant_id).inc()
|
||||
logger.info(
|
||||
"KG upsert completed", document_id=document_id, tenant_id=tenant_id
|
||||
)
|
||||
metrics.counter("kg_upserts_total", labelnames=["tenant_id"]).labels(
|
||||
tenant_id=tenant_id
|
||||
).inc()
|
||||
logger.info("KG upsert completed", doc_id=doc_id, tenant_id=tenant_id)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"Failed to upsert KG data", document_id=document_id, error=str(e)
|
||||
)
|
||||
metrics.counter("kg_upsert_errors_total").labels(
|
||||
tenant_id=tenant_id, error_type=type(e).__name__
|
||||
).inc()
|
||||
logger.error("Failed to upsert KG data", doc_id=doc_id, error=str(e))
|
||||
metrics.counter(
|
||||
"kg_upsert_errors_total", labelnames=["tenant_id", "error_type"]
|
||||
).labels(tenant_id=tenant_id, error_type=type(e).__name__).inc()
|
||||
|
||||
|
||||
async def _validate_with_shacl(
|
||||
|
||||
Reference in New Issue
Block a user