fix: commit semantic repair changes
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator.imports:Block]
|
||||
# [DEF:imports:Block]
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
import hashlib
|
||||
@@ -70,7 +70,7 @@ from src.services.dataset_review.repositories.session_repository import (
|
||||
)
|
||||
from src.services.dataset_review.semantic_resolver import SemanticSourceResolver
|
||||
from src.services.dataset_review.event_logger import SessionEventPayload
|
||||
# [/DEF:DatasetReviewOrchestrator.imports:Block]
|
||||
# [/DEF:imports:Block]
|
||||
|
||||
logger = cast(Any, logger)
|
||||
|
||||
@@ -166,7 +166,7 @@ class LaunchDatasetResult:
|
||||
# @DATA_CONTRACT: Input[StartSessionCommand] -> Output[StartSessionResult]
|
||||
# @INVARIANT: session ownership is preserved on every mutation and recovery remains explicit when partial.
|
||||
class DatasetReviewOrchestrator:
|
||||
# [DEF:DatasetReviewOrchestrator.__init__:Function]
|
||||
# [DEF:DatasetReviewOrchestrator_init:Function]
|
||||
# @COMPLEXITY: 3
|
||||
# @PURPOSE: Bind repository, config, and task dependencies required by the orchestration boundary.
|
||||
# @RELATION: [DEPENDS_ON] ->[SessionRepo]
|
||||
@@ -183,9 +183,9 @@ class DatasetReviewOrchestrator:
|
||||
self.task_manager = task_manager
|
||||
self.semantic_resolver = semantic_resolver or SemanticSourceResolver()
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator.__init__:Function]
|
||||
# [/DEF:DatasetReviewOrchestrator_init:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator.start_session:Function]
|
||||
# [DEF:start_session:Function]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Initialize a new session from a Superset link or dataset selection and trigger context recovery.
|
||||
# @RELATION: [DEPENDS_ON] ->[SessionRepo]
|
||||
@@ -378,9 +378,9 @@ class DatasetReviewOrchestrator:
|
||||
findings=findings,
|
||||
)
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator.start_session:Function]
|
||||
# [/DEF:start_session:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator.prepare_launch_preview:Function]
|
||||
# [DEF:prepare_launch_preview:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Assemble effective execution inputs and trigger Superset-side preview compilation.
|
||||
# @RELATION: [CALLS] ->[SupersetCompilationAdapter.compile_preview]
|
||||
@@ -490,9 +490,9 @@ class DatasetReviewOrchestrator:
|
||||
blocked_reasons=[],
|
||||
)
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator.prepare_launch_preview:Function]
|
||||
# [/DEF:prepare_launch_preview:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator.launch_dataset:Function]
|
||||
# [DEF:launch_dataset:Function]
|
||||
# @COMPLEXITY: 5
|
||||
# @PURPOSE: Start the approved dataset execution through SQL Lab and persist run context for audit/replay.
|
||||
# @RELATION: [CALLS] ->[SupersetCompilationAdapter.create_sql_lab_session]
|
||||
@@ -624,10 +624,10 @@ class DatasetReviewOrchestrator:
|
||||
blocked_reasons=[],
|
||||
)
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator.launch_dataset:Function]
|
||||
# [/DEF:launch_dataset:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._parse_dataset_selection:Function]
|
||||
# @COMPLEXITY: 3
|
||||
# [DEF:_parse_dataset_selection:Function]
|
||||
# @COMPLEXITY: 2
|
||||
# @PURPOSE: Normalize dataset-selection payload into canonical session references.
|
||||
# @RELATION: [DEPENDS_ON] ->[DatasetReviewSession]
|
||||
def _parse_dataset_selection(self, source_input: str) -> tuple[str, Optional[int]]:
|
||||
@@ -647,10 +647,10 @@ class DatasetReviewOrchestrator:
|
||||
|
||||
return normalized, None
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._parse_dataset_selection:Function]
|
||||
# [/DEF:_parse_dataset_selection:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._build_initial_profile:Function]
|
||||
# @COMPLEXITY: 3
|
||||
# [DEF:_build_initial_profile:Function]
|
||||
# @COMPLEXITY: 2
|
||||
# @PURPOSE: Create the first profile snapshot so exports and detail views remain usable immediately after intake.
|
||||
# @RELATION: [DEPENDS_ON] ->[DatasetProfile]
|
||||
def _build_initial_profile(
|
||||
@@ -690,9 +690,9 @@ class DatasetReviewOrchestrator:
|
||||
manual_summary_locked=False,
|
||||
)
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._build_initial_profile:Function]
|
||||
# [/DEF:_build_initial_profile:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._build_partial_recovery_findings:Function]
|
||||
# [DEF:_build_partial_recovery_findings:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Project partial Superset intake recovery into explicit findings without blocking session usability.
|
||||
# @RELATION: [DEPENDS_ON] ->[ValidationFinding]
|
||||
@@ -722,9 +722,9 @@ class DatasetReviewOrchestrator:
|
||||
)
|
||||
return findings
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._build_partial_recovery_findings:Function]
|
||||
# [/DEF:_build_partial_recovery_findings:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._build_recovery_bootstrap:Function]
|
||||
# [DEF:_build_recovery_bootstrap:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Recover and materialize initial imported filters, template variables, and draft execution mappings after session creation.
|
||||
# @RELATION: [CALLS] ->[SupersetContextExtractor.recover_imported_filters]
|
||||
@@ -881,9 +881,24 @@ class DatasetReviewOrchestrator:
|
||||
|
||||
return imported_filters, template_variables, execution_mappings, findings
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._build_recovery_bootstrap:Function]
|
||||
# [/DEF:_build_recovery_bootstrap:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._build_execution_snapshot:Function]
|
||||
# [DEF:_extract_effective_filter_value:Function]
|
||||
# @COMPLEXITY: 2
|
||||
# @PURPOSE: Separate normalized filter payload metadata from the user-facing effective filter value.
|
||||
def _extract_effective_filter_value(
|
||||
self, normalized_value: Any, raw_value: Any
|
||||
) -> Any:
|
||||
if isinstance(normalized_value, dict) and (
|
||||
"filter_clauses" in normalized_value
|
||||
or "extra_form_data" in normalized_value
|
||||
):
|
||||
return raw_value
|
||||
return normalized_value if normalized_value is not None else raw_value
|
||||
|
||||
# [/DEF:_extract_effective_filter_value:Function]
|
||||
|
||||
# [DEF:_build_execution_snapshot:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Build effective filters, template params, approvals, and fingerprint for preview and launch gating.
|
||||
# @RELATION: [DEPENDS_ON] ->[DatasetReviewSession]
|
||||
@@ -923,9 +938,10 @@ class DatasetReviewOrchestrator:
|
||||
|
||||
effective_value = mapping.effective_value
|
||||
if effective_value is None:
|
||||
effective_value = imported_filter.normalized_value
|
||||
if effective_value is None:
|
||||
effective_value = imported_filter.raw_value
|
||||
effective_value = self._extract_effective_filter_value(
|
||||
imported_filter.normalized_value,
|
||||
imported_filter.raw_value,
|
||||
)
|
||||
if effective_value is None:
|
||||
effective_value = template_variable.default_value
|
||||
|
||||
@@ -937,19 +953,21 @@ class DatasetReviewOrchestrator:
|
||||
|
||||
mapped_filter_ids.add(imported_filter.filter_id)
|
||||
if effective_value is not None:
|
||||
effective_filters.append(
|
||||
{
|
||||
"mapping_id": mapping.mapping_id,
|
||||
"filter_id": imported_filter.filter_id,
|
||||
"filter_name": imported_filter.filter_name,
|
||||
"display_name": imported_filter.display_name,
|
||||
"variable_id": template_variable.variable_id,
|
||||
"variable_name": template_variable.variable_name,
|
||||
"effective_value": effective_value,
|
||||
"raw_input_value": mapping.raw_input_value,
|
||||
"normalized_filter_payload": imported_filter.normalized_value,
|
||||
}
|
||||
)
|
||||
mapped_filter_payload = {
|
||||
"mapping_id": mapping.mapping_id,
|
||||
"filter_id": imported_filter.filter_id,
|
||||
"filter_name": imported_filter.filter_name,
|
||||
"variable_id": template_variable.variable_id,
|
||||
"variable_name": template_variable.variable_name,
|
||||
"effective_value": effective_value,
|
||||
"raw_input_value": mapping.raw_input_value,
|
||||
}
|
||||
if isinstance(imported_filter.normalized_value, dict):
|
||||
mapped_filter_payload["display_name"] = imported_filter.display_name
|
||||
mapped_filter_payload["normalized_filter_payload"] = (
|
||||
imported_filter.normalized_value
|
||||
)
|
||||
effective_filters.append(mapped_filter_payload)
|
||||
template_params[template_variable.variable_name] = effective_value
|
||||
if mapping.approval_state == ApprovalState.APPROVED:
|
||||
approved_mapping_ids.append(mapping.mapping_id)
|
||||
@@ -963,8 +981,10 @@ class DatasetReviewOrchestrator:
|
||||
if imported_filter.filter_id in mapped_filter_ids:
|
||||
continue
|
||||
effective_value = imported_filter.normalized_value
|
||||
if effective_value is None:
|
||||
effective_value = imported_filter.raw_value
|
||||
effective_value = self._extract_effective_filter_value(
|
||||
imported_filter.normalized_value,
|
||||
imported_filter.raw_value,
|
||||
)
|
||||
if effective_value is None:
|
||||
continue
|
||||
effective_filters.append(
|
||||
@@ -1014,9 +1034,9 @@ class DatasetReviewOrchestrator:
|
||||
"preview_fingerprint": preview_fingerprint,
|
||||
}
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._build_execution_snapshot:Function]
|
||||
# [/DEF:_build_execution_snapshot:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._build_launch_blockers:Function]
|
||||
# [DEF:_build_launch_blockers:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Enforce launch gates from findings, approvals, and current preview truth.
|
||||
# @RELATION: [DEPENDS_ON] ->[CompiledPreview]
|
||||
@@ -1057,9 +1077,9 @@ class DatasetReviewOrchestrator:
|
||||
|
||||
return sorted(set(blockers))
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._build_launch_blockers:Function]
|
||||
# [/DEF:_build_launch_blockers:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._get_latest_preview:Function]
|
||||
# [DEF:_get_latest_preview:Function]
|
||||
# @COMPLEXITY: 2
|
||||
# @PURPOSE: Resolve the current latest preview snapshot for one session aggregate.
|
||||
def _get_latest_preview(
|
||||
@@ -1078,18 +1098,18 @@ class DatasetReviewOrchestrator:
|
||||
reverse=True,
|
||||
)[0]
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._get_latest_preview:Function]
|
||||
# [/DEF:_get_latest_preview:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._compute_preview_fingerprint:Function]
|
||||
# [DEF:_compute_preview_fingerprint:Function]
|
||||
# @COMPLEXITY: 2
|
||||
# @PURPOSE: Produce deterministic execution fingerprint for preview truth and staleness checks.
|
||||
def _compute_preview_fingerprint(self, payload: Dict[str, Any]) -> str:
|
||||
serialized = json.dumps(payload, sort_keys=True, default=str)
|
||||
return hashlib.sha256(serialized.encode("utf-8")).hexdigest()
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._compute_preview_fingerprint:Function]
|
||||
# [/DEF:_compute_preview_fingerprint:Function]
|
||||
|
||||
# [DEF:DatasetReviewOrchestrator._enqueue_recovery_task:Function]
|
||||
# [DEF:_enqueue_recovery_task:Function]
|
||||
# @COMPLEXITY: 4
|
||||
# @PURPOSE: Link session start to observable async recovery when task infrastructure is available.
|
||||
# @RELATION: [CALLS] ->[create_task]
|
||||
@@ -1147,7 +1167,7 @@ class DatasetReviewOrchestrator:
|
||||
task_id = getattr(task_object, "id", None)
|
||||
return str(task_id) if task_id else None
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator._enqueue_recovery_task:Function]
|
||||
# [/DEF:_enqueue_recovery_task:Function]
|
||||
|
||||
|
||||
# [/DEF:DatasetReviewOrchestrator:Class]
|
||||
|
||||
Reference in New Issue
Block a user