bam-masterdata 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/PKG-INFO +1 -1
  2. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/_version.py +2 -2
  3. bam_masterdata-0.3.1/bam_masterdata/checker/__init__.py +1 -0
  4. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/checker.py +17 -2
  5. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/masterdata_validator.py +3 -2
  6. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/cli/cli.py +49 -37
  7. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/cli/entities_to_rdf.py +1 -1
  8. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/utils/__init__.py +1 -0
  9. bam_masterdata-0.3.1/bam_masterdata/utils/paths.py +43 -0
  10. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/utils/utils.py +2 -1
  11. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/PKG-INFO +1 -1
  12. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/SOURCES.txt +2 -0
  13. bam_masterdata-0.3.1/tests/utils/test_paths.py +14 -0
  14. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/utils/test_utils.py +1 -0
  15. bam_masterdata-0.3.0/bam_masterdata/checker/__init__.py +0 -1
  16. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.coveragerc +0 -0
  17. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.github/workflows/actions.yml +0 -0
  18. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.github/workflows/coveralls.yml +0 -0
  19. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.github/workflows/mkdocs-deploy.yml +0 -0
  20. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.github/workflows/publish.yml +0 -0
  21. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.gitignore +0 -0
  22. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/.vscode/settings.json +0 -0
  23. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/LICENSE +0 -0
  24. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/README.md +0 -0
  25. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/__init__.py +0 -0
  26. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/source_loader.py +0 -0
  27. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/validation_rules/all_validation_rules.json +0 -0
  28. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/validation_rules/excel_validation_rules.json +0 -0
  29. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/checker/validation_rules/validation_rules.json +0 -0
  30. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/cli/__init__.py +0 -0
  31. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/cli/entities_to_excel.py +0 -0
  32. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/cli/fill_masterdata.py +0 -0
  33. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/datamodel/__init__.py +0 -0
  34. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/datamodel/collection_types.py +0 -0
  35. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/datamodel/dataset_types.py +0 -0
  36. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/datamodel/object_types.py +0 -0
  37. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/datamodel/vocabulary_types.py +0 -0
  38. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/excel/__init__.py +0 -0
  39. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/excel/excel_to_entities.py +0 -0
  40. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/logger.py +0 -0
  41. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/metadata/__init__.py +0 -0
  42. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/metadata/definitions.py +0 -0
  43. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/metadata/entities.py +0 -0
  44. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/metadata/entities_dict.py +0 -0
  45. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/openbis/__init__.py +0 -0
  46. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/openbis/get_entities.py +0 -0
  47. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/openbis/login.py +0 -0
  48. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/validation_rules/excel_validation_rules.json +0 -0
  49. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata/validation_rules/validation_rules.json +0 -0
  50. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/dependency_links.txt +0 -0
  51. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/entry_points.txt +0 -0
  52. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/requires.txt +0 -0
  53. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/bam_masterdata.egg-info/top_level.txt +0 -0
  54. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/bammasterdata_blue_transparent.png +0 -0
  55. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/bammasterdata_blue_transparent_text.png +0 -0
  56. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/bammasterdata_blue_transparent_text.svg +0 -0
  57. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/bammasterdata_blue_white.png +0 -0
  58. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/bammasterdata_blue_white_text.png +0 -0
  59. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/datastore-logo-white.png +0 -0
  60. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/datastore-logo.png +0 -0
  61. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/drawio/checker-structure.drawio +0 -0
  62. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/drawio/masterdata-workflow.drawio +0 -0
  63. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/drawio/masterdata-workflow.drawio.png +0 -0
  64. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/fonts/BAMKlavika-Light.ttf +0 -0
  65. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/fonts/BAMKlavika-LightItalic.ttf +0 -0
  66. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/fonts/BAMKlavika-Medium.ttf +0 -0
  67. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/assets/fonts/BAMKlavika-MediumItalic.ttf +0 -0
  68. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/explanations/data-store.md +0 -0
  69. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/explanations/openbis.md +0 -0
  70. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/explanations/pybis.md +0 -0
  71. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/overview.md +0 -0
  72. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/collections.md +0 -0
  73. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/datasets.md +0 -0
  74. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/objects.md +0 -0
  75. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/objects_props.md +0 -0
  76. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/parent_child.md +0 -0
  77. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/projects.md +0 -0
  78. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/searches.md +0 -0
  79. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/setup.md +0 -0
  80. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/howtos/pybis/spaces.md +0 -0
  81. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/index.md +0 -0
  82. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/references/collection.md +0 -0
  83. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/references/controlled-vocabulary.md +0 -0
  84. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/references/dataset.md +0 -0
  85. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/stylesheets/extra.css +0 -0
  86. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/tutorials/create-masterdata.md +0 -0
  87. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/docs/tutorials/pybis.md +0 -0
  88. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/mkdocs.yml +0 -0
  89. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/pyproject.toml +0 -0
  90. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/scripts/install_python_dependencies.sh +0 -0
  91. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/scripts/pkg_size.py +0 -0
  92. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/setup.cfg +0 -0
  93. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/setup.py +0 -0
  94. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/__init__.py +0 -0
  95. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/checker/test_source_loader.py +0 -0
  96. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/cli/test_entities_to_excel.py +0 -0
  97. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/cli/test_entities_to_rdf.py +0 -0
  98. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/conftest.py +0 -0
  99. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/datamodel_test/collection_types.py +0 -0
  100. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/datamodel_test/dataset_types.py +0 -0
  101. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/datamodel_test/object_types.py +0 -0
  102. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example01_codedoesnoteexists.xlsx +0 -0
  103. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example02_codeexists_proptype_datatypechanged.xlsx +0 -0
  104. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example03_codeexists_proptype_contvoccodechanged.xlsx +0 -0
  105. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example04_codeexists_proptype_objectcodechanged.xlsx +0 -0
  106. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example05_codeexists_proptype_warningdefschanged.xlsx +0 -0
  107. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example06_codeexists_proptype_vocobjcodemiss.xlsx +0 -0
  108. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example07_codeexists_objtype_warningdefschanged.xlsx +0 -0
  109. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example08_codeexists_objtype_assignprop_listcodeschanged_add.xlsx +0 -0
  110. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example09_codeexists_objtype_assignprop_listcodeschanged_del.xlsx +0 -0
  111. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example10_codeexists_objtype_assignprop_codedoesnotexists.xlsx +0 -0
  112. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example11_codeexists_objtype_assignprop_listcodeschanged_datatypechanged.xlsx +0 -0
  113. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example12_codeexists_objtype_assignprop_listcodeschanged_warningdefschanged.xlsx +0 -0
  114. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example13_codeexists_objtype_assignprop_coincide2objects.xlsx +0 -0
  115. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example_incoming_excel.xlsx +0 -0
  116. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example_incoming_python/collection_types.py +0 -0
  117. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example_incoming_python/dataset_types.py +0 -0
  118. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/example_incoming_python/object_types.py +0 -0
  119. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/masterdata_example.xlsx +0 -0
  120. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/masterdata_excel_output.json +0 -0
  121. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/checker/masterdata_python_output.json +0 -0
  122. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/utils/example_prop_types_1.py +0 -0
  123. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/data/utils/example_prop_types_2.py +0 -0
  124. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/excel/test_excel_to_entities.py +0 -0
  125. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/metadata/test_definitions.py +0 -0
  126. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/metadata/test_entities.py +0 -0
  127. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/metadata/test_entities_dict.py +0 -0
  128. {bam_masterdata-0.3.0 → bam_masterdata-0.3.1}/tests/test_logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bam-masterdata
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: The BAM Data Store utility tools and masterdata models wrapped in a Python package with a front-end web interface.
5
5
  Author-email: BAM Data Store <datastore@bam.de>
