API Reference¶
This API reference provides comprehensive documentation for all public classes and functions in the BAM Masterdata package. For more detailed examples and usage patterns, see the How-to Guides and Tutorial sections.
bam_masterdata.metadata.entities
¶
BaseEntity
¶
Bases: BaseModel
Base class used to define ObjectType
and VocabularyType
classes. It extends the BaseModel
adding new methods that are useful for interfacing with openBIS.
Source code in bam_masterdata/metadata/entities.py
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 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 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 179 180 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 213 214 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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
__str__ = __repr__
¶
cls_name
¶
Returns the entity name of the class as a string to speed up checks. This is a property to be overwritten by each of the abstract entity types.
__init__(**kwargs)
¶
Source code in bam_masterdata/metadata/entities.py
__setattr__(key, value)
¶
Source code in bam_masterdata/metadata/entities.py
__repr__()
¶
Source code in bam_masterdata/metadata/entities.py
get_property_metadata()
¶
Dictionary containing the metadata of the properties assigned to the entity type.
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the keys of the
TYPE:
|
dict
|
values of the definitions of |
dict
|
{ "name": PropertyTypeAssignment( code="$NAME", data_type=VARCHAR, mandatory=True, property_label="Name" ), "age": PropertyTypeAssignment( code="AGE", data_type=INTEGER, mandatory=False, property_label="Age" ), |
dict
|
} |
Source code in bam_masterdata/metadata/entities.py
to_json(indent=None)
¶
Returns the entity as a string in JSON format storing the value of the properties assigned to the entity.
PARAMETER | DESCRIPTION |
---|---|
indent
|
The indent to print in JSON. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The JSON representation of the entity.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
to_dict()
¶
Returns the entity as a dictionary storing the value of the properties assigned to the entity.
RETURNS | DESCRIPTION |
---|---|
dict
|
The dictionary representation of the entity.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
to_hdf5(hdf_file, group_name='')
¶
Serialize the entity to a HDF5 file under the group specified in the input.
PARAMETER | DESCRIPTION |
---|---|
hdf_file
|
The HDF5 file to store the entity.
TYPE:
|
group_name
|
The group name to serialize the data.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
model_to_dict()
¶
Returns the model as a dictionary storing the data defs
and the property or vocabulary term
assignments.
RETURNS | DESCRIPTION |
---|---|
dict
|
The dictionary representation of the model.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
model_to_json(indent=None)
¶
Returns the model as a string in JSON format storing the data defs
and the property or
vocabulary term assignments.
PARAMETER | DESCRIPTION |
---|---|
indent
|
The indent to print in JSON. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The JSON representation of the model.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
model_to_rdf(namespace, graph, logger)
¶
Convert the entity to RDF triples and add them to the graph. The function uses the
_add_properties_rdf
method to convert the properties assigned to the entity to RDF triples.
PARAMETER | DESCRIPTION |
---|---|
namespace
|
The namespace to use for the RDF graph.
TYPE:
|
graph
|
The RDF graph to which the entity is added.
TYPE:
|
logger
|
The logger to log messages.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
ObjectType
¶
Bases: BaseEntity
Base class used to define object types. All object types must inherit from this class. The
object types are defined in the module bam_masterdata/object_types.py
.
The ObjectType
class contains a list of all properties
defined for a ObjectType
, for
internally represent the model in other formats (e.g., JSON or Excel).
Note this is also used for CollectionType
and DatasetType
, as they also contain a list of
properties.
Source code in bam_masterdata/metadata/entities.py
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 |
|
model_config = ConfigDict(ignored_types=(ObjectTypeDef, CollectionTypeDef, DatasetTypeDef, PropertyTypeAssignment))
¶
properties = Field(default=[], description='\n List of properties assigned to an object type. This is useful for internal representation of the model.\n ')
¶
base_name
¶
Returns the entity name of the class as a string.
__init__(**kwargs)
¶
Source code in bam_masterdata/metadata/entities.py
__setattr__(key, value)
¶
Source code in bam_masterdata/metadata/entities.py
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 |
|
get_vocabulary_class(vocabulary_code, vocab_path)
¶
Get the class instance of the vocabulary type defined by vocabulary_code
in the Python module
specified by vocab_path
.
PARAMETER | DESCRIPTION |
---|---|
vocabulary_code
|
Code of the vocabulary type to get.
TYPE:
|
vocab_path
|
Path to the module containing the vocabulary type definitions.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VocabularyType | None
|
VocabularyType | None: The class of the vocabulary type if found, otherwise None. |
Source code in bam_masterdata/metadata/entities.py
model_validator_after_init(data)
¶
Validate the model after instantiation of the class.
PARAMETER | DESCRIPTION |
---|---|
data
|
The data containing the fields values to validate.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The data with the validated fields.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
to_openbis(logger, openbis, type='object', type_map=OBJECT_TYPE_MAP)
¶
Source code in bam_masterdata/metadata/entities.py
CollectionType
¶
Bases: ObjectType
Source code in bam_masterdata/metadata/entities.py
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 963 964 965 966 967 968 969 970 971 972 973 974 975 |
|
model_config = ConfigDict(ignored_types=(ObjectTypeDef, ObjectType, CollectionTypeDef, PropertyTypeAssignment))
¶
attached_objects = Field(default={}, exclude=True, description='\n Dictionary containing the object types attached to the collection type.\n The keys are object unique identifiers and the values are the ObjectType instances.\n ')
¶
relationships = Field(default={}, exclude=True, description='\n Dictionary containing the relationships between the objects attached to the collection type.\n The keys are relationships unique identifiers, the values are the object unique identifiers as a\n tuple, and the order is always (parent_id, child_id).\n ')
¶
base_name
¶
Returns the entity name of the class as a string.
__repr__()
¶
to_openbis(logger, openbis, type='collection', type_map=COLLECTION_TYPE_MAP)
¶
Source code in bam_masterdata/metadata/entities.py
add(object_type)
¶
Add an object type to the collection type.
PARAMETER | DESCRIPTION |
---|---|
object_type
|
The object type to add to the collection type.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The unique identifier of the object type assigned in openBIS.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
remove(object_id='')
¶
Remove an object type from the collection type by its unique identifier.
PARAMETER | DESCRIPTION |
---|---|
object_id
|
The ID of the object type to be removed from the collection.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
add_relationship(parent_id, child_id)
¶
Add a relationship between two object types in the collection type.
PARAMETER | DESCRIPTION |
---|---|
parent_id
|
The unique identifier of the parent object type.
TYPE:
|
child_id
|
The unique identifier of the child object type.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The unique identifier of the relationship created, which is a concatenation of the parent
TYPE:
|
str
|
and child IDs. |
Source code in bam_masterdata/metadata/entities.py
remove_relationship(relationship_id)
¶
Remove a relationship from the collection type.
PARAMETER | DESCRIPTION |
---|---|
relationship_id
|
The unique identifier of the relationship to remove.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
DatasetType
¶
Bases: ObjectType
Source code in bam_masterdata/metadata/entities.py
base_name
¶
Returns the entity name of the class as a string.
to_openbis(logger, openbis, type='dataset', type_map=DATASET_TYPE_MAP)
¶
Source code in bam_masterdata/metadata/entities.py
VocabularyType
¶
Bases: BaseEntity
Base class used to define vocabulary types. All vocabulary types must inherit from this class. The
vocabulary types are defined in the module bam_masterdata/vocabulary_types.py
.
The VocabularyType
class contains a list of all terms
defined for a VocabularyType
, for
internally represent the model in other formats (e.g., JSON or Excel).
Source code in bam_masterdata/metadata/entities.py
model_config = ConfigDict(ignored_types=(VocabularyTypeDef, VocabularyTerm))
¶
terms = Field(default=[], description='\n List of vocabulary terms. This is useful for internal representation of the model.\n ')
¶
base_name
¶
Returns the entity name of the class as a string.
model_validator_after_init(data)
¶
Validate the model after instantiation of the class.
PARAMETER | DESCRIPTION |
---|---|
data
|
The data containing the fields values to validate.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The data with the validated fields.
TYPE:
|
Source code in bam_masterdata/metadata/entities.py
to_openbis(logger, openbis, type='vocabulary', type_map=VOCABULARY_TYPE_MAP)
¶
Source code in bam_masterdata/metadata/entities.py
bam_masterdata.metadata.definitions
¶
EntityDef
¶
Bases: BaseModel
Abstract base class for all masterdata entity definitions. The entity definitions are immutable properties.
This class provides a common interface (with common attributes like code
and
description
.) for all entity definitions.
Source code in bam_masterdata/metadata/definitions.py
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 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 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 179 180 181 182 183 184 185 186 187 188 |
|
code = Field(..., description="\n Code string identifying the entity with an openBIS inventory definition. Note that:\n\n - Must be uppercase and separated by underscores, e.g. `'EXPERIMENTAL_STEP'`.\n - If the entity is native to openBIS, the code must start with a dollar sign, e.g. `'$NAME'`.\n - In the case of inheritance, it needs to be separated by dots, e.g. `'WELDING_EQUIPMENT.INSTRUMENT'`.\n ")
¶
description = Field(..., description="\n Description of the entity. This is the human-readable text for the object and must be\n as complete and concise as possible. The German description can be added after the English\n description separated by a double slash (//), e.g. `'Chemical Substance//Chemische Substanz'`.\n ")
¶
iri = Field(default=None, description='\n IRI (Internationalized Resource Identifier) of the entity. This is a unique identifier for the entity\n and is used to link the entity to an ontology. It is a string with the format `"<ontology_id>:<ontology_version>"`.\n Example: "http://purl.obolibrary.org/bam-masterdata/Instrument:1.0.0".\n ')
¶
id = Field(default=None, description='\n Identifier of the entity defined as the class name and used to serialize the entity definitions\n in other formats.\n ')
¶
row_location = Field(default=None, description='\n Row in the Excel at which the entity type field is defined. It is a string with the format `"<row-letter><row_number>"`.\n Example: "A1" ot "A107". This field is useful when checking the consistency of Excel files with multiple entity\n types defined to quickly locate the specific Excel cell which logs a message when applying the `checker` CLI.\n ')
¶
name
¶
excel_name
¶
Returns the name of the entity in a format suitable for the openBIS Excel file.
excel_headers_map
¶
Maps the field keys of the Pydantic model into the openBIS Excel style headers.
validate_code(value)
¶
Source code in bam_masterdata/metadata/definitions.py
validate_iri(value)
¶
Source code in bam_masterdata/metadata/definitions.py
strip_description(value)
¶
model_id(data)
¶
Stores the model id
as the class name from the code
field.
PARAMETER | DESCRIPTION |
---|---|
data
|
The data containing the fields values to validate.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The data with the validated fields.
TYPE:
|
Source code in bam_masterdata/metadata/definitions.py
ObjectTypeDef
¶
Bases: BaseObjectTypeDef
Definition class for an object type. It adds the fields of generated_code_prefix
, auto_generate_codes
,
and validation_script
to the common attributes of a base object type definition. E.g.:
class Instrument(BaseModel):
defs = ObjectTypeDef(
code='INSTRUMENT',
description='
Measuring Instrument//Messgerät
',
generated_code_prefix='INS',
)
Source code in bam_masterdata/metadata/definitions.py
generated_code_prefix = Field(default=None, description="\n A short prefix for the defined object type, e.g. 'CHEM'. If not specified, it is defined\n using the first 3 characters of `code`.\n ")
¶
auto_generate_codes = Field(True, description='\n Boolean used to generate codes using `generated_code_prefix` plus a unique number. Set to\n True by default.\n ')
¶
model_validator_after_init(data)
¶
Validate the model after instantiation of the class.
PARAMETER | DESCRIPTION |
---|---|
data
|
The data containing the fields values to validate.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The data with the validated fields.
TYPE:
|
Source code in bam_masterdata/metadata/definitions.py
CollectionTypeDef
¶
DatasetTypeDef
¶
Bases: BaseObjectTypeDef
Definition class for a data set type. E.g.:
```python class RawData(BaseModel): defs = DatasetTypeDef( code='RAW_DATA', description='...', )
Source code in bam_masterdata/metadata/definitions.py
VocabularyTypeDef
¶
Bases: EntityDef
Definition class for a vocabulary type. It adds the fields of url_template
to the common attributes of
an entity definition. E.g.:
class DocumentType(VocabularyType):
defs = VocabularyTypeDef(
code='DOCUMENT_TYPE',
description='Document type//Dokumententypen',
)
Source code in bam_masterdata/metadata/definitions.py
url_template = Field(default=None, description='')
¶
PropertyTypeDef
¶
Bases: EntityDef
Definition class for a property type. It adds the fields of property_label
, data_type
,
vocabulary_code
, metadata
, dynamic_script
, and multivalued
to the common attributes of
an entity definition.
This class is used as an abstract layer for PropertyTypeAssignment
, as in openBIS a PropertyType
definition has less fields than when it is actually assigned to an entity type.
Source code in bam_masterdata/metadata/definitions.py
property_label = Field(..., description="\n Label that appears in the inventory view. This is the human-readable text for the property\n type definition, and it typically coincides with the `code`, e.g., `'Monitoring date'` for the\n `MONITORING_DATE` property type.\n ")
¶
data_type = Field(..., description='\n The data type of the property, i.e., if it is an integer, float, string, etc. The allowed\n data types in openBIS are:\n - `BOOLEAN`\n - `CONTROLLEDVOCABULARY`\n - `DATE`\n - `HYPERLINK`\n - `INTEGER`\n - `MATERIAL`\n - `MULTILINE_VARCHAR`\n - `OBJECT`\n - `SAMPLE`\n - `REAL`\n - `TIMESTAMP`\n - `VARCHAR`\n - `XML`\n\n These are defined as an enumeration in the `DataType` class.\n\n Read more in https://openbis.readthedocs.io/en/latest/uncategorized/register-master-data-via-the-admin-interface.html#data-types-available-in-openbis.\n ')
¶
vocabulary_code = Field(default=None, description="\n String identifying the controlled vocabulary used for the data type of the property. This is\n thus only relevant if `data_type == 'CONTROLLEDVOCABULARY'`.\n ")
¶
object_code = Field(default=None, description="\n String identifying the object type used for the data type of the property. This is only\n relevant if `data_type == 'OBJECT'`.\n ")
¶
metadata = Field(default=None, description="\n General metadata written in a dictionary format. This is used to store additional information\n about the property type, e.g., `{'unit': 'm', 'precision': 2}`.\n ")
¶
dynamic_script = Field(default=None, description='')
¶
PropertyTypeAssignment
¶
Bases: PropertyTypeDef
Base class used to define properties inside ObjectType
, CollectionType
, or DatasetType
.
This is used to construct these types by assigning property types to them. It adds the fields
of mandatory
, show_in_edit_views
, section
, unique
, and internal_assignment
to the common
attributes of a property type definition. E.g.:
class Instrument(ObjectType):
defs = ObjectTypeDef(
code='INSTRUMENT',
description='
Measuring Instrument//Messgerät
',
generated_code_prefix='INS',
)
alias = PropertyTypeAssignment(
code='ALIAS',
data_type='VARCHAR',
property_label='Alternative name',
description='
e.g. abbreviation or nickname//z.B. Abkürzung oder Spitzname//z.B. Abkürzung oder Spitzname
',
mandatory=False,
show_in_edit_views=True,
section='General information',
)
# ... other property type assignments here ...
Source code in bam_masterdata/metadata/definitions.py
mandatory = Field(..., description='\n If `True`, the property is mandatory and has to be set during instantiation of the object type.\n If `False`, the property is optional.\n ')
¶
show_in_edit_views = Field(..., description='\n If `True`, the property is shown in the edit views of the ELN in the object type instantiation.\n If `False`, the property is hidden.\n ')
¶
section = Field(..., description="\n Section to which the property type belongs to. E.g., `'General Information'`.\n ")
¶
unique = Field(default=None, description='')
¶
internal_assignment = Field(default=None, description='')
¶
VocabularyTerm
¶
Bases: VocabularyTypeDef
Base class used to define terms inside a VocabularyType
. This is used to construct the vocabulary types
by assigning vocabulary terms to them. It adds the fields of label
and official
to the common attributes
of a vocabulary type definition. E.g.:
```python class DocumentType(VocabularyType): defs = VocabularyTypeDef( code='DOCUMENT_TYPE', description='Document type//Dokumententypen', )
acceptance_certificate = VocabularyTerm(
code='ACCEPTANCE_CERTIFICATE',
label='Acceptance Certificate',
description='Acceptance Certificate//Abnahmezeugnis',
)
calibration_certificate = VocabularyTerm(
code='CALIBRATION_CERTIFICATE',
label='Calibration Certificate',
description='Calibration Certificate//Kalibrierschein',
)
# ... other vocabulary term definitions here ...
Source code in bam_masterdata/metadata/definitions.py
bam_masterdata.metadata.entities_dict
¶
EntitiesDict
¶
Class to convert the entities in the datamodel defined in Python to a dictionary. The entities are read from the Python
files defined in python_path
.
Source code in bam_masterdata/metadata/entities_dict.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 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 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 |
|
python_path = python_path
¶
logger = kwargs.get('logger', logger)
¶
data = {}
¶
__init__(python_path='', **kwargs)
¶
to_dict(module_path)
¶
Returns a dictionary containing entities read from the module_path
Python file. The Python modules
are imported using the function import_module
and their contents are inspected (using inspect
) to
find the classes in the datamodel containing defs
and with a model_to_dict
method defined.
PARAMETER | DESCRIPTION |
---|---|
module_path
|
Path to the Python module file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the entities in the datamodel defined in one Python module file.
TYPE:
|
Source code in bam_masterdata/metadata/entities_dict.py
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 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 |
|
single_json()
¶
Returns a single dictionary containing all the entities in the datamodel defined in the Python files
in python_path
. The format of this dictionary is:
{
"collection_type": {
"COLLECTION": {
"defs": {
"code": "COLLECTION",
"description": "",
...
},
"properties": [
{
"code": "$DEFAULT_COLLECTION_VIEW",
"description": "Default view for experiments of the type collection",
...
},
{...},
...
]
}
},
"object_type": {...},
...
}
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing all the entities in the datamodel.
TYPE:
|
Source code in bam_masterdata/metadata/entities_dict.py
bam_masterdata.cli.fill_masterdata
¶
MasterdataCodeGenerator
¶
Class to generate Python code for the masterdata datamodel based on the entities existing in an openBIS instance.
Source code in bam_masterdata/cli/fill_masterdata.py
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 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 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 179 180 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 213 214 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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
row_cell_info = kwargs.get('row_cell_info', False)
¶
generator_type = 'openbis'
¶
properties = OpenbisEntities(url=url).get_property_dict()
¶
collections = OpenbisEntities(url=url).get_collection_dict()
¶
datasets = OpenbisEntities(url=url).get_dataset_dict()
¶
objects = OpenbisEntities(url=url).get_object_dict()
¶
vocabularies = OpenbisEntities(url=url).get_vocabulary_dict()
¶
__init__(url='', path='', **kwargs)
¶
Source code in bam_masterdata/cli/fill_masterdata.py
determine_parent_class(code, class_names, default, lines)
¶
Determine the parent class information of the entity based on its code
. It returns
the parent_code
and parent class
, as well as the class_name
of the entity. The
class will inherit from parent_class
.
If the parent class does not exist, a note is added to the lines
list for debugging purposes.
PARAMETER | DESCRIPTION |
---|---|
code
|
The code of the entity.
TYPE:
|
class_names
|
A dictionary with the class names of the entities.
TYPE:
|
default
|
The default parent class if the parent class does not exist.
TYPE:
|
lines
|
A list of strings to be printed to the Python module.
TYPE:
|
Returns: tuple: The parent code, parent class, and class name of the entity.
Source code in bam_masterdata/cli/fill_masterdata.py
get_property_object_code(prop_data)
¶
Get the object code (or vocabulary code) used for reference for the assigned property with prop_code
.
PARAMETER | DESCRIPTION |
---|---|
prop_data
|
The data information for the property as obtained from openBIS.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The object/vocabulary code used for reference for the assigned property.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
add_properties(entities, parent_code, data, lines)
¶
Add the properties of the entity to the lines
list. The properties are added as
PropertyTypeAssignment
objects.
Note: the assigned properties do not have the information of code
for the entity when
data_type is OBJECT or CONTROLLEDVOCABULARY. These are instead defined in property_types.py
.
PARAMETER | DESCRIPTION |
---|---|
entities
|
The dictionary of entities (objects, collections, datasets, vocabularies).
TYPE:
|
parent_code
|
The code of the parent class.
TYPE:
|
data
|
The data information for the entity as obtained from openBIS.
TYPE:
|
lines
|
A list of strings to be printed to the Python module.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
generate_collection_types()
¶
Generate Python code for the collection types in the Openbis datamodel. The code is generated
as a string which is then printed out to the specific Python module in bam_masterdata/datamodel/collection_types.py
.
RETURNS | DESCRIPTION |
---|---|
str
|
Python code for the collection types.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
generate_dataset_types()
¶
Generate Python code for the dataset types in the Openbis datamodel. The code is generated
as a string which is then printed out to the specific Python module in bam_masterdata/datamodel/dataset_types.py
.
RETURNS | DESCRIPTION |
---|---|
str
|
Python code for the dataset types.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
generate_object_types()
¶
Generate Python code for the object types in the Openbis datamodel. The code is generated
as a string which is then printed out to the specific Python module in bam_masterdata/datamodel/object_types.py
.
RETURNS | DESCRIPTION |
---|---|
str
|
Python code for the object types.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
generate_vocabulary_types()
¶
Generate Python code for the vocabulary types in the Openbis datamodel. The code is generated
as a string which is then printed out to the specific Python module in bam_masterdata/datamodel/vocabulary_types.py
.
RETURNS | DESCRIPTION |
---|---|
str
|
Python code for the vocabulary types.
TYPE:
|
Source code in bam_masterdata/cli/fill_masterdata.py
342 343 344 345 346 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 |
|
bam_masterdata.cli.excel_to_entities
¶
MasterdataExcelExtractor
¶
Source code in bam_masterdata/cli/excel_to_entities.py
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 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 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 179 180 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 213 214 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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
VALIDATION_RULES = {}
¶
excel_path = excel_path
¶
row_cell_info = kwargs.get('row_cell_info', False)
¶
workbook = openpyxl.load_workbook(excel_path)
¶
logger = kwargs.get('logger', logger)
¶
__init__(excel_path, **kwargs)
¶
Initialize the MasterdataExtractor.
Source code in bam_masterdata/cli/excel_to_entities.py
index_to_excel_column(index)
¶
Converts a 1-based index to an Excel column name.
PARAMETER | DESCRIPTION |
---|---|
index
|
The 1-based index to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The corresponding Excel column name. |
Source code in bam_masterdata/cli/excel_to_entities.py
get_last_non_empty_row(sheet, start_index)
¶
Finds the last non-empty row before encountering a completely empty row.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index
|
The row number to start checking from (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int | None
|
The row number of the last non-empty row before an empty row is encountered, |
int | None
|
or None if no non-empty rows are found starting from the given index. |
Source code in bam_masterdata/cli/excel_to_entities.py
str_to_bool(value, term, coordinate, sheet_title)
¶
Converts a string to a boolean value.
PARAMETER | DESCRIPTION |
---|---|
value
|
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
The boolean value. |
Source code in bam_masterdata/cli/excel_to_entities.py
get_and_check_property(value, term, coordinate, sheet_title, is_description=False, is_code=False, is_data=False, is_url=False)
¶
Gets a property and checks its format.
PARAMETER | DESCRIPTION |
---|---|
value
|
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The property. |
Source code in bam_masterdata/cli/excel_to_entities.py
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
process_term(term, cell_value, coordinate, sheet_title)
¶
Processes a term by converting it to a boolean if necessary or checking its validity.
PARAMETER | DESCRIPTION |
---|---|
term
|
The term being processed.
TYPE:
|
cell_value
|
The value of the cell.
TYPE:
|
coordinate
|
The coordinate of the cell in the sheet.
TYPE:
|
sheet_title
|
The title of the sheet.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The processed value, either as a boolean or the original value after validation. |
Source code in bam_masterdata/cli/excel_to_entities.py
extract_value(sheet, row, column, validation_pattern=None, is_description=False, is_data=False, is_url=False)
¶
Extracts and validates a value from a specified cell in the Excel sheet.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
row
|
The row number of the cell (1-based index).
TYPE:
|
column
|
The column number of the cell (1-based index).
TYPE:
|
validation_pattern
|
Optional regex pattern to validate the cell value.
TYPE:
|
is_description
|
Flag indicating if the value is a description.
TYPE:
|
is_data
|
Flag indicating if the value is a data type.
TYPE:
|
is_url
|
Flag indicating if the value is a URL.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The extracted and validated cell value as a string. Returns an empty string if the value is invalid or not provided. |
Source code in bam_masterdata/cli/excel_to_entities.py
process_entity(sheet, start_index_row, header_terms, expected_terms, entity_type)
¶
Process an entity type block in the Excel sheet and return its attributes as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
The row where the current entity type begins (1-based index).
TYPE:
|
header_terms
|
List of header terms in the entity block.
TYPE:
|
expected_terms
|
List of expected terms to extract from the entity block.
TYPE:
|
entity_type
|
The type of the entity (e.g., SAMPLE_TYPE, OBJECT_TYPE).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
A dictionary containing the attributes of the entity. |
Source code in bam_masterdata/cli/excel_to_entities.py
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
properties_to_dict(sheet, start_index_row, last_non_empty_row)
¶
Extracts properties from an Entity type block in the Excel sheet and returns them as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
Row where the current entity type begins (1-based index).
TYPE:
|
last_non_empty_row
|
Row where the current entity type finish (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
A dictionary where each key is a property code and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the attributes of the property. |
Source code in bam_masterdata/cli/excel_to_entities.py
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 |
|
terms_to_dict(sheet, start_index_row, last_non_empty_row)
¶
Extracts terms from a Vocabulary block in the Excel sheet and returns them as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
Row where the current entity type begins (1-based index).
TYPE:
|
last_non_empty_row
|
Row where the current entity type finish (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
A dictionary where each key is a vocabulary term code and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the attributes of the vocabulary term. |
Source code in bam_masterdata/cli/excel_to_entities.py
block_to_entity_dict(sheet, start_index_row, last_non_empty_row, complete_dict)
¶
Extracts entity attributes from an Excel sheet block and returns them as a dictionary.
Source code in bam_masterdata/cli/excel_to_entities.py
excel_to_entities()
¶
Extracts entities from an Excel file and returns them as a dictionary.
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
dict[str, dict[str, Any]]: A dictionary where each key is a normalized sheet name and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the extracted entities. Returns an empty dictionary if all sheets are empty. |
Source code in bam_masterdata/cli/excel_to_entities.py
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 |
|
bam_masterdata.cli.entities_to_excel
¶
entities_to_excel(worksheet, module_path, definitions_module)
¶
Export entities to the Excel file. The Python modules are imported using the function import_module
,
and their contents are inspected (using inspect
) to find the classes in the datamodel containing
defs
and with a model_to_json
method defined. Each row is then appended to the worksheet
.
PARAMETER | DESCRIPTION |
---|---|
worksheet
|
The worksheet to append the entities.
TYPE:
|
module_path
|
Path to the Python module file.
TYPE:
|
definitions_module
|
The module containing the definitions of the entities. This is used to match the header definitions of the entities.
TYPE:
|
Source code in bam_masterdata/cli/entities_to_excel.py
bam_masterdata.cli.entities_to_rdf
¶
BAM = Namespace('https://bamresearch.github.io/bam-masterdata/#')
¶
PROV = Namespace('http://www.w3.org/ns/prov#')
¶
rdf_graph_init(g)
¶
Initialize the RDF graph with base namespaces, annotation properties, and internal BAM properties. This
function also creates placeholders for PropertyType and other entity types. The graph is to be printed out
in RDF/XML format in the entities_to_rdf
function.
PARAMETER | DESCRIPTION |
---|---|
g
|
The RDF graph to be initialized.
TYPE:
|
Source code in bam_masterdata/cli/entities_to_rdf.py
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 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 139 140 141 142 143 144 145 146 147 148 |
|
entities_to_rdf(graph, module_path, logger)
¶
Convert the entities defined in the specified module to RDF triples and add them to the graph. The function
uses the model_to_rdf
method defined in each class to convert the class attributes to RDF triples. The
function also adds the PropertyType and other entity types as placeholders in the graph.
PARAMETER | DESCRIPTION |
---|---|
graph
|
The RDF graph to which the entities are added.
TYPE:
|
module_path
|
The path to the module containing the entities to be converted.
TYPE:
|
logger
|
The logger to log messages.
TYPE:
|
Source code in bam_masterdata/cli/entities_to_rdf.py
bam_masterdata.excel.excel_to_entities
¶
MasterdataExcelExtractor
¶
Source code in bam_masterdata/excel/excel_to_entities.py
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 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 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 179 180 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 213 214 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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
VALIDATION_RULES = {}
¶
excel_path = excel_path
¶
row_cell_info = kwargs.get('row_cell_info', False)
¶
workbook = openpyxl.load_workbook(excel_path)
¶
logger = kwargs.get('logger', logger)
¶
__init__(excel_path, **kwargs)
¶
Initialize the MasterdataExtractor.
Source code in bam_masterdata/excel/excel_to_entities.py
index_to_excel_column(index)
¶
Converts a 1-based index to an Excel column name.
PARAMETER | DESCRIPTION |
---|---|
index
|
The 1-based index to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The corresponding Excel column name. |
Source code in bam_masterdata/excel/excel_to_entities.py
get_last_non_empty_row(sheet, start_index)
¶
Finds the last non-empty row before encountering a completely empty row.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index
|
The row number to start checking from (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int | None
|
The row number of the last non-empty row before an empty row is encountered, |
int | None
|
or None if no non-empty rows are found starting from the given index. |
Source code in bam_masterdata/excel/excel_to_entities.py
str_to_bool(value, term, coordinate, sheet_title)
¶
Converts a string to a boolean value.
PARAMETER | DESCRIPTION |
---|---|
value
|
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
The boolean value. |
Source code in bam_masterdata/excel/excel_to_entities.py
get_and_check_property(value, term, coordinate, sheet_title, is_description=False, is_code=False, is_data=False, is_url=False)
¶
Gets a property and checks its format.
PARAMETER | DESCRIPTION |
---|---|
value
|
The string to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The property. |
Source code in bam_masterdata/excel/excel_to_entities.py
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
process_term(term, cell_value, coordinate, sheet_title)
¶
Processes a term by converting it to a boolean if necessary or checking its validity.
PARAMETER | DESCRIPTION |
---|---|
term
|
The term being processed.
TYPE:
|
cell_value
|
The value of the cell.
TYPE:
|
coordinate
|
The coordinate of the cell in the sheet.
TYPE:
|
sheet_title
|
The title of the sheet.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
The processed value, either as a boolean or the original value after validation. |
Source code in bam_masterdata/excel/excel_to_entities.py
extract_value(sheet, row, column, validation_pattern=None, is_description=False, is_data=False, is_url=False)
¶
Extracts and validates a value from a specified cell in the Excel sheet.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
row
|
The row number of the cell (1-based index).
TYPE:
|
column
|
The column number of the cell (1-based index).
TYPE:
|
validation_pattern
|
Optional regex pattern to validate the cell value.
TYPE:
|
is_description
|
Flag indicating if the value is a description.
TYPE:
|
is_data
|
Flag indicating if the value is a data type.
TYPE:
|
is_url
|
Flag indicating if the value is a URL.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The extracted and validated cell value as a string. Returns an empty string if the value is invalid or not provided. |
Source code in bam_masterdata/excel/excel_to_entities.py
process_entity(sheet, start_index_row, header_terms, expected_terms, entity_type)
¶
Process an entity type block in the Excel sheet and return its attributes as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
The row where the current entity type begins (1-based index).
TYPE:
|
header_terms
|
List of header terms in the entity block.
TYPE:
|
expected_terms
|
List of expected terms to extract from the entity block.
TYPE:
|
entity_type
|
The type of the entity (e.g., SAMPLE_TYPE, OBJECT_TYPE).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
A dictionary containing the attributes of the entity. |
Source code in bam_masterdata/excel/excel_to_entities.py
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
properties_to_dict(sheet, start_index_row, last_non_empty_row)
¶
Extracts properties from an Entity type block in the Excel sheet and returns them as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
Row where the current entity type begins (1-based index).
TYPE:
|
last_non_empty_row
|
Row where the current entity type finish (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
A dictionary where each key is a property code and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the attributes of the property. |
Source code in bam_masterdata/excel/excel_to_entities.py
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 |
|
terms_to_dict(sheet, start_index_row, last_non_empty_row)
¶
Extracts terms from a Vocabulary block in the Excel sheet and returns them as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
sheet
|
The worksheet object.
TYPE:
|
start_index_row
|
Row where the current entity type begins (1-based index).
TYPE:
|
last_non_empty_row
|
Row where the current entity type finish (1-based index).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
A dictionary where each key is a vocabulary term code and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the attributes of the vocabulary term. |
Source code in bam_masterdata/excel/excel_to_entities.py
block_to_entity_dict(sheet, start_index_row, last_non_empty_row, complete_dict)
¶
Extracts entity attributes from an Excel sheet block and returns them as a dictionary.
Source code in bam_masterdata/excel/excel_to_entities.py
excel_to_entities()
¶
Extracts entities from an Excel file and returns them as a dictionary.
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, Any]]
|
dict[str, dict[str, Any]]: A dictionary where each key is a normalized sheet name and the value is a dictionary |
dict[str, dict[str, Any]]
|
containing the extracted entities. Returns an empty dictionary if all sheets are empty. |
Source code in bam_masterdata/excel/excel_to_entities.py
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 |
|
bam_masterdata.openbis.login
¶
ologin(url='')
¶
Connect to openBIS using the credentials stored in the environment variables.
PARAMETER | DESCRIPTION |
---|---|
url
|
The URL of the openBIS instance. Defaults to the value of the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Openbis
|
Openbis object for the specific openBIS instance defined in
TYPE:
|
Source code in bam_masterdata/openbis/login.py
bam_masterdata.openbis.get_entities
¶
OpenbisEntities
¶
Class to get openBIS entities and their attributes as dictionaries to be printed in the
Python modules of bam_masterdata/datamodel/
.
Source code in bam_masterdata/openbis/get_entities.py
4 5 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 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 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
openbis = ologin(url=url)
¶
__init__(url='')
¶
get_property_dict()
¶
Get the property types from openBIS and return them as a dictionary where the keys
are the property type code
and the value is a dictionary of attributes assigned to that
property type.
RETURNS | DESCRIPTION |
---|---|
dict
|
Dictionary of property types with their attributes.
TYPE:
|
Source code in bam_masterdata/openbis/get_entities.py
get_collection_dict()
¶
Get the collection types from openBIS and return them as a dictionary where the keys
are the collection type code
and the value is a dictionary of attributes assigned to that
collection type.
RETURNS | DESCRIPTION |
---|---|
dict
|
Dictionary of collection types with their attributes.
TYPE:
|
Source code in bam_masterdata/openbis/get_entities.py
get_dataset_dict()
¶
Get the dataset types from openBIS and return them as a dictionary where the keys
are the dataset type code
and the value is a dictionary of attributes assigned to that
dataset type.
RETURNS | DESCRIPTION |
---|---|
dict
|
Dictionary of dataset types with their attributes.
TYPE:
|
Source code in bam_masterdata/openbis/get_entities.py
get_object_dict()
¶
Get the object types from openBIS and return them as a dictionary where the keys
are the object type code
and the value is a dictionary of attributes assigned to that
object type.
RETURNS | DESCRIPTION |
---|---|
dict
|
Dictionary of object types with their attributes.
TYPE:
|
Source code in bam_masterdata/openbis/get_entities.py
get_vocabulary_dict()
¶
Get the vocabulary types from openBIS and return them as a dictionary where the keys
are the vocabulary type code
and the value is a dictionary of attributes assigned to that
vocabulary type.
RETURNS | DESCRIPTION |
---|---|
dict
|
Dictionary of vocabulary types with their attributes.
TYPE:
|
Source code in bam_masterdata/openbis/get_entities.py
bam_masterdata.checker.checker
¶
MasterdataChecker
¶
Source code in bam_masterdata/checker/checker.py
VALID_MODES = {'self', 'incoming', 'validate', 'compare', 'all', 'individual'}
¶
current_model = None
¶
new_entities = None
¶
logger = logger
¶
validation_rules = {}
¶
__init__()
¶
Initialize the comparator with validation rules and set the datamodel directory.
load_current_model(datamodel_dir='./bam_masterdata/datamodel/')
¶
Load and transform the current data model (Pydantic classes) into JSON.
Uses the default datamodel directory unless overridden.
Source code in bam_masterdata/checker/checker.py
load_new_entities(source)
¶
Load new entities from various sources (Python classes, Excel, etc.).
Source code in bam_masterdata/checker/checker.py
check(mode='all')
¶
Run validations.
Modes: - "self" -> Validate only the current data model. - "incoming" -> Validate only the new entity structure. - "validate" -> Validate both the current model and new entities. - "compare" -> Compare new entities against the current model. - "all" -> Run both validation types. - "individual" -> Run individual repositories validations.
Before running, ensure that required models are loaded based on the mode.
RETURNS | DESCRIPTION |
---|---|
dict
|
Validation results.
TYPE:
|
Source code in bam_masterdata/checker/checker.py
bam_masterdata.checker.masterdata_validator
¶
MasterdataValidator
¶
Source code in bam_masterdata/checker/masterdata_validator.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 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 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 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 179 180 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 213 214 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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 |
|
new_entities = new_entities
¶
current_model = current_model
¶
validation_rules = validation_rules
¶
logger = logger
¶
log_msgs = []
¶
validation_results = {}
¶
__init__(new_entities, current_model, validation_rules)
¶
Initialize the validator with new and current entity data.
PARAMETER | DESCRIPTION |
---|---|
new_entities
|
The incoming datamodel.
TYPE:
|
current_model
|
The existing datamodel.
TYPE:
|
validation_rules
|
The validation rules to apply.
TYPE:
|
Source code in bam_masterdata/checker/masterdata_validator.py
validate(mode='all')
¶
Run validations based on mode: - "self": Validate current model structure and format. - "incoming": Validate new entities structure and format. - "validate": Validate both current and incoming models but do not compare. - "compare": Validate new entities against the current model. - "all": Run both. - "individual": Validate new entities and compare them with the current model.
Returns: dict: Validation results.
Source code in bam_masterdata/checker/masterdata_validator.py
extract_property_codes(data)
¶
Source code in bam_masterdata/checker/masterdata_validator.py
bam_masterdata.checker.source_loader
¶
SourceLoader
¶
Load the entities from a source written in different formats (Python classes, Excel, etc.) as defined
in the source_path
into a dictionary.
Source code in bam_masterdata/checker/source_loader.py
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 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
source_path = source_path
¶
logger = kwargs.get('logger', logger)
¶
row_cell_info = kwargs.get('row_cell_info', True)
¶
source_type = 'python'
¶
__init__(source_path, **kwargs)
¶
Source code in bam_masterdata/checker/source_loader.py
load()
¶
Load entities from the source path into a dictionary.
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the entities.
TYPE:
|
Source code in bam_masterdata/checker/source_loader.py
entities_to_json()
¶
Transforms the dictionary of entities returned by the Excel extractor into a dictionary in JSON format for later check.
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the transformed entities.
TYPE:
|
Source code in bam_masterdata/checker/source_loader.py
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 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
bam_masterdata.parsing.parsing
¶
AbstractParser
¶
Bases: ABC
Example Abstract base class for parsers. Each parser should inherit from this class and implement
the parse()
method to populate collection
.
Source code in bam_masterdata/parsing/parsing.py
parse(files, collection, logger)
¶
Parse the input files
and populate the provided collection
with object types, their metadata,
and their relationships.
PARAMETER | DESCRIPTION |
---|---|
files
|
List of file paths to be parsed.
TYPE:
|
collection
|
Collection to be populated with parsed data.
TYPE:
|
logger
|
Logger for logging messages during parsing.
TYPE:
|
Source code in bam_masterdata/parsing/parsing.py
bam_masterdata.utils.utils
¶
delete_and_create_dir(directory_path, logger=logger, force_delete=False)
¶
Deletes the directory at directory_path
and creates a new one in the same path.
PARAMETER | DESCRIPTION |
---|---|
directory_path
|
The directory path to delete and create the folder.
TYPE:
|
logger
|
The logger to log messages. Default is
TYPE:
|
force_delete
|
If True, the directory will be forcibly deleted if it exists.
TYPE:
|
Source code in bam_masterdata/utils/utils.py
listdir_py_modules(directory_path, logger=logger)
¶
Recursively goes through the directory_path
and returns a list of all .py files that do not start with '_'. If
directory_path
is a single Python module file, it will return a list with that file.
PARAMETER | DESCRIPTION |
---|---|
directory_path
|
The directory path to search through.
TYPE:
|
logger
|
The logger to log messages. Default is
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str]
|
list[str]: A list of all .py files that do not start with '_' |
Source code in bam_masterdata/utils/utils.py
import_module(module_path)
¶
Dynamically imports a module from the given file path.
PARAMETER | DESCRIPTION |
---|---|
module_path
|
Path to the Python module file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
module
|
Imported module object.
TYPE:
|
Source code in bam_masterdata/utils/utils.py
code_to_class_name(code, logger=logger, entity_type='object')
¶
Converts an openBIS code
to a class name by capitalizing each word and removing special characters. In
the special case the entity is a property type, it retains the full name separated by points instead of
only keeping the last name (e.g., "TEM.INSTRUMENT" -> "TemInstrument" instead of "Instrument").
PARAMETER | DESCRIPTION |
---|---|
code
|
The openBIS code to convert to a class name.
TYPE:
|
logger
|
The logger to log messages. Default is
TYPE:
|
entity_type
|
The type of entity to convert. Default is "object".
TYPE:
|
Returns: str: The class name derived from the openBIS code.
Source code in bam_masterdata/utils/utils.py
load_validation_rules(logger, file_path=os.path.join(VALIDATION_RULES_DIR, 'validation_rules.json'))
¶
Source code in bam_masterdata/utils/utils.py
duplicated_property_types(module_path, logger)
¶
Find the duplicated property types in a module specified by module_path
and returns a dictionary
containing the duplicated property types class names as keys and the lines where they matched as values.
PARAMETER | DESCRIPTION |
---|---|
module_path
|
The path to the module containing the property types.
TYPE:
|
logger
|
The logger to log messages.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary containing the duplicated property types class names as keys and the
TYPE:
|
dict
|
lines where they matched as values. |
Source code in bam_masterdata/utils/utils.py
format_json_id(value)
¶
Converts snake_case or UPPER_CASE to PascalCase while keeping special cases like '$NAME' untouched.
Source code in bam_masterdata/utils/utils.py
convert_enums(obj)
¶
Source code in bam_masterdata/utils/utils.py
is_reduced_version(generated_code_value, code)
¶
Check if generated_code_value is a reduced version of code.
PARAMETER | DESCRIPTION |
---|---|
generated_code_value
|
The potentially reduced code.
TYPE:
|
code
|
The original full code.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if generated_code_value is a reduced version of code, False otherwise.
TYPE:
|
Source code in bam_masterdata/utils/utils.py
store_log_message(logger, entity_ref, message, level='error')
¶
Logs a message and stores it inside the entity's _log_msgs list.
PARAMETER | DESCRIPTION |
---|---|
entity_ref
|
The entity dictionary where _log_msgs should be stored.
TYPE:
|
message
|
The log message.
TYPE:
|
level
|
Log level ('error', 'warning', 'critical', 'info').
TYPE:
|
Source code in bam_masterdata/utils/utils.py
bam_masterdata.utils.paths
¶
DIRECTORIES = {'datamodel': [Path.cwd() / 'datamodel', Path.cwd() / 'bam_masterdata' / 'datamodel', Path(__file__).parent.parent / 'datamodel'], 'validation_rules_checker': [Path.cwd() / 'bam_masterdata' / 'checker' / 'validation_rules', Path(__file__).parent.parent / 'checker' / 'validation_rules']}
¶
DATAMODEL_DIR = find_dir(possible_locations=(DIRECTORIES['datamodel']))
¶
VALIDATION_RULES_DIR = find_dir(possible_locations=(DIRECTORIES['validation_rules_checker']))
¶
find_dir(possible_locations)
¶
Search for a valid directory in a list of possible locations.
PARAMETER | DESCRIPTION |
---|---|
possible_locations
|
A list of possible locations to search for a directory.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
FileNotFoundError
|
If no valid directory is found. |
RETURNS | DESCRIPTION |
---|---|
str
|
The path of the valid directory.
TYPE:
|