Python packages / DCP tools
Changelog
v1.0.1 (2026-10-13)
- Fixed a fresh install failing to import
dcp_tools.gcp_utilities, which broke thedcp-toolsCLI andrun_ingestion_workflow.datacommons-admin1.1.3 movedIngestionJobClientto a new module, and 1.1.6 removed thejob_nameargument dcp-tools passes. The dependency is now capped atdatacommons-admin<1.1.3until dcp-tools supports the new client.
v1.0.0 (2026-10-13)
First stable release under the name dcp-tools. The API is unchanged since v1.0.0a5, and from this release on, breaking changes wait for a new major version. To upgrade from bblocks-datacommons-tools 0.1.1, follow the migration notes in the v1.0.0a1 to v1.0.0a5 entries below, which describe each change in detail.
- Breaking: renamed the package from
bblocks-datacommons-toolstodcp-tools, the import path todcp_toolsand the CLI todcp-tools. The old distribution installsdcp-toolsand re-exports it with aDeprecationWarning. - Breaking: ingestion runs on the Data Commons Platform.
run_data_loadis nowrun_ingestion_workflow, the ingestion settings are renamed, and the Cloud SQL and redeploy settings and commands are removed. - Breaking: the Python API is snake_case throughout, the node models drop their
MCFprefix, andadd_sourceandadd_provenancetake separatedcidandnameparameters. - Breaking:
export_allwrites the complete bundle and empties the target directory first. - Breaking: the variable-per-column (implicit schema) input format and the
redeploycommand are removed. - Added
add_node,add_mcf_file, Source and Provenance nodes with licence, refresh and coverage metadata, multi-entity observations throughcustom:<name>dimensions, andconstraint_propertieson StatVars. - Minimum supported Python is 3.13.
v1.0.0a5 (2026-09-10)
- Breaking:
license_typeandcuratorare now DCID references, written aslicenseType: dcid:<token>instead of a quoted string. Bare tokens passed toadd_source/add_provenanceare minted;SourceNode/ProvenanceNodestill require thedcid:prefix. - Breaking: renamed the ingestion settings to match the DCP Terraform outputs:
LOAD_JOB_NAME->INGESTION_PREP_JOB_NAME,LOAD_JOB_REGION->GCP_REGION, andLOAD_JOB_SERVICE_ACCOUNT->INGESTION_SERVICE_ACCOUNT. The old names are no longer accepted. - Breaking: renamed
run_data_loadtorun_ingestion_workflow, and thedataloadCLI command toingest.importsis now keyword-only, sorun_data_load(settings, "climateFinance")becomesrun_ingestion_workflow(settings, imports="climateFinance"). - Breaking:
export_allnow empties the target directory before writing. - Added
license_typeandlicense_attributiontoadd_source, andsource_data_urlandlicense_attributiontoadd_provenance.
v1.0.0a4 (2026-09-07)
add_provenancenow warns instead of raising whensourceisn't registered in the bundle, so aProvenancecan reference aSourcethat already exists in base Data Commons.
v1.0.0a3 (2026-08-19)
- Added
add_node(dcid=..., name=..., type_of=...)toCustomDataManager, for MCF nodes with a caller-suppliedtypeOfe.g. entity instances (e.g. an organisation) or constraint-value classes (e.g.Commitment) the typed builders don't cover. gcs_input_folder_path(GCS_INPUT_FOLDER_PATH) is now optional and defaults toingestion/input, the DCP Terraform default.- Fixed
KGSettingsrejecting its snake_case field names;KGSettings(local_path=...)now works alongsideKGSettings(LOCAL_PATH=...).
v1.0.0a2 (2026-08-10)
- Breaking:
ProvenanceNode.source_linkis renamed tosource, so a provenance's parent source now serializes assource: dcid:source/<name>(wassourceLink:), the property name Data Commons ingestion preprocessing expects. - Added
add_mcf_file(file_name, provenance=...)to declare an MCF file inconfig.json'sinputFiles.add_mcf_file("*.mcf", provenance=...)covers them all in a single-provenance import; declare each file separately when an import has more than one provenance. - Added
constraint_propertiestoStatVarNodeand as a parameter onadd_variable_to_mcf, for the DCID(s) of properties that constrain the StatisticalVariable. Bare tokens are minted todcid:<token>. - Breaking:
datacommons-adminwas bumped to>=1.1.1and now required aingestion_workflow_name(INGESTION_WORKFLOW_NAME) setting. - Fixed
run_data_loadand thedataload/pipelinecommands not loading every import when none are named.
v1.0.0a1 (2026-07-27)
- First alpha of the
dcp-toolspackage, the first release under the new name. - Renamed the package from
bblocks-datacommons-toolstodcp-tools. The import path is nowdcp_tools(wasbblocks.datacommons_tools). Installing the oldbblocks-datacommons-toolsdistribution now pulls indcp-toolsand re-exports it with aDeprecationWarning; update imports todcp_toolsat your convenience. - Minimum supported Python is now 3.13 (was 3.11).
- Packaging now follows the
bblocks-projectscopier template (ruff lint preset,tytype checking, pre-commit hooks, PyPI trusted publishing). - Breaking: removed support for the second, implicit import mechanism —
add_implicit_schema_file,add_variable_to_config, and theImplicitSchemaFile/Variablemodel classes are gone.ObservationPropertiesis retained but repurposed: it's no longer nested under a variable definition, and now carries the file-level constant observation properties onInputFile; it also accepts custom keys (extra="allow", wasextra="forbid"), and the four standard fields are unchanged. Loading a legacyvariablePerColumnconfig now raisesValueError. Migrate by usingadd_input_filewithcolumn_mappings; see Data Commons custom data docs. - Breaking: with a single import format left, the input-file API drops the "explicit"
qualifier:
ExplicitSchemaFileis nowInputFileandadd_explicit_schema_fileis nowadd_input_file. The arguments are the same ones (in the snake_case spelling below) and the generatedconfig.jsonis unchanged. - Breaking:
Config.input_filesis nowlist[InputFile](was a dict keyed by file name).InputFilealso rejects unknown keys now (extra="forbid"). - Breaking:
export_mfc_fileis now spelledexport_mcf_file, andcsv_metadata_to_mfc_fileis nowcsv_metadata_to_mcf_file. - Breaking: removed the
entitykey onColumnMappings. UseobservationAboutfor single-entity data orcustom:<name>for multi-entity dimensions. - Added support for multi-entity observations using custom dimensions: declare each
dimension with
custom:<name>inColumnMappingsand a matchingdcid:<name>in the StatVar'sobservation_properties. - Single-entity StatVars no longer emit
observationPropertiesby default. - Fixed
rename_variable, which left theNodeslookup index keyed by the old name, so a following variable removal raised "not found" for the renamed node and still resolved the old name. The rename now goes through a newNodes.rename, which keeps the index in step. - Fixed
export_data,export_mcf_file, andexport_vertical_specsraisingOSErrorwhen the target file name nested in a subdirectory that did not yet exist (for example anadd_input_filename such as"sub/gdp.csv"). Each now creates the parent directory before writing. - Fixed
add_variable_to_mcf, which did not normalize a baredcidtodcid:<token>like the schema-node builders do, so a bare token raised aValidationErrorthere while working everywhere else. Itspopulation_type,measured_property,measurement_qualifierandmeasurement_denominatorarguments had the same gap and now accept bare tokens too. - Fixed
DcidOrListDcid, which used aPlainValidatorthat replaced the wrappedDcidschema rather than running before it, so thedcid:prefix check never ran. Any string, prefixed or not, passed through and landed in the MCF verbatim. This affectedtype_ofon every node,relevant_variable,observation_propertiesandmemberon StatVar nodes, andincluded_in,sub_class_of,domain_includes,range_includesandsub_property_ofon the schema-node builders. These fields now normalize a bare token todcid:<token>and reject anything empty or whitespace-bearing, and a non-string value now raises rather than being accepted silently. Breaking for anyone passing a bare token to one of these fields today and relying on it staying bare. - Breaking:
member_ofon a StatVar now has to be a real group dcid. It had the same bypass, so any string reached the MCF verbatim; it now requires ag/segment, soone/g/economyis minted todcid:one/g/economyanddcid:economyis rejected. Check the values you pass toadd_variable_to_mcfand thememberOfcolumn of your StatVar CSVs. - Breaking:
relevant_variableon a Topic node is now plainDcidOrListDcid. Its type used to combine the fixed variant with two unfixed ones, so a value the fixed one rejected still got through the others. It accepts the same StatVar, group and topic dcids as before, and now rejects the malformed values that used to slip past. - Breaking: nodes now validate on assignment, not only on construction. Setting a
field to an invalid value, for example
node.member_of = "garbage"or renaming a node to a token with nodcid:prefix, raises instead of quietly writing it to the MCF file. - Breaking:
build_stat_var_groups_from_stringsis replaced byresolve_group_paths. It usedmember_ofto hold an unresolved group path such as"Economic/Employment"until it was overwritten, which is what blocked validating the field. Group paths are now resolved before the nodes are built. If you call it directly, usecsv_metadata_to_nodes(..., parse_groups=True, group_namespace=...)instead.add_variables_to_mcf_from_csvis unchanged. - Fixed
add_variables_to_mcf_from_csv(parse_groups=True)raisingAttributeErrorwhen the CSV had nomemberOfcolumn or a row left it blank. The missing column now raises a clearValueError, and a blank value leaves that node'smember_ofunset. A group path holding a whitespace-only segment, such as a stray tab between two slashes, also used to mint a group with an empty name; those segments are now dropped. - Breaking: a Topic node's
dcidnow has to carry thedcid:prefix. The old check looked for atopic/segment anywhere in the string and never required the prefix, sotopic/xvalidated and was written to the MCF unprefixed. Adddcid:to theNodecolumn of any topic CSV. Data Commons rejects unprefixed node ids on load, so those files were not loading correctly to begin with. - Breaking: re-pointed the data load flow at the DCP prep job, using the
IngestionJobClient.run_data_loadnow triggers the prep job. TheredeployCLI command and theredeploy_serviceandredeploy_cloud_run_servicefunctions are removed; the service restart is now owned by the ingestion workflow. Load-job settings are renamed:CLOUD_RUN_JOB_NAME→LOAD_JOB_NAME,CLOUD_JOB_REGION→LOAD_JOB_REGION, plus a new optionalLOAD_JOB_SERVICE_ACCOUNTthat sets which service account the load job impersonates (when unset, the caller's credentials are used). The unused Cloud SQL and Cloud Run service settings are removed too:CLOUD_SQL_DB_NAME,CLOUD_SQL_REGION,CLOUD_SERVICE_REGION,CLOUD_RUN_SERVICE_NAME, andDATACOMMONS_SERVICE_IMAGE. - Added an
importsargument onrun_data_loadand a matching--importsflag on thedataloadCLI command, to trigger a load of specific imports rather than all imports. - Breaking: renamed the node model classes to drop the
MCFqualifier —MCFNode→Node,MCFNodes→Nodes, and every subclass. MCF is now treated as one serialization of a Data Commons graph node. - Breaking: a node's identifier is now a single
dcidproperty — the duplicateNode/dcidpair is collapsed. Access it vianode.dcid; it still serializes to theNode:line in MCF. - Breaking:
Node.mcfis now theNode.to_mcf()method. - Breaking: the Python API is snake_case throughout — node/
Configattributes, builder keyword arguments and theset_*methods. Serialisation still uses camelCase using pydantic'salias_generator=to_camel. - Breaking:
export_allwrites and overwrites the complete bundle, and no longer takesmcf_file_namesoroverride. It writesconfig.json, the data CSVs,vertical_specs.json(when specs were added), and every MCF file you've added nodes to, overwriting what's already there. Pass nothing for the full bundle; useexport_mcf_filefor a single file. - Breaking:
overrideis renamed tooverwriteonexport_mcf_file,Nodes.export_to_mcf_fileandcsv_metadata_to_mcf_file, and now defaults to overwriting. - Breaking:
csv2mcfreplaces--overridewith--append. It overwrites the output file by default; pass--appendto add to an existing file instead. - Breaking:
add_sourceandadd_provenancetake separatedcid(identifier, minted with the slug prefix), optionalname(label), anddescriptionparameters. Previouslynamewas the identifier and nonameproperty was set — pass the identifier asdcid=now. - Breaking:
CustomDataManager.remove_indicatoris renamed toremove_variable(parameterindicator_id→dcid), matching thevariableterminology used elsewhere.
v0.1.1 (2026-02-19)
- Added a
--syncflag to theuploadandpipelineCLI commands, which deletes remote blobs that no longer have a local counterpart after uploading. - Added
sync_directory_to_gcsinstorage.py, which composes upload and stale blob cleanup. - Added a
syncparameter onupload_to_cloud_storage.
v0.1.0 (2026-02-13)
- Initial release of the
dcp-toolspackage for external preview and testing
v0.0.9 (2025-09-17)
- Added new configuration options, including
set_customIdNamespace,set_customSvgPrefix,set_defaultCustomRootStatVarGroupNameandset_svHierarchyPropsBlocklist.
v0.0.8 (2025-09-03)
- Removed white space between quoted items to defend against a bug with data loading on the DC side.
v0.0.7 (2025-08-27)
- Handle linebreaks and trailing spaces by removing them. This prevents errors when serialising to MCF which could (quietly) break the data loading job.
v0.0.6 (2025-08-14)
- Node name is now an optional attribute. This enables easily appending data to existing Base DC Nodes.
v0.0.5 (2025-08-14)
- Nodes can now contain a single
dcidor a list ofdcids
v0.0.4 (2025-07-22)
- Improved how groups strings are transformed to camelCase by dealing with additional special characters
- Removed option to override input and output folders on the data load job.
v0.0.3 (2025-07-18)
- Fixes two bugs related to MCF files. It now enforces the
dcid:prefix for Node and automatically trims spaces betweendcid:and the start of the id string.
v0.0.2 (2025-07-07)
- Minor update to documentation and release to PyPI
v0.0.1 (2025-07-07)
- Initial release of the
dcp-tools