6
6
  Maintainer-email: "Jose M. Pizarro" <jose.pizarro-blanco@bam.de>
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.3.0'
21
- __version_tuple__ = version_tuple = (0, 3, 0)
20
+ __version__ = version = '0.3.1'
21
+ __version_tuple__ = version_tuple = (0, 3, 1)
@@ -0,0 +1 @@
1
+ from .checker import MasterdataChecker, no_validation_errors
@@ -1,5 +1,3 @@
1
- import os
2
-
3
1
  from bam_masterdata.checker.masterdata_validator import MasterdataValidator
4
2
  from bam_masterdata.checker.source_loader import SourceLoader
5
3
  from bam_masterdata.logger import logger
@@ -47,6 +45,7 @@ class MasterdataChecker:
47
45
  - "validate" -> Validate both the current model and new entities.
48
46
  - "compare" -> Compare new entities against the current model.
49
47
  - "all" -> Run both validation types.
48
+ - "individual" -> Run individual repositories validations.
50
49
 
51
50
  Before running, ensure that required models are loaded based on the mode.
52
51
 
@@ -84,3 +83,19 @@ class MasterdataChecker:
84
83
  self.new_entities, self.current_model, self.validation_rules
85
84
  )
86
85
  return validator.validate(mode)
86
+
87
+
88
+ def no_validation_errors(validation_results: dict) -> bool:
89
+ """
90
+ Check if there are no validation errors in the results.
91
+
92
+ Args:
93
+ validation_results (dict): The dictionary containing the specific validation results.
94
+
95
+ Returns:
96
+ bool: True if there are no validation errors, False otherwise.
97
+ """
98
+
99
+ if not isinstance(validation_results, dict):
100
+ return False
101
+ return all(no_validation_errors(v) for v in validation_results.values())
@@ -30,6 +30,7 @@ class MasterdataValidator:
30
30
  - "validate": Validate both current and incoming models but do not compare.
