Upgrading to 0.6¶
ddigraph 0.6 builds one graph from every DDI flavor. Every load, export,
preview and backend reads the file with ddigraph.ir.parse() and writes it
through a lens. So a graph, an export or a script made for 0.5 does not
match 0.6. This page shows how to move a Neo4j database across. Then it
lists each name 0.6 renamed or removed, with what to use instead, and the
behaviour that changed. The
changelog has the full story, and
Node identity explains the new names.
Migrate a Neo4j Database¶
A database that 0.5 loaded holds the old shape. Its Concept.name IS
UNIQUE constraint also makes a second dataset's load fail with a
ConstraintError. Before the first 0.6 load, follow the steps below. They
keep the properties you added to the 0.5 nodes, such as notes or
embeddings. tests/test_migration_live.py runs them on a graph that 0.5.1
loaded. It checks that the result equals a fresh 0.6 load, with your
properties kept.
Before you start
- Back up the database. Step 2 drops its constraints and indexes. Step 6 deletes the 0.5 nodes with their relationships, including the relationships you added to them, since step 5 copies properties only.
- Use Neo4j 5.26 or later (the
neo4j:5image). Steps 5 and 6 useCALL (old) { ... }andSET new[name], which older servers reject. - Note each Codebook and DDI-CDI file's dataset ID from 0.5. Step 4 reloads each file with the same one. 0.5 loaded a DDI-L file into no dataset, so pick the dataset ID you want to keep for it.
1. List What Will Be Dropped¶
ddigraph bootstrap --drop-legacy --dry-run
It drops nothing. It prints a DROP CONSTRAINT or DROP INDEX for each
constraint and index whose name does not start with ddigraph_. Then it
prints the 0.6 statements and a count. On a database that 0.5.1
bootstrapped, it starts and ends like this:
DROP CONSTRAINT `constraint_100dbabe` IF EXISTS;
DROP CONSTRAINT `constraint_10b3963e` IF EXISTS;
...
DROP INDEX `index_fed50bee` IF EXISTS;
CREATE CONSTRAINT ddigraph_DDINode_key IF NOT EXISTS
FOR (n:DDINode) REQUIRE n.key IS UNIQUE;
CREATE RANGE INDEX ddigraph_DDINode_urn IF NOT EXISTS
FOR (n:DDINode) ON (n.urn);
...
Dry run: 335 statements (280 drops) would run on database 'neo4j'; none ran
Read the list. --drop-legacy drops every constraint and index whose
name does not start with ddigraph_, except the LOOKUP indexes. That
includes indexes you made yourself, such as full-text or vector indexes.
Note them, and create them again after step 3.
2. Drop the 0.5 Schema¶
ddigraph bootstrap --drop-legacy
It prints each statement it dropped, creates the 0.6 schema, and ends with:
Schema ensured for database 'neo4j'; dropped 280 legacy constraints and indexes
3. Create the 0.6 Schema¶
ddigraph bootstrap
It changes nothing here, since step 2 made the schema. It is the command to
run on every new database from now on: one key constraint and the range
indexes, all named ddigraph_*. Create your own indexes again now.
4. Reload Each File¶
Load each file again. Give a Codebook or DDI-CDI file the dataset ID it had in 0.5, since step 5 matches its nodes in that dataset. Step 5 matches DDI-L nodes by their URN, so any dataset ID works for a DDI-L file:
ddigraph load codebook_sample.xml --dataset-id cb
ddigraph load fragment_instance.xml --dataset-id fi
ddigraph load cdi_sample.xml --dataset-id cdi
The 0.6 nodes have the DDINode label. They are written beside the 0.5
ones, which do not have it. Each load prints a summary such as:
Ingestion complete: dataset_id=cb, nodes_written=52, relationships_written=20, stubs=0, references=17, resolved=16, unresolved=1, conflicts=3
5. Copy the Properties You Added¶
This step copies each property you added to a 0.5 node onto the 0.6 node it
became. First set $written to the names of every property that 0.5.x
wrote, so they are not copied. In Neo4j Browser or cypher-shell, run this
line on its own:
:param written => ['abbreviation', 'abstract', 'access_condition_id', 'access_policy_id', 'activity_type', 'agency', 'agent_type', 'authorization_id', 'authorization_statement', 'authors', 'bibliographic', 'category_count', 'category_group_id', 'category_id', 'category_ids', 'category_label', 'cdi_id', 'citation_id', 'code', 'code_count', 'code_list_id', 'code_scheme_id', 'comparison_id', 'comparison_type', 'completion_date', 'component_type', 'concept', 'condition', 'construct_count', 'construct_id', 'construct_type', 'contributor_id', 'control_construct_reference', 'control_construct_references', 'coverage_id', 'coverage_type', 'dataset_id', 'dataset_name', 'dataset_type', 'ddi_id', 'description', 'development_id', 'development_results_references', 'doc_id', 'domain_type', 'element_tag', 'element_type', 'end_date', 'entity_type', 'evaluation_id', 'event_id', 'external_instrument_locations', 'external_references', 'fielded_languages', 'file_id', 'fragment_id', 'funding_id', 'grant_number', 'group_id', 'id', 'identifiable_id', 'instrument_id', 'instrument_type', 'label', 'language', 'logical_record_id', 'material_id', 'measurement_text', 'name', 'ncube_group_id', 'ncube_id', 'ncube_ids', 'note_id', 'organization_id', 'parent_flow_id', 'parent_grid_id', 'parent_question_id', 'physical_structure_id', 'policy_type', 'processing_event_id', 'producer', 'quality_id', 'question_flow_id', 'question_grid_id', 'question_id', 'question_item_id', 'question_text', 'rationale', 'referenced_construct_id', 'representation_id', 'representation_type', 'represented_variable_id', 'response_type', 'reusable_agency', 'reusable_id', 'reusable_type_of_object', 'reusable_urn', 'reusable_version', 'role', 'sample_frame_id', 'sampling_id', 'series_id', 'software_id', 'standard', 'start_date', 'structure_type', 'study_id', 'text', 'title', 'universe_id', 'uri', 'urn', 'value', 'var_group_id', 'variable_id', 'variable_ids', 'version', 'weight_id']
Then set $labels to every label that 0.5.x gave a node. Steps 5 to 7
work only on the nodes that lack DDINode and have one of these labels or
a fragment_id. So the nodes that ddigraph did not write are left alone,
unless one of them has such a label:
:param labels => ['Access', 'AccessCondition', 'AccessPolicy', 'ActionToMinimizeLosses', 'AggregationVariables', 'ApprovalReview', 'ApprovalReviewDocument', 'Archive', 'Attribute', 'AuthorizedSource', 'CDIActivity', 'CDIAgent', 'CDICategory', 'CDICategorySet', 'CDIClassificationFamily', 'CDIClassificationIndex', 'CDIClassificationItem', 'CDIClassificationSeries', 'CDICode', 'CDICodeList', 'CDIConcept', 'CDIConceptMap', 'CDIConceptSystem', 'CDIConceptSystemCorrespondence', 'CDIConceptualVariable', 'CDICorrespondenceTable', 'CDIDataSet', 'CDIDataStore', 'CDIDataStructure', 'CDIDataStructureComponent', 'CDIInstanceVariable', 'CDILogicalRecord', 'CDIPhysicalDataSet', 'CDIPhysicalRecordSegment', 'CDIPopulation', 'CDIProcessingAgent', 'CDIRepresentedVariable', 'CDIStatisticalClassification', 'CDIUnitType', 'CDIUniverse', 'CDIValueDomain', 'CDIVariableRelationship', 'Category', 'CategoryGroup', 'CategoryMap', 'CategoryScheme', 'Citation', 'ClassificationCorrespondenceTable', 'ClassificationFamily', 'ClassificationIndex', 'ClassificationItem', 'ClassificationLevel', 'ClassificationSeries', 'Code', 'CodeList', 'CodeListGroup', 'CodeListScheme', 'CodeScheme', 'CognitiveExpertReviewActivity', 'CognitiveInterviewActivity', 'Collection', 'CollectionEvent', 'CollectionInstrument', 'CollectionSituation', 'Comparison', 'ComputationItem', 'Concept', 'ConceptGroup', 'ConceptMap', 'ConceptScheme', 'ConceptualComponent', 'ConceptualVariable', 'ConceptualVariableGroup', 'ConceptualVariableScheme', 'ContentReviewActivity', 'Contributor', 'ContributorRole', 'ControlConstruct', 'ControlConstructGroup', 'ControlConstructScheme', 'CoordinateRegion', 'Coverage', 'DDIGenericIdentifiable', 'DDIInstance', 'DDIProfile', 'DataCaptureDevelopment', 'DataCollection', 'DataCollectionEvent', 'DataCollectionMethodology', 'DataFile', 'DataRelationship', 'DataSet', 'Dataset', 'DefaultAccess', 'DevelopmentActivity', 'DevelopmentActivityGroup', 'DevelopmentActivityScheme', 'DevelopmentImplementation', 'DevelopmentPlan', 'DevelopmentResults', 'DevelopmentStep', 'DeviationFromSampleDesign', 'DocumentDescription', 'Embargo', 'ExPostEvaluation', 'FocusGroupActivity', 'Funding', 'FundingDocument', 'GeneralInstruction', 'GenerationInstruction', 'GeographicLevel', 'GeographicLocation', 'GeographicLocationGroup', 'GeographicLocationScheme', 'GeographicStructure', 'GeographicStructureGroup', 'GeographicStructureScheme', 'GrossFileStructure', 'GrossRecordStructure', 'Group', 'IfThenElse', 'InParameter', 'Individual', 'InformationClassification', 'Instruction', 'InstructionGroup', 'Instrument', 'InstrumentGroup', 'InstrumentScheme', 'InterviewerInstructionScheme', 'ItemMap', 'LifecycleEvent', 'LocalGroupContent', 'LocalHoldingPackage', 'LocalResourcePackageContent', 'LocalStudyUnitContent', 'LocationValue', 'LogicalProduct', 'LogicalRecord', 'Loop', 'ManagedDateTimeRepresentation', 'ManagedItemMap', 'ManagedMissingValuesRepresentation', 'ManagedNumericRepresentation', 'ManagedRepresentationGroup', 'ManagedRepresentationScheme', 'ManagedScaleRepresentation', 'ManagedTextRepresentation', 'MeasureDefinition', 'MeasurementConstruct', 'MeasurementGroup', 'MeasurementItem', 'MeasurementScheme', 'Methodology', 'MethodologyNote', 'ModeOfCollection', 'NCube', 'NCubeGroup', 'NCubeInstance', 'NCubeScheme', 'Organization', 'OrganizationGroup', 'OrganizationScheme', 'OtherMaterial', 'OtherMaterialGroup', 'OtherMaterialScheme', 'OutParameter', 'PhysicalDataProduct', 'PhysicalInstance', 'PhysicalInstanceGroup', 'PhysicalRecordSegment', 'PhysicalStructure', 'PhysicalStructureGroup', 'PhysicalStructureScheme', 'PretestActivity', 'ProcessingEvent', 'ProcessingEventGroup', 'ProcessingEventScheme', 'ProcessingInstructionGroup', 'ProcessingInstructionScheme', 'QualityScheme', 'QualityStandard', 'QualityStandardGroup', 'QualityStatement', 'QualityStatementGroup', 'Question', 'QuestionBlock', 'QuestionConstruct', 'QuestionFlow', 'QuestionGrid', 'QuestionGroup', 'QuestionItem', 'QuestionMap', 'QuestionScheme', 'RecordLayout', 'RecordLayoutGroup', 'RecordLayoutScheme', 'RecordRelationship', 'Relation', 'RepeatUntil', 'RepeatWhile', 'Representation', 'RepresentationMap', 'RepresentedVariable', 'RepresentedVariableGroup', 'RepresentedVariableScheme', 'ResourcePackage', 'Sample', 'SampleFrame', 'SampleFrameAccess', 'SampleStep', 'SamplingInformationGroup', 'SamplingInformationScheme', 'SamplingPlan', 'SamplingProcedure', 'SamplingStage', 'Sequence', 'Series', 'Software', 'SpatialCoverage', 'Split', 'SplitJoin', 'StandardWeight', 'StatementItem', 'StatisticalClassification', 'Study', 'StudyAuthorization', 'StudyDevelopment', 'StudyUnit', 'SubUniverseClass', 'TemporalCoverage', 'TimeMethod', 'TopicalCoverage', 'TranslationActivity', 'UnitType', 'UnitTypeGroup', 'UnitTypeScheme', 'Universe', 'UniverseGroup', 'UniverseMap', 'UniverseScheme', 'VarGroup', 'Variable', 'VariableGroup', 'VariableMap', 'VariableScheme', 'VariableStatistics', 'Weight', 'Weighting', 'WeightingMethodology']
Then run the copy:
MATCH (old) WHERE NOT old:DDINode
AND (old.fragment_id IS NOT NULL OR any(label IN labels(old) WHERE label IN $labels))
CALL (old) {
MATCH (new:DDINode:Dataset {dataset_id: old.id}) WHERE old:Dataset
RETURN new
UNION
MATCH (new:DDINode {ddi_id: old.ddi_id, agency: old.agency, version: old.version})
WHERE old.fragment_id IS NOT NULL
RETURN new
UNION
MATCH (old)-[:IN_DATASET]->(home:Dataset)
MATCH (new:DDINode {ddi_id: old.id})-[:IN_DATASET]->(:DDINode:Dataset {dataset_id: home.id})
RETURN new
}
UNWIND [name IN keys(old) WHERE NOT name IN $written AND new[name] IS NULL] AS name
SET new[name] = old[name]
RETURN new.key AS key, name
It returns one row for each property it copied. Say you set a note on
variable v1, a reviewed flag on DDI-L category cat1 and an owner on
dataset cb. Then it returns:
key name
a8bc6c5b92a74160b1ddcfef254fc4ef owner
3606606eebc19440cc7ba5ce55c6bd61 note
4fc41f4fb59acbab4031c11f34883242 reviewed
What each part does:
- The
MATCHfinds every node 0.5 wrote. Such a node lacks the 0.6 label, and has a 0.5 label or afragment_id. 0.5 gave every DDI-L node afragment_id. It also gave a DDI-L element it did not know its own tag as a label, so thefragment_idfinds those. - The first branch matches a 0.5
Datasetto the 0.6Datasetwhosedataset_idis itsid. - The second branch matches a DDI-L node (0.5 gave it a
fragment_id) to the 0.6 node of the same agency, ID and version: the parts of its URN. - The third branch matches a Codebook node to the 0.6 node whose
ddi_idis its XMLid, in a dataset the 0.5 node was in. 0.5 shared one node between datasets, and 0.6 scopes IDs to a dataset. So this can match one node per dataset, and each one gets the property. - The
UNWINDkeeps the names that 0.5 never wrote and the 0.6 node lacks. So nothing that 0.5 or 0.6 wrote is copied or overwritten. SET new[name] = old[name]copies each one.
The ddi_id index serves the second and third lookups. From Python, pass
written and labels as query parameters instead of running the :param
lines.
Some 0.5 nodes have no XML ID, so no 0.6 node matches them. They are the
Codebook elements 0.5 named by their position (such as cb:citation_1),
the Concepts it keyed by name, and every 0.5 DDI-CDI node (such as
cdi:code_list_1). Copy what you added to those by hand.
6. Delete the 0.5 Nodes¶
Delete them 10,000 to a transaction:
MATCH (old) WHERE NOT old:DDINode
AND (old.fragment_id IS NOT NULL OR any(label IN labels(old) WHERE label IN $labels))
CALL (old) { DETACH DELETE old } IN TRANSACTIONS OF 10000 ROWS
CALL ... IN TRANSACTIONS runs only outside an explicit transaction. In
Neo4j Browser, start it with :auto. cypher-shell runs it as it is.
7. Check That None Is Left¶
MATCH (old) WHERE NOT old:DDINode
AND (old.fragment_id IS NOT NULL OR any(label IN labels(old) WHERE label IN $labels))
RETURN count(old) AS left
It must return 0.
Renamed and Removed Names¶
Each table gives the 0.5 name and what to use in 0.6.
Graph Properties¶
| 0.5 | 0.6 |
|---|---|
id (Codebook nodes) |
ddi_id, the file's ID; the node is scoped to its dataset_id |
id (Dataset nodes) |
dataset_id |
fragment_id (DDI-L nodes) |
urn, or ddi_id, agency and version |
cdi_id (DDI-CDI nodes) |
ddi_id, and urn for an object with a ddiIdentifier |
variable_id, question_id, study_id and the other <label>_id identity names |
ddi_id |
The lookup fields file_id, universe_id, category_ids, variable_ids, ncube_ids, code_scheme_id, parent_grid_id, parent_flow_id, concept and the control construct references |
Edges, such as IN_FILE, IN_UNIVERSE, USES_CATEGORY and USES_CONSTRUCT |
| No dataset on DDI-L nodes | (n)-[:IN_DATASET]->(:Dataset), one edge per dataset that holds the node, for every flavor |
Question.text |
question_text, as on every question |
dataset_name (Codebook nodes) |
The name of the node's Dataset: (n)-[:IN_DATASET]->(d:Dataset) and d.name |
label (Dataset nodes) |
name |
label (DDI-CDI nodes), set to the name when the object has no display label |
label only from a displayLabel or LabelForDisplay; otherwise read name |
| None | key (32 hex characters, unique), identity and content_hash on every node; key_scheme on Dataset nodes |
Labels and Edges¶
| 0.5 | 0.6 |
|---|---|
The EntryPoint label |
(:Dataset)-[:HAS_ENTRY_POINT]->(n), scoped to the dataset |
The ContributorRole label |
Contributor |
(QuestionGrid)-[:HAS_ITEM]->(QuestionItem) |
(QuestionItem)-[:IN_GRID]->(QuestionGrid), with an ordinal |
(QuestionFlow)-[:HAS_ITEM]->(QuestionItem) |
(QuestionItem)-[:IN_FLOW]->(QuestionFlow), with an ordinal |
GOVERNED_BY from AccessPolicy to Dataset, in the exports and backends |
(Dataset)-[:GOVERNED_BY]->(AccessPolicy) everywhere, as Neo4j already had it |
(CDICorrespondenceTable)-[:HAS]->(CDIConceptMap) |
(CDICorrespondenceTable)-[:HAS_CONCEPT_MAP]->(CDIConceptMap), as a concept system correspondence has it |
| None | DDINode on every node; Unresolved and unresolved_reason on a stub; ordinal on an ordered edge; resolution on a reference edge |
Cypher¶
| 0.5 | 0.6 |
|---|---|
MATCH (v:Variable {id: 'v1'}) |
MATCH (v:Variable {dataset_id: 'cb', ddi_id: 'v1'}) |
MATCH (d:Dataset {id: 'cb'}) |
MATCH (d:Dataset {dataset_id: 'cb'}) |
MATCH (n {fragment_id: 'urn:ddi:test.org:cat1:1.0'}) |
MATCH (n:DDINode {urn: 'urn:ddi:test.org:cat1:1.0'}) |
MATCH (n)-[:IN_DATASET]->(:Dataset {id: 'cb'}) |
MATCH (n)-[:IN_DATASET]->(:Dataset {dataset_id: 'cb'}) |
MATCH (n:EntryPoint) |
MATCH (:Dataset)-[:HAS_ENTRY_POINT]->(n) |
MATCH (g:QuestionGrid)-[:HAS_ITEM]->(i) |
MATCH (i:QuestionItem)-[:IN_GRID]->(g:QuestionGrid) |
RETURN q.text |
RETURN q.question_text |
Python¶
| 0.5 | 0.6 |
|---|---|
DDILoader, DDIFragmentLoader |
ddigraph.load(path, dataset_id=...), which loads every flavor |
DDIFragmentLoader.load(clear_first=True) |
ddigraph.load(path, dataset_id=..., replace=True), which deletes only that dataset |
GraphChunkWriter, Neo4jGraphAdapter, AsyncFragmentGraphWriter |
ddigraph.lens.neo4j.Neo4jLens(driver).write(chunks, dataset_id=...), with chunks = ddigraph.ir.parse(path, dataset_id=...) |
GraphWriteAdapter |
A lens: the ddigraph.lens.Lens protocol (see Custom Adapters) |
ensure_schema, ensure_fragment_schema, bootstrap_queries, fragment_bootstrap_queries, CONSTRAINT_QUERIES, INDEX_QUERIES |
ddigraph.bootstrap(), ddigraph.graph.bootstrap.bootstrap_schema(driver) or Neo4jLens.ddl() |
bootstrap(include_fragments=..., include_cdi=...) |
bootstrap(), or bootstrap(drop_legacy=True, dry_run=True); it returns the statements |
LoadResult.totals |
nodes_written, relationships_written, stubs, references, resolved, unresolved and conflicts |
parse_ddi_batches, parse_cdi_batches, DDIFragmentParser, DDIBatch, CDIBatch, CDIBatchStream, Fragment, FragmentReference, parse_ddi_variables and the rest of ddigraph.ingest |
ddigraph.ir.parse(path, dataset_id=...) |
is_cdi_format(path) |
ddigraph.detect(path) == "cdi" |
DDISchema, ddigraph.schema.definitions, DDIIngestGraph, DDI_RELATIONSHIPS |
ddigraph.mm.load_spec(), and the tables in ddigraph.schema._generated.model |
DDISchema.FRAGMENT_RELATIONSHIP_TYPES |
ddigraph.ir.lifecycle.REFERENCE_TYPES |
ddigraph.graph.view.node_key(node) |
node.key, or ddigraph.urn.text(node.identity) for a readable ID |
A GraphChunk node's identity dict, and a relationship's start and end nodes |
node.identity is a ddigraph.urn identity; rel.start and rel.end are keys |
ddigraph.metrics (MetricsEmitter, NullMetrics) and the metrics= arguments |
Removed; read the counts in LoadResult and the log |
ddigraph.utils.retry.retry_transient, ddigraph.utils.as_dicts and six helpers of ddigraph.utils.parsing |
Removed; the Neo4j driver retries each chunk's transaction. Copy a helper into your own code if you need it |
ddigraph.ingest.loader.DRY_RUN_MESSAGE |
ddigraph.api.DRY_RUN_MESSAGE |
ddigraph.ingest.fragment_loader.detect_ddi_format |
ddigraph.detect_ddi_format, or ddigraph.ir.detect, which also has normalize_dataset_id |
ddigraph.export(..., base=...) |
No base: every RDF subject is the node's identity |
ddigraph.rdf.reader.read_graph(..., chunk_size=...) |
read_graph(path, dataset_id=...) |
ddigraph.rdf.writer.build_graph(chunks, base=...) |
build_graph(chunks, dataset_id=...) |
DEFAULT_BASE_URI, subject_iri, property_field_for, relationship_type_for, is_ambiguous_predicate |
ddigraph.urn.text(node.identity), which is the subject IRI |
to_networkx(..., flatten_lists=True), ddigraph.backends.networkx.node_id |
A node's ID is its key; for GraphML, copy the graph with plain values |
NetworkX node_type |
node_labels, a sorted list |
pandas node_label, node_id, start_label, start_id, end_label, end_id |
key, node_labels (a list), and start and end, joined on nodes.key |
Gremlin g.V().has(label, "node_key", key) |
g.V().has("key", key) |
Command Line¶
| 0.5 | 0.6 |
|---|---|
ddigraph bootstrap --include-fragments, --no-include-fragments, --include-cdi |
ddigraph bootstrap: one schema for every flavor |
| None | ddigraph bootstrap --drop-legacy [--dry-run] |
ddigraph export --base-uri |
No option: every RDF subject is the node's identity |
--queue-maxsize, --writer-concurrency, --batch-metrics, --write-retry-attempts, --write-retry-base-delay, --write-retry-jitter, --metrics-namespace |
Removed; --chunk-size still sets the nodes per chunk |
--transaction-timeout on a load |
It applies to ddigraph bootstrap only; a load uses the server's db.transaction.timeout |
The Ingestion complete: Category=45, ..., batches=5, relationships=410 summary |
Ingestion complete: dataset_id=..., nodes_written=..., relationships_written=..., stubs=..., references=..., resolved=..., unresolved=..., conflicts=...; --json prints the whole LoadResult |
--replace deleted every DDI-L node for a DDI-L file, and did nothing for RDF |
--replace deletes only the dataset, for every format; a node another dataset holds stays |
--dataset-id required for a Codebook load, and ignored for DDI-L |
It applies to every flavor, and defaults to the file name without its extension |
ddigraph preview --limit lines such as variable_id=v1 |
The identity's text form, such as urn:ddigraph:scoped:codebook_sample:v1 |
| None | ddigraph load --resolve exact, latest-declared or fail |
Settings¶
| 0.5 | 0.6 |
|---|---|
queue_maxsize, writer_concurrency, batch_metrics, write_retry_attempts, write_retry_base_delay, write_retry_jitter, metrics_namespace |
Removed, with their DDIGRAPH_* variables. --tune and --config refuse them as unknown |
strict_parsing refused only Codebook variables with the same ID |
It refuses any file in which two elements claim one key, before anything is written |
transaction_timeout limited each write |
It limits each statement of a bootstrap |
HTTP API¶
| 0.5 | 0.6 |
|---|---|
/bootstrap with include_fragments and include_cdi |
drop_legacy and dry_run; the job's result is {drop_legacy, dry_run, statements} |
A /load result with totals |
The LoadResult fields; /load also takes resolve |
/export with base |
Removed |
Exports¶
| 0.5 | 0.6 |
|---|---|
RDF subjects {base}/{Label}/{id} |
The node's identity: urn:ddi:..., or urn:ddigraph:scoped:{dataset}:{id} |
ddigraph:fragmentId, ddigraph:variableId and the other identity predicates |
ddigraph:key, or ddigraph:ddiId |
ddigraph:inDataset |
A ddigraph:Membership, and dcterms:isPartOf the Dataset node |
skos:exactMatch, once per external reference |
One rdf:List of the references, in order, under ddigraph:externalReferences |
| JSON export of labels and identity fields | The IR: nodes with key, label, identity, provenance, unresolved and properties; relationships with start, type, end, ordinal and resolution |
CSV node_id, start_label, start_id, end_label, end_id |
nodes.csv starts with key, node_label and identity; join relationships.start and relationships.end to nodes.key |
An RDF file that 0.5 exported does not load in 0.6, and it fails the 0.6 SHACL shapes. Export the DDI file again with 0.6.
Behaviour Changes¶
These change what ddigraph does with the same input. Each one fixes something, but check them before you upgrade. The changelog gives the detail of each.
Reading Files¶
- The Rust engine reads by default. The engine setting now defaults to
auto: the Rust engine when it is installed and the file fits the memory limit, lxml otherwise. The graph is the same. To read every file with lxml, as 0.5 did, setDDIGRAPH_ENGINE=lxml. - Format detection is stricter. A
DDIInstanceroot is now DDI-L, and only aFragmentInstancecan be loaded. An empty file or an unknown root raisesValueError, andddigraph.detect()raises instead of returning"unknown". - An unknown DDI-L element stops the load. A fragment or a
*Referencethat the mapping spec has no name for raisesValueErrorwith the file and line. 0.5 kept the fragment under its tag name and dropped the reference. - libxml2's size limits stay on. A text node over 10 MB, a tree deeper
than 256 levels, a name over 50,000 characters, or 100 or more syntax
errors raise
XMLLimitError. SetDDIGRAPH_XML_HUGE_TREE=trueonly for a file you trust. - An entity with markup is refused. A file that declares an entity with XML markup in its text is refused. Replace each such entity with its text.
- lxml 6.2.0 or later is required. It fixes several security issues, among them GHSA-59qx-3jjv-x996 and CVE-2026-41066.
ddigraph.ir.parse()reads the whole file first. Then it streams the Dataset node, the nodes, the stubs and last the references, in a new order. The graph is the same. If your code relied on the order, sort the stream yourself.- Codebook unresolved references come in document order, as DDI-L and DDI-CDI already did.
- A DDI-L reference with no
TypeOfObjectis kept. It used to be dropped without a word. Now it is an edge, as any other reference is. - A DDI-L 3.3 condition is read. An
IfThenElse,Loop,RepeatWhileorRepeatUntilnow has theconditionthat itsr:CommandContentholds, such asWORK = 1.
Loading into Neo4j¶
- A reload without
--replaceonly adds and updates. It keeps the nodes and edges the file no longer holds. Reload an edited file with--replace. - No free text has an index.
ddigraph bootstrapno longer indexes labels, descriptions, question texts, titles or conditions, since a long value would fail the write. Add your own index if you need one. --transaction-timeoutapplies toddigraph bootstraponly. A load's transactions use the server'sdb.transaction.timeout.--session-timeoutis deprecated and ignored with a warning.- TLS settings from the environment now apply, from
.envtoo. With aneo4j+s://orneo4j+ssc://URI, TLS options are dropped with a warning. - An HTTP upload's provenance is the server's temporary copy, not the uploaded file's name.
Texts in several languages¶
- A DDI-L text keeps each of its languages. This covers a name, a
label, a description, a category's label, a question's or a
measurement's text, and a title. 0.5 kept the first text only. Now
pholds the primary text: the one with no language, or else the one whose tag sorts first, soenbeforefr.p_translationsandp_translation_langshold the others. A DDI-L node also has adescription, from its own<r:Description>. - A name is a text. In every flavor,
nameis now a text, aslabelis. A DDI-L name has its language inname_lang. In Python, the IR and a query row give aText, not a string: readname.value. - The RDF export writes one literal per language. A DDI-L name, such
as
ddigraph:name "Yes / No"@en, "Oui / Non"@fr, has its language now. A SPARQL filter that compared it with a plain string no longer matches. Compare its string instead:
FILTER(str(?n) = "Yes / No")
A query that expected one label per node may now get one row per language. Pick the language you want:
FILTER(lang(?l) = "en")
The SHACL shapes allow one literal per language, and at most one with
no language. Export the DDI file again with 0.6.
- A DDI-L node has its user IDs. The lists user_ids and
user_id_types hold its own <r:UserID> elements. The RDF export
links each one with ddigraph:userId (see
User IDs). There is nothing to change, but
the content_hash of a node with user IDs changes.
Logs and Python Output¶
- A load logs different records.
Loaded FILE into dataset X: N nodes (S stubs), R relationshipsreplacesDDI ingestion finished with totals. The CLI'sIngestion completerecord carriesdataset_id,nodes_writtenandrelationships_written. - Log lines show their fields as sorted
key=valuepairs after the message. TheRecovered DDI XML parse errorwarning comes from theddigraph.utils.parsinglogger, with its message inparse_error. RELATIONSHIP_COLUMNSmoved toddigraph.lens.pandas, andto_dataframesadds amembershipsframe: one row per node and dataset that holds it.