Repository navigation
fix(preprocessor): always emit dc/g/Root StatVarGroup in Nodes.__init__ - #796
Merged
clincoln8 merged 3 commits intoOct 19, 2026
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
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.
Contributor
There was a problem hiding this comment.
Code Review
This pull request ensures that the global root StatVarGroup (dc/g/Root) is always created by calling _ensure_root_group() during the initialization of the Nodes class. This guarantees that manually defined StatVarGroup hierarchies in MCF have a root Node in Spanner. The corresponding tests and expected test data files (CSV and JSON-LD) have been updated to reflect the presence of this root group. There are no review comments to address, and the changes look solid.
gmechali
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Ensure the global root
StatVarGroup(dc/g/Root,"Data Commons Variables") is always emitted by the preprocessor into_globaltriples so that manually definedStatVarGrouphierarchies in MCF have a valid rootNoderow in Spanner without requiring database seeding.Key Aspects of the Approach
self._ensure_root_group()inNodes.__init__()(simple/stats/nodes.py).c/g/Root("Custom Variables") gated behindif config.generate_hierarchy(): self.group("")(or explicitnodes.group("")calls) so unused custom root groups are not created for manually definedStatVarGrouphierarchies.Implementation Details
self._ensure_root_group()(introduced in [DCP Init DB] Add the dc/g/Root node in preprocessor, exactly like c/g/Root. Allows us to remove Seeding entirely #780) was only called insideNodes._default_custom_group()andNodes.group(), which are not reached in standarddcpbridgeimports usingvariablePerRowCSVs (VariablePerRowImporter) and manually definedStatVarGroupnodes in MCF (McfImporter) whengroupStatVarsByPropertyis not enabled. As a result,dc/g/Rootwas absent from the SpannerNodetable, causing Mixer'sBulkVariableGroupInfo(FilterNodesByTypes) to rejectdc/g/Rootand return an empty StatVar Explorer hierarchy.test_root_stat_var_group_createdinsimple/tests/stats/nodes_test.pyto verify thatdc/g/Rootis initialized immediately onNodes(CONFIG)construction whilec/g/Rootis not created unless requested.entities_importerandrunnertests to includedc/g/Root.--python 3.12onuv run pytestforingestion-helperinrun_test.shsouvdoes not resolverequires-python = ">=3.12"to CPython 3.15 in Cloud Build and time out building wheels from source.Edge Cases, Errors & Logging
_ensure_root_group()is idempotent (if sc.ROOT_SVG_ID not in self.groups:), so subsequent calls tonodes.group()or_default_custom_group()reuse the existingdc/g/Rootentry without duplication.Testing & E2E Verification
simpletest suite (pytest tests/ kg_util/, 127 passed) and verifiedyapf/isortformatting.