31
31
  - "compare": Validate new entities against the current model.
32
32
  - "all": Run both.
33
+ - "individual": Validate new entities and compare them with the current model.
33
34
 
34
35
  Returns:
35
36
  dict: Validation results.
@@ -568,10 +569,10 @@ class MasterdataValidator:
568
569
  codes.add(property_item["code"])
569
570
  # Recursively check for more nested structures
570
571
  elif isinstance(value, (dict, list)):
571
- codes.extend(self.extract_property_codes(value))
572
+ codes.update(self.extract_property_codes(value))
572
573
 
573
574
  elif isinstance(data, list):
574
575
  for item in data:
575
- codes.extend(self.extract_property_codes(item))
576
+ codes.update(self.extract_property_codes(item))
576
577
 
577
578
  return codes
@@ -9,13 +9,14 @@ from decouple import config as environ
9
9
  from openpyxl import Workbook
10
10
  from rdflib import Graph
11
11
 
12
- from bam_masterdata.checker import MasterdataChecker
12
+ from bam_masterdata.checker import MasterdataChecker, no_validation_errors
13
13
  from bam_masterdata.cli.entities_to_excel import entities_to_excel
14
14
  from bam_masterdata.cli.entities_to_rdf import entities_to_rdf
15
15
  from bam_masterdata.cli.fill_masterdata import MasterdataCodeGenerator
16
16
  from bam_masterdata.logger import logger
17
17
  from bam_masterdata.metadata.entities_dict import EntitiesDict
