Dictionary
cifflow.dictionary.ddlm_item
DDLm item definition — one save frame extracted from a DDLm dictionary.
DdlmItem
dataclass
Represents a single definition extracted from a DDLm dictionary save frame.
Each save frame in a DDLm dictionary defines either a data item or a category. After import resolution, all relevant attributes are collected into this dataclass.
Attributes:
| Name | Type | Description |
|---|---|---|
definition_id |
str
|
Canonical tag name as it appears in CIF data files, normalised to
lowercase. Corresponds to |
scope |
str
|
|
definition_class |
str
|
DDLm class of this definition: |
category_id |
str | None
|
SQLite table name derived from |
object_id |
str | None
|
SQLite column name derived from |
type_purpose |
str | None
|
Value of |
type_source |
str | None
|
Value of |
type_container |
str
|
Value of |
type_contents |
str | None
|
Value of |
linked_item_id |
str | None
|
For |
units_code |
str | None
|
Value of |
description |
str | None
|
Human-readable description from |
enumeration_states |
list[str]
|
Allowed enumeration values from |
enumeration_default |
str | None
|
Default value from |
category_keys |
list[str]
|
Lowercased fully-qualified tag names from |
aliases |
list[str]
|
Old tag names from |
replaced_by |
list[str]
|
Preferred replacement tag names from |
is_deprecated |
bool
|
|
enumeration_range |
str | None
|
Value of |
type_dimension |
str | None
|
Value of |
enumeration_def_index_ids |
list[str]
|
Ordered list of canonical tag names from |
enumeration_defaults |
list[tuple[list[str], str]]
|
Keyed default table from a |
Source code in src/cifflow/dictionary/ddlm_item.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
cifflow.dictionary.ddlm_parser
DDLm dictionary data container produced by DictionaryLoader.
DdlmDictionary
dataclass
In-memory representation of a loaded DDLm dictionary.
Produced by DictionaryLoader.load(). Contains all category and item
definitions extracted from the dictionary's save frames, together with
pre-built lookup tables for fast tag resolution.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The |
title |
str | None
|
Value of |
version |
str | None
|
Value of |
categories |
dict[str, DdlmItem]
|
Mapping from lowercased |
items |
dict[str, DdlmItem]
|
Mapping from lowercased |
tag_to_item |
dict[str, DdlmItem]
|
Combined lookup covering every |
alias_to_definition_id |
dict[str, str]
|
Maps each lowercased alias tag name to the current lowercased
|
deprecated_ids |
set[str]
|
Set of lowercased |
warnings |
list[str]
|
Non-fatal issues encountered during loading, in emission order. |
source_files |
list[str]
|
Absolute file paths (or URIs) of every dictionary file loaded,
in load order. Populated when |
uri |
str | None
|
Value of |
Source code in src/cifflow/dictionary/ddlm_parser.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
cifflow.dictionary.loader
DDLm dictionary loader — parses a DDLm CIF and resolves _import.get directives.
SourceResolver = Callable[[str], str | None]
module-attribute
Callable that maps a URI string to a raw CIF source string, or None.
DictionaryLoader
Loads a DDLm dictionary from a CIF 2.0 source string.
Resolves _import.get directives using the supplied SourceResolver.
Both mode="Contents" (frame-level attribute merge) and mode="Full"
(constituent dictionary incorporation) are supported. File access is fully
delegated to the resolver; this class never accesses the filesystem or
network directly.
Parsed files are cached for the lifetime of the loader instance. To invalidate the cache, create a new instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolver
|
SourceResolver | None
|
Callable that maps a URI string to a raw CIF source string, or |
None
|
path_resolver
|
Callable[[str], str | None] | None
|
Optional companion to resolver that maps the same URI to an absolute
filesystem path. When provided, the resolved paths are recorded in
:attr: |
None
|
on_warning
|
Callable[[str], None] | None
|
Optional callback for non-fatal warnings. If |
None
|
ignore_head_imports
|
bool
|
When |
False
|
Source code in src/cifflow/dictionary/loader.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | |
load(source, *, base_uri=None)
Parse a DDLm dictionary source string and resolve all _import.get directives.
Both mode="Contents" (frame-level attribute merge) and
mode="Full" (constituent dictionary incorporation) are supported.
When a mode="Full" import targets a Head category, the entire
constituent dictionary is loaded recursively and its definitions are
merged into the result, with local definitions taking precedence.
Circular imports are detected and skipped with a warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Raw CIF 2.0 source string of the dictionary to parse. |
required |
base_uri
|
str | None
|
URI of the dictionary being parsed, used as the base for resolving
relative import URIs. If |
None
|
Returns:
| Type | Description |
|---|---|
DdlmDictionary
|
The fully loaded dictionary with all imports resolved. |
Source code in src/cifflow/dictionary/loader.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
directory_resolver(path)
Return a SourceResolver that reads files by filename from a local directory.
The last path component of the URI is used as the filename. Returns
None if the file is not found in the directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Directory to search for dictionary files. |
required |
Returns:
| Type | Description |
|---|---|
SourceResolver
|
A callable mapping URI strings to raw CIF source strings. |
Source code in src/cifflow/dictionary/loader.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
directory_path_resolver(path)
Return a path resolver that maps a URI to its absolute file path.
Companion to :func:directory_resolver. Pass to
DictionaryLoader(path_resolver=...) so that source_files in the
resulting DdlmDictionary contains absolute paths rather than bare URIs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Directory to search for dictionary files. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[str], str | None]
|
Maps URI strings to absolute path strings, or |
Source code in src/cifflow/dictionary/loader.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
cifflow.dictionary.schema
SQLite schema generation from a loaded DDLm dictionary.
BridgeColumnDef
dataclass
A column whose value is derived transitively through one or more tables.
When populating table_name, the column column_name has no direct
CIF source. Its value is resolved by following a chain of single-column
FK lookups described by hops, then reading bridge_value_column
from the final table in the chain.
Each hop is a 3-tuple (via_column, bridge_table, bridge_pk_column):
via_column: column in the previous table (or intable_namefor the first hop) whose value is used as the lookup key.bridge_table: the table to look up in.bridge_pk_column: the PK column ofbridge_tablematched againstvia_column.
For a single-hop bridge the chain has length 1 and the semantics are identical to the legacy four-field form.
Attributes:
| Name | Type | Description |
|---|---|---|
table_name |
str
|
Table that gains the derived column (e.g. |
column_name |
str
|
Name of the derived column (e.g. |
hops |
list[tuple[str, str, str]]
|
Ordered list of |
bridge_value_column |
str
|
Column in the last hop's |
fallback_chains |
list[tuple[list[tuple[str, str, str]], str]]
|
Alternative resolution chains tried in order when the primary chain
yields |
Source code in src/cifflow/dictionary/schema.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
via_column
property
Via-column of the first hop (column in table_name).
bridge_table
property
Bridge table of the last hop (the table holding the value).
bridge_pk_column
property
PK column of the last hop's bridge table.
ForeignKeyDef
dataclass
A FOREIGN KEY constraint between two tables (single- or multi-column).
Always emitted with DEFERRABLE INITIALLY DEFERRED to handle cyclic
category graphs correctly within a transaction.
Attributes:
| Name | Type | Description |
|---|---|---|
source_table |
str
|
Name of the table that holds the foreign key column(s). |
source_columns |
list[str]
|
Ordered list of foreign key column names in source_table. |
target_table |
str
|
Name of the table being referenced. |
target_columns |
list[str]
|
Ordered list of column names being referenced in target_table, corresponding positionally to source_columns. |
Source code in src/cifflow/dictionary/schema.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
ColumnDef
dataclass
Definition of a single column in a generated SQLite table.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
SQL column name, equal to the DDLm |
definition_id |
str
|
The current canonical |
type_contents |
str | None
|
DDLm |
nullable |
bool
|
|
is_primary_key |
bool
|
|
is_synthetic |
bool
|
|
linked_item_id |
str | None
|
For |
type_container |
str | None
|
DDLm |
enumeration_states |
list[str]
|
Allowed enumeration values from |
enumeration_range |
str | None
|
Value of |
type_dimension |
str | None
|
Value of |
enumeration_default |
str | None
|
Scalar default value from |
enumeration_def_index_ids |
list[str]
|
Ordered index tag names from |
enumeration_defaults |
list[tuple[list[str], str]]
|
Keyed default table: |
Source code in src/cifflow/dictionary/schema.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
TableDef
dataclass
Definition of a single SQLite table generated from a DDLm category.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
SQL table name, derived from the category's |
definition_id |
str
|
The |
category_class |
str
|
DDLm class of the source category: |
columns |
list[ColumnDef]
|
Ordered list of column definitions. Order follows the column-ordering
rule: |
primary_keys |
list[str]
|
Column names forming the |
foreign_keys |
list[ForeignKeyDef]
|
|
Source code in src/cifflow/dictionary/schema.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
SchemaSpec
dataclass
Complete SQLite schema derived from a DdlmDictionary.
Produced by :func:generate_schema and consumed by
:func:emit_create_statements and
:func:~cifflow.dictionary.schema_apply.apply_schema.
Attributes:
| Name | Type | Description |
|---|---|---|
tables |
dict[str, TableDef]
|
Mapping from SQL table name to its :class: |
column_to_tag |
dict[tuple[str, str], str]
|
Reverse mapping from |
alias_to_definition_id |
dict[str, str]
|
Old tag name → canonical |
deprecated_ids |
set[str]
|
Set of |
warnings |
list[str]
|
Non-fatal issues encountered during schema generation, in emission order. |
bridge_columns |
list[BridgeColumnDef]
|
Transitive bridge column definitions -- derived columns whose values are resolved through one or more FK lookup hops. |
propagation_links |
dict[str, list[tuple[str, str, str | None]]]
|
Mapping from table name to a list of
|
dictionary_name |
str | None
|
|
dictionary_title |
str | None
|
Value of |
dictionary_version |
str | None
|
Value of |
dictionary_uri |
str | None
|
Value of |
source_files |
list[str]
|
Absolute file paths of every dictionary file loaded. Empty when no
|
category_parent |
dict[str, str | None]
|
Mapping from table name to its parent table name (or |
tag_to_category_class |
dict[str, str]
|
Mapping from canonical |
deprecated_replacements |
dict[str, list[str]]
|
Mapping from deprecated |
Source code in src/cifflow/dictionary/schema.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
descendants(root)
Return all table names that are root or a descendant of root in the category_parent hierarchy.
Returns frozenset({root}) if root has no children, or
frozenset() if root is not in the schema at all.
Source code in src/cifflow/dictionary/schema.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
generate_schema(dictionary)
Derive a :class:SchemaSpec from a loaded DdlmDictionary.
Iterates over all categories in dictionary, creating one
:class:TableDef for each Set or Loop category. Head and
Functions categories are silently skipped (they never appear in data
instance files); any other unrecognised class emits a warning and is also
skipped.
Foreign-key constraints are built in a second pass over all items whose
type_purpose is "Link". SU items populate
:attr:ColumnDef.linked_item_id but do not produce
:class:ForeignKeyDef entries.
alias_to_definition_id and deprecated_ids are copied directly from
dictionary so that ingest() can perform alias resolution and
deprecation checking without retaining a reference to the dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
DdlmDictionary
|
The loaded dictionary returned by
:meth: |
required |
Returns:
| Type | Description |
|---|---|
SchemaSpec
|
The complete schema specification including all tables, column
definitions, primary keys, foreign keys, the reverse
|
Source code in src/cifflow/dictionary/schema.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 | |
emit_create_statements(schema)
Render each :class:TableDef in schema as a CREATE TABLE statement.
Returns one SQL string per table in topological order (FK parents before
children). The statements use CREATE TABLE IF NOT EXISTS and include
inline PRIMARY KEY and FOREIGN KEY clauses. All FK constraints
carry DEFERRABLE INITIALLY DEFERRED.
All value columns are declared TEXT regardless of
ColumnDef.type_contents; _cifflow_row_id is always INTEGER.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
SchemaSpec
|
The schema specification produced by :func: |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
One |
Source code in src/cifflow/dictionary/schema.py
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | |
emit_fallback_create_statements()
Return the fixed DDL statements for the schema-less fallback tier.
Returns four SQL strings: CREATE TABLE IF NOT EXISTS for
_cif_fallback, its lookup index, CREATE TABLE IF NOT EXISTS for
_block_dataset_membership, and CREATE TABLE IF NOT EXISTS for
_validation_result.
Source code in src/cifflow/dictionary/schema.py
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | |
cifflow.dictionary.resolver
Tag resolution — maps a CIF tag name to its current DDLm definition.
ResolvedTag
dataclass
Result of resolving a tag name against a loaded DDLm dictionary.
Produced by :func:resolve_tag.
Attributes:
| Name | Type | Description |
|---|---|---|
definition_id |
str
|
The current canonical tag name ( |
category_id |
str
|
The SQL table name for this definition ( |
object_id |
str
|
The SQL column name for this definition ( |
was_alias |
bool
|
|
is_deprecated |
bool
|
|
Source code in src/cifflow/dictionary/resolver.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
resolve_tag(tag, dictionary)
Resolve a tag name from a CIF data file to its current definition.
Looks up tag (case-insensitive) in dictionary.tag_to_item,
following alias chains transparently. Returns None if the tag is
not known to this dictionary; this is the signal that the tag belongs
to the fallback tier, not an error condition.
Does not emit warnings. The caller is responsible for acting on the
was_alias and is_deprecated flags of the returned value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
The tag name to resolve, as it appears in a CIF data file. Lookup is case-insensitive. |
required |
dictionary
|
DdlmDictionary
|
The loaded |
required |
Returns:
| Type | Description |
|---|---|
ResolvedTag | None
|
Resolution result including canonical name, table, column, and
alias/deprecation flags; |
Source code in src/cifflow/dictionary/resolver.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
cifflow.dictionary.cache
JSON serialisation and deserialisation of DdlmDictionary.
Allows a fully resolved dictionary (including metadictionary imports) to be saved to disk and reloaded without re-parsing constituent CIF files.
Cache invalidation is the caller's responsibility. These functions make no attempt to detect whether the source dictionary files have changed.
save_dictionary(dictionary, path)
Serialise dictionary to a JSON file at path.
The file is written atomically from the perspective of a single process
(standard open + json.dump). Existing files are overwritten.
tag_to_item is stored as a dict[str, str] mapping (tag name →
definition_id) to avoid duplicating DdlmItem objects for every
alias. It is reconstructed on load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
DdlmDictionary
|
The |
required |
path
|
str | Path
|
Destination file path. Parent directories must already exist. |
required |
Source code in src/cifflow/dictionary/cache.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
load_dictionary(path)
Deserialise a DdlmDictionary from a JSON file at path.
Raises ValueError if the file does not exist, contains malformed JSON,
is missing required keys, or references an unknown definition_id in
tag_to_item. The caller should respond by falling back to
DictionaryLoader.load().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a JSON file previously written by :func: |
required |
Returns:
| Type | Description |
|---|---|
DdlmDictionary
|
The deserialised dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file cannot be read or the contents are invalid. |
Source code in src/cifflow/dictionary/cache.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
cifflow.dictionary.visualise
Schema visualisation: DOT and HTML output for SchemaSpec.
Public functions
visualise_schema(schema, ...) -> Graphviz DOT string visualise_schema_html(schema, ...) -> self-contained HTML string
visualise_schema(schema, *, show_columns='sparse', show_bridge=True, show_parent_edges=True, highlight_orphans=True, highlight_components=False, show_orphans=True, show_legend=True, concentrate=False, hide_deprecated=False, layout='dot', splines='curved', ranksep=1.0, nodesep=0.4)
Return a Graphviz DOT string visualising schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
SchemaSpec
|
The :class: |
required |
show_columns
|
Literal['all', 'sparse', 'none']
|
|
'sparse'
|
show_bridge
|
bool
|
Include bridge column edges. Always |
True
|
show_parent_edges
|
bool
|
Include category-parent hierarchy edges. Always |
True
|
highlight_orphans
|
bool
|
Apply |
True
|
highlight_components
|
bool
|
Wrap each connected component in a |
False
|
show_orphans
|
bool
|
When |
True
|
show_legend
|
bool
|
When |
True
|
concentrate
|
bool
|
When |
False
|
hide_deprecated
|
bool
|
When |
False
|
layout
|
str
|
Graphviz layout engine written into |
'dot'
|
splines
|
str
|
Graphviz |
'curved'
|
ranksep
|
float
|
Minimum separation in inches between ranks (layout rows/columns).
Larger values spread the graph out vertically (or horizontally with
|
1.0
|
nodesep
|
float
|
Minimum separation in inches between adjacent nodes in the same rank.
Default |
0.4
|
Returns:
| Type | Description |
|---|---|
str
|
A Graphviz DOT source string ready to pass to a Graphviz renderer or embed in an HTML page via viz.js. |
Source code in src/cifflow/dictionary/visualise.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
visualise_schema_html(schema, *, title=None, show_columns='sparse', show_bridge=True, show_parent_edges=True, highlight_orphans=True, highlight_components=False, show_orphans=True, show_legend=True, concentrate=False, hide_deprecated=False, layout='dot', splines='curved', ranksep=1.0, nodesep=0.4)
Return a self-contained HTML string that renders schema interactively.
All keyword arguments except title are forwarded to
:func:visualise_schema. The returned HTML embeds viz.js and svg-pan-zoom
as inline <script> blocks — no network access is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
SchemaSpec
|
The :class: |
required |
title
|
str | None
|
|
None
|
show_columns
|
Literal['all', 'sparse', 'none']
|
|
'sparse'
|
show_bridge
|
bool
|
Forwarded to :func: |
True
|
show_parent_edges
|
bool
|
Forwarded to :func: |
True
|
highlight_orphans
|
bool
|
Forwarded to :func: |
True
|
highlight_components
|
bool
|
Forwarded to :func: |
False
|
show_orphans
|
bool
|
Forwarded to :func: |
True
|
show_legend
|
bool
|
Forwarded to :func: |
True
|
concentrate
|
bool
|
Forwarded to :func: |
False
|
hide_deprecated
|
bool
|
Forwarded to :func: |
False
|
layout
|
str
|
Forwarded to :func: |
'dot'
|
splines
|
str
|
Forwarded to :func: |
'curved'
|
ranksep
|
float
|
Forwarded to :func: |
1.0
|
nodesep
|
float
|
Forwarded to :func: |
0.4
|
Returns:
| Type | Description |
|---|---|
str
|
A self-contained HTML document with the schema rendered as an interactive SVG via viz.js and svg-pan-zoom. |
Source code in src/cifflow/dictionary/visualise.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |