feat(aggregation): materialize topic and peer group list edges in LinkedEdgeGenerator - #727
feat(aggregation): materialize topic and peer group list edges in LinkedEdgeGenerator#727clincoln8 wants to merge 10 commits into
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 1 high |
| Complexity | 1 medium |
🟢 Metrics 22 complexity
Metric Results Complexity 22
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request adds support for materializing topic list edges (relevantVariableList and memberList) during linked edge generation, controlled by a new generate_topic_list_edges configuration flag. Feedback focuses on maintaining the intended 'opt-in safety' design where this feature is disabled by default; the reviewer recommends changing the fallback defaults in several getattr calls from True to False across linked_edge_generator.py, orchestrator.py, and main.py to prevent the feature from being unexpectedly enabled.
…d default fallback to False
…ist edges by default
…for Base DC opt-in safety
…m container builds
069650f to
210a6b2
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the capability to materialize relevantVariableList on Topics and memberList on SVPGs via a new generate_topic_list_edges configuration option, alongside corresponding updates to the orchestrator, CLI, and tests. It also simplifies the deletion logic in deleter.py by removing the thread pool in favor of sequential execution. Feedback on the changes highlights two critical issues: first, a bug in delete_linked_edges where unconditionally deleting generated/TopicLists leads to accidental global data loss of topic list edges across unrelated imports; second, a performance bottleneck in run_topic_list_edges due to an unfiltered global query on the Edge table instead of scoping the query by import_names.
…ecution in orchestrator
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new global calculation step to materialize relevantVariableList on Topics and memberList on StatVarPeerGroups (SVPGs). It updates the orchestrator, deleter, and linked edge generator to support generating and deleting these topic list edges, and exposes this feature via a new --generate_topic_list_edges CLI flag. Additionally, deletions in deleter.py are simplified to run sequentially. Feedback on the changes points out that the import_names parameter in run_topic_list_edges is unused and should be removed to clean up the method signature.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to generate and materialize consolidated topic lists (relevantVariableList and memberList edges) as a global calculation step, including configuration options, orchestrator integration, and corresponding deletion logic in Spanner. It also refactors AggregationDeleter to run deletions sequentially rather than in parallel. The review feedback suggests expanding the fallback namespace checks for topics and peer groups to support direct prefixes like topic/% and svpg/% for custom Data Commons installations.
…rn matching to schema-driven typeOf and predicate domain
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for materializing consolidated topic list edges (relevantVariableList and memberList) as a global calculation step. It updates the LinkedEdgeGenerator to aggregate and export these list edges to Spanner, adds corresponding deletion logic in AggregationDeleter (while also refactoring the deletion process to run sequentially), and exposes this feature via orchestrator configuration and CLI arguments. The feedback recommends ensuring that the generate_topic_list_edges setting is checked within individual calculation steps in addition to the global orchestrator configuration, preventing configuration settings in YAML files from being silently ignored during both generation and deletion phases.
…eps for generate_topic_list_edges
Summary
In Data Commons, MCF ingestion writes 1-to-1 scalar triples (
relevantVariablefor Topics,memberfor SVPGs). However, downstream consumers (Mixer'sTopicCacheManagerand Explore's/api/explore/detect-and-fulfill) require consolidated list predicates (relevantVariableListandmemberList) to expand topic hierarchies efficiently without scanning thousands of individual rows.Changes
LinkedEdgeGenerator:run_topic_list_edges()which queries rawrelevantVariableandmemberarcs in BigQuery, resolves types via schema-driventypeOf IN ('Topic', 'StatVarPeerGroup')and predicate domain (relevantVariable), and executesSTRING_AGG(DISTINCT object_id, ',' ORDER BY object_id).CONCAT(SUBSTR(val, 1, 16), ':', sha256)) and exports raw CSV payloads to Spanner'sNodetable (Node.value) and relationship links toEdge(Edge.object_id = node_hash), preventing SpannerSTRING(1024)column overflows.generated/TopicLists(ordc/base/generated/TopicLists).run_linked_member()andrun_topic_list_edges()from fragile ID substring pattern matching (LIKE '%/topic/%') to schema-driven type resolution (typeOf = 'Topic'and predicate domainrelevantVariable), natively supporting arbitrary custom taxonomy DCIDs (e.g. UN, WHO, SDG).AggregationOrchestrator:run_topic_list_edges()once globally on the orchestrator thread during postprocessing (in_run_global_calculations()), avoiding thread-pool race conditions and Spanner write-lock contention.generate_topic_list_edgesCLI argument toOrchestratorConfig.AggregationDeleter:delete_topic_list_edges()method to deletegenerated/TopicListsonly when topic list edge regeneration is active.delete_linked_edges()to strictly per-import deletion (generated/{import_name}) to prevent accidental cross-import data loss.generate_topic_list_edgesflag (default:Falsefor opt-in safety) acrossLinkedEdgeConfig,OrchestratorConfig, andmain.pyCLI (--generate_topic_list_edges).aggregation_test.py,orchestrator_test.py, anddeleter_test.py(all 68 unit tests passing).Testing
uv run pytestacrosspipeline/workflow/aggregation-helper(all 68 passed).calinc-dev.