18
18
  from bam_masterdata.utils import (
19
+ DATAMODEL_DIR,
19
20
  delete_and_create_dir,
20
21
  duplicated_property_types,
21
22
  import_module,
@@ -23,27 +24,6 @@ from bam_masterdata.utils import (
23
24
  )
24
25
 
25
26
 
26
- def find_datamodel_dir():
27
- """Search for 'datamodel/' in possible locations and return its absolute path."""
28
- possible_locations = [
29
- # Case: Running from a project with `datamodel/`
30
- Path.cwd() / "datamodel",
31
- # Case: Running inside bam-masterdata
32
- Path.cwd() / "bam_masterdata" / "datamodel",
33
- # Case: Running inside installed package
34
- Path(__file__).parent.parent / "datamodel",
35
- ]
36
-
37
- for path in possible_locations:
38
- if path.exists():
39
- return str(path.resolve())
40
-
41
- raise FileNotFoundError("Could not find a valid 'datamodel/' directory.")
42
-
43
-
44
- DATAMODEL_DIR = find_datamodel_dir()
45
-
46
-
47
27
  @click.group(help="Entry point to run `bam_masterdata` CLI commands.")
48
28
  def cli():
49
29
  pass
@@ -389,7 +369,8 @@ def export_to_rdf(force_delete, python_path, export_dir):
389
369
  "--mode",
390
370
  "mode", # alias
391
371
  type=click.Choice(
392
- ["self", "incoming", "validate", "compare", "all"], case_sensitive=False
372
+ ["self", "incoming", "validate", "compare", "all", "individual"],
373
+ case_sensitive=False,
393
374
  ),
394
375
  default="all",
395
376
  help="""Specify the mode for the checker. Options are:
@@ -397,7 +378,8 @@ def export_to_rdf(force_delete, python_path, export_dir):
397
378
  "incoming" -> Validate only the new entity structure.
398
379
  "validate" -> Validate both the current model and new entities.
399
380
  "compare" -> Compare new entities against the current model.
400
- "all" -> Run all validations and comparison. (Default)""",
381
+ "all" -> Run all validations and comparison. (Default).
382
+ "individual" -> Run individual repositories validations.""",
401
383
  )
402
384
  @click.option(
403
385
  "--datamodel-path",
@@ -420,27 +402,57 @@ def checker(file_path, mode, datamodel_path):
420
402
  validation_results = checker.check(mode=mode)
421
403
 
422
404
  # Check if there are problems with the current model
423
- if mode in ["self", "all", "validate"] and validation_results.get("current_model"):
424
- click.echo(
425
- "There are problems in the current model that need to be solved" #: {validation_results['current_model']}"
426
- )
405
+ if mode in ["self", "all", "validate"] and validation_results.get(
406
+ "current_model", {}
407
+ ):
408
+ for entity, errors in validation_results.get("current_model", {}).items():
409
+ if errors:
410
+ click.echo(
411
+ f"There are problems in the current model for entity {entity} that need to be solved"
412
+ )
413
+ click.echo(f"Errors: {errors}")
427
414
 
428
415
  # Check if there are problems with the incoming model
429
416
  if mode in ["incoming", "all", "validate"] and validation_results.get(
430
- "incoming_model"
417
+ "incoming_model", {}
431
418
  ):
432
- click.echo(
433
- f"There are problems in the incoming model located in {file_path} that need to be solved" #: {validation_results['incoming_model']}"
434
- )
419
+ for entity, errors in validation_results.get("incoming_model", {}).items():
420
+ if errors:
421
+ click.echo(
422
+ f"There are problems in the incoming model in {file_path} for entity {entity} that need to be solved"
423
+ )
424
+ click.echo(f"Errors: {errors}")
435
425
 
436
426
  # Check if there are comparison problems
437
- if mode in ["compare", "all"] and validation_results.get("comparisons"):
438
- click.echo(
439
- f"There are problems when checking the incoming model located in {file_path} against the current data model that need to be solved" #: {validation_results['comparisons']}"
440
- )
427
+ if mode in ["compare", "all"] and validation_results.get("comparisons", {}):
428
+ for entity, errors in validation_results.get("comparisons", {}).items():
429
+ if errors:
430
+ click.echo(
431
+ f"There are problems when checking the incoming model in {file_path} against the current model {datamodel_path} for entity {entity} that need to be solved"
432
+ )
433
+ click.echo(f"Errors: {errors}")
434
+
435
+ # Check if there are individual repository problems
436
+ if (
437
+ mode in ["individual"]
438
+ and validation_results.get("incoming_model", {})
439
+ and validation_results.get("comparisons", {})
440
+ ):
441
+ for entity, errors in validation_results.get("individual", {}).items():
442
+ if errors:
443
+ click.echo(
444
+ f"There are problems in the individual repositories when validating them for entity {entity} that need to be solved"
445
+ )
446
+ click.echo(f"Errors: {errors}")
447
+ for entity, errors in validation_results.get("comparisons", {}).items():
448
+ if errors:
449
+ click.echo(
450
+ f"There are problems in the individual repositories when comparing them with respect to bam-masterdata for entity {entity} that need to be solved"
451
+ )
452
+ click.echo(f"Errors: {errors}")
441
453
 
442
454
  # Check if no problems were found
443
- if all(value == {} for value in validation_results.values()):
455
+ if no_validation_errors(validation_results):
444
456
  click.echo("No problems found in the datamodel and incoming model.")
445
457
 
446
458
 
@@ -11,7 +11,7 @@ from rdflib.namespace import DC, OWL, RDF, RDFS
11
11
 
12
12
  from bam_masterdata.utils import import_module
13
13
 
14
- BAM = Namespace("https://bamresearch.github.io/bam-masterdata/")
14
+ BAM = Namespace("https://bamresearch.github.io/bam-masterdata/#")
15
15
  PROV = Namespace("http://www.w3.org/ns/prov#")
16
16
 
17
17
 
@@ -1,3 +1,4 @@
1
+ from .paths import DATAMODEL_DIR, VALIDATION_RULES_DIR, find_dir
1
2
  from .utils import (
2
3
  code_to_class_name,
3
4
  convert_enums,
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def find_dir(possible_locations: list[Path]) -> str:
5
+ """
6
+ Search for a valid directory in a list of possible locations.
7
+
8
+ Args:
9
+ possible_locations (list[Path]): A list of possible locations to search for a directory.
10
+
11
+ Raises:
12
+ FileNotFoundError: If no valid directory is found.
13
+
14
+ Returns:
15
+ str: The path of the valid directory.
16
+ """
17
+ for path in possible_locations:
18
+ if path.exists():
19
+ return str(path.resolve())
20
+
21
+ raise FileNotFoundError("Could not find a valid directory.")
22
+
23
+
24
+ DIRECTORIES = {
25
+ "datamodel": [
26
+ # Case: Running from a project with `datamodel/`
27
+ Path.cwd() / "datamodel",
28
+ # Case: Running inside bam-masterdata
29
+ Path.cwd() / "bam_masterdata" / "datamodel",
30
+ # Case: Running inside installed package
31
+ Path(__file__).parent.parent / "datamodel",
32
+ ],
33
+ "validation_rules_checker": [
34
+ Path.cwd() / "bam_masterdata" / "checker" / "validation_rules",
35
+ Path(__file__).parent.parent / "checker" / "validation_rules",
36
+ ],
37
+ }
38
+
39
+
40
+ DATAMODEL_DIR = find_dir(possible_locations=DIRECTORIES["datamodel"])
41
+ VALIDATION_RULES_DIR = find_dir(
42
+ possible_locations=DIRECTORIES["validation_rules_checker"]
43
+ )
@@ -10,6 +10,7 @@ from itertools import chain
10
10
  from typing import TYPE_CHECKING, Any, Optional
11
11
 
12
12
  from bam_masterdata.logger import logger
13
+ from bam_masterdata.utils import VALIDATION_RULES_DIR
13
14
 
14
15
  if TYPE_CHECKING:
15
16
  from structlog._config import BoundLoggerLazyProxy
@@ -142,7 +143,7 @@ def code_to_class_name(
142
143
 
143
144
  def load_validation_rules(
144
145
  logger: "BoundLoggerLazyProxy",
145
- file_path: str = "./bam_masterdata/checker/validation_rules/validation_rules.json",
146
+ file_path: str = os.path.join(VALIDATION_RULES_DIR, "validation_rules.json"),
146
147
  ):
147
148
  if not os.path.exists(file_path):
148
149
  logger.error(f"Validation rules file not found: {file_path}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bam-masterdata
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: The BAM Data Store utility tools and masterdata models wrapped in a Python package with a front-end web interface.
5
5
  Author-email: BAM Data Store <datastore@bam.de>
6
6
  Maintainer-email: "Jose M. Pizarro" <jose.pizarro-blanco@bam.de>
@@ -46,6 +46,7 @@ bam_masterdata/openbis/__init__.py
46
46
  bam_masterdata/openbis/get_entities.py
47
47
  bam_masterdata/openbis/login.py
48
48
  bam_masterdata/utils/__init__.py
49
+ bam_masterdata/utils/paths.py
49
50
  bam_masterdata/utils/utils.py
50
51
  bam_masterdata/validation_rules/excel_validation_rules.json
51
52
  bam_masterdata/validation_rules/validation_rules.json
@@ -120,4 +121,5 @@ tests/excel/test_excel_to_entities.py
120
121
  tests/metadata/test_definitions.py
121
122
  tests/metadata/test_entities.py
122
123
  tests/metadata/test_entities_dict.py
124
+ tests/utils/test_paths.py
123
125
  tests/utils/test_utils.py
@@ -0,0 +1,14 @@
1
+ from pathlib import Path
2
+
3
+ from bam_masterdata.utils import DATAMODEL_DIR, VALIDATION_RULES_DIR, find_dir
4
+
5
+
6
+ def test_find_dir():
7
+ assert find_dir(possible_locations=[Path.cwd()]) == str(Path.cwd())
8
+
9
+
10
+ def test_default_dirs():
11
+ assert DATAMODEL_DIR == str(Path.cwd() / "bam_masterdata" / "datamodel")
12
+ assert VALIDATION_RULES_DIR == str(
13
+ Path.cwd() / "bam_masterdata" / "checker" / "validation_rules"
14
+ )
@@ -74,6 +74,7 @@ def test_delete_and_create_dir(
74
74
  (
75
75
  "./tests/utils",
76
76
  [
77
+ "./tests/utils/test_paths.py",
77
78
  "./tests/utils/test_utils.py",
78
79
  ],
79
80
  None,
@@ -1 +0,0 @@
1
- from .checker import MasterdataChecker
File without changes
File without changes
File without changes
File without changes