pyegeria 5.3.9.9.3__py3-none-any.whl → 5.5.3.3__py3-none-any.whl

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.

Potentially problematic release.


This version of pyegeria might be problematic. Click here for more details.

Files changed (272) hide show
  1. commands/__init__.py +24 -0
  2. commands/cat/Dr-Egeria_md-orig.py +2 -2
  3. commands/cat/__init__.py +1 -17
  4. commands/cat/collection_actions.py +197 -0
  5. commands/cat/dr_egeria_command_help.py +372 -0
  6. commands/cat/dr_egeria_jupyter.py +7 -7
  7. commands/cat/dr_egeria_md.py +27 -182
  8. commands/cat/exp_list_glossaries.py +11 -14
  9. commands/cat/get_asset_graph.py +37 -267
  10. commands/cat/{get_collection.py → get_collection_tree.py} +10 -18
  11. commands/cat/get_project_dependencies.py +14 -14
  12. commands/cat/get_project_structure.py +15 -14
  13. commands/cat/get_tech_type_elements.py +16 -116
  14. commands/cat/glossary_actions.py +145 -298
  15. commands/cat/list_assets.py +3 -11
  16. commands/cat/list_cert_types.py +17 -63
  17. commands/cat/list_collections.py +46 -138
  18. commands/cat/list_deployed_catalogs.py +15 -27
  19. commands/cat/list_deployed_database_schemas.py +27 -43
  20. commands/cat/list_deployed_databases.py +16 -31
  21. commands/cat/list_deployed_servers.py +35 -54
  22. commands/cat/list_glossaries.py +18 -17
  23. commands/cat/list_projects.py +10 -12
  24. commands/cat/list_tech_type_elements.py +21 -37
  25. commands/cat/list_tech_types.py +13 -25
  26. commands/cat/list_terms.py +38 -79
  27. commands/cat/list_todos.py +4 -11
  28. commands/cat/list_user_ids.py +3 -10
  29. commands/cat/my_reports.py +559 -0
  30. commands/cat/run_report.py +394 -0
  31. commands/cat/run_report_orig.py +528 -0
  32. commands/cli/egeria.py +222 -247
  33. commands/cli/egeria_cat.py +68 -81
  34. commands/cli/egeria_my.py +13 -0
  35. commands/cli/egeria_ops.py +69 -74
  36. commands/cli/egeria_tech.py +17 -93
  37. commands/cli/ops_config.py +3 -6
  38. commands/{cat/list_categories.py → deprecated/list_data_designer.py} +53 -64
  39. commands/{cat/list_data_structures.py → deprecated/list_data_structures_full.py} +3 -6
  40. commands/deprecated/old_get_asset_graph.py +315 -0
  41. commands/my/__init__.py +0 -2
  42. commands/my/list_my_profile.py +27 -34
  43. commands/my/list_my_roles.py +1 -7
  44. commands/my/monitor_my_todos.py +1 -7
  45. commands/my/monitor_open_todos.py +6 -7
  46. commands/my/todo_actions.py +4 -5
  47. commands/ops/__init__.py +0 -2
  48. commands/ops/gov_server_actions.py +17 -21
  49. commands/ops/list_archives.py +17 -38
  50. commands/ops/list_catalog_targets.py +33 -40
  51. commands/ops/load_archive.py +35 -26
  52. commands/ops/{monitor_engine_activity_c.py → monitor_active_engine_activity.py} +51 -82
  53. commands/ops/{monitor_integ_daemon_status.py → monitor_daemon_status.py} +35 -55
  54. commands/ops/monitor_engine_activity.py +79 -77
  55. commands/ops/{monitor_gov_eng_status.py → monitor_engine_status.py} +10 -7
  56. commands/ops/monitor_platform_status.py +38 -50
  57. commands/ops/monitor_server_startup.py +6 -11
  58. commands/ops/monitor_server_status.py +7 -11
  59. commands/ops/orig_monitor_server_list.py +8 -8
  60. commands/ops/orig_monitor_server_status.py +1 -5
  61. commands/ops/refresh_integration_daemon.py +5 -5
  62. commands/ops/restart_integration_daemon.py +5 -5
  63. commands/ops/table_integ_daemon_status.py +6 -6
  64. commands/ops/x_engine_actions.py +7 -7
  65. commands/tech/__init__.py +0 -2
  66. commands/tech/{generic_actions.py → element_actions.py} +6 -11
  67. commands/tech/get_element_info.py +20 -29
  68. commands/tech/get_guid_info.py +23 -42
  69. commands/tech/get_tech_details.py +20 -35
  70. commands/tech/get_tech_type_template.py +28 -39
  71. commands/tech/list_all_om_type_elements.py +24 -30
  72. commands/tech/list_all_om_type_elements_x.py +22 -28
  73. commands/tech/list_all_related_elements.py +19 -28
  74. commands/tech/list_anchored_elements.py +22 -30
  75. commands/tech/list_asset_types.py +19 -24
  76. commands/tech/list_elements_by_classification_by_property_value.py +26 -32
  77. commands/tech/list_elements_by_property_value.py +19 -25
  78. commands/tech/list_elements_by_property_value_x.py +20 -28
  79. commands/tech/list_elements_for_classification.py +28 -41
  80. commands/tech/list_gov_action_processes.py +16 -27
  81. commands/tech/list_information_supply_chains.py +22 -30
  82. commands/tech/list_registered_services.py +14 -26
  83. commands/tech/list_related_elements_with_prop_value.py +15 -25
  84. commands/tech/list_related_specification.py +1 -4
  85. commands/tech/list_relationship_types.py +15 -25
  86. commands/tech/list_relationships.py +20 -36
  87. commands/tech/list_solution_blueprints.py +28 -33
  88. commands/tech/list_solution_components.py +23 -29
  89. commands/tech/list_solution_roles.py +21 -32
  90. commands/tech/list_tech_templates.py +51 -54
  91. commands/tech/list_valid_metadata_values.py +5 -9
  92. commands/tech/table_tech_templates.py +2 -6
  93. commands/tech/x_list_related_elements.py +1 -4
  94. examples/GeoSpatial Products Example.py +524 -0
  95. examples/Jupyter Notebooks/P-egeria-server-config.ipynb +2137 -0
  96. examples/Jupyter Notebooks/README.md +2 -0
  97. examples/Jupyter Notebooks/common/P-environment-check.ipynb +115 -0
  98. examples/Jupyter Notebooks/common/__init__.py +14 -0
  99. examples/Jupyter Notebooks/common/common-functions.ipynb +4694 -0
  100. examples/Jupyter Notebooks/common/environment-check.ipynb +52 -0
  101. examples/Jupyter Notebooks/common/globals.ipynb +184 -0
  102. examples/Jupyter Notebooks/common/globals.py +154 -0
  103. examples/Jupyter Notebooks/common/orig_globals.py +152 -0
  104. examples/format_sets/all_format_sets.json +910 -0
  105. examples/format_sets/custom_format_sets.json +268 -0
  106. examples/format_sets/subset_format_sets.json +187 -0
  107. examples/format_sets_save_load_example.py +291 -0
  108. examples/jacquard_data_sets.py +129 -0
  109. examples/output_formats_example.py +193 -0
  110. examples/test_jacquard_data_sets.py +54 -0
  111. examples/test_jacquard_data_sets_scenarios.py +94 -0
  112. md_processing/__init__.py +90 -0
  113. md_processing/command_dispatcher.py +33 -0
  114. md_processing/command_mapping.py +221 -0
  115. md_processing/data/commands/commands_data_designer.json +537 -0
  116. md_processing/data/commands/commands_external_reference.json +733 -0
  117. md_processing/data/commands/commands_feedback.json +155 -0
  118. md_processing/data/commands/commands_general.json +204 -0
  119. md_processing/data/commands/commands_glossary.json +218 -0
  120. md_processing/data/commands/commands_governance.json +3678 -0
  121. md_processing/data/commands/commands_product_manager.json +865 -0
  122. md_processing/data/commands/commands_project.json +642 -0
  123. md_processing/data/commands/commands_solution_architect.json +366 -0
  124. md_processing/data/commands.json +17568 -0
  125. md_processing/data/commands_working.json +30641 -0
  126. md_processing/data/gened_report_specs.py +6584 -0
  127. md_processing/data/generated_format_sets.json +6533 -0
  128. md_processing/data/generated_format_sets_old.json +4137 -0
  129. md_processing/data/generated_format_sets_old.py +45 -0
  130. md_processing/dr_egeria.py +182 -0
  131. md_processing/md_commands/__init__.py +3 -0
  132. md_processing/md_commands/data_designer_commands.py +1276 -0
  133. md_processing/md_commands/ext_ref_commands.py +530 -0
  134. md_processing/md_commands/feedback_commands.py +726 -0
  135. md_processing/md_commands/glossary_commands.py +684 -0
  136. md_processing/md_commands/governance_officer_commands.py +600 -0
  137. md_processing/md_commands/product_manager_commands.py +1266 -0
  138. md_processing/md_commands/project_commands.py +383 -0
  139. md_processing/md_commands/solution_architect_commands.py +1184 -0
  140. md_processing/md_commands/view_commands.py +295 -0
  141. md_processing/md_processing_utils/__init__.py +4 -0
  142. md_processing/md_processing_utils/common_md_proc_utils.py +1249 -0
  143. md_processing/md_processing_utils/common_md_utils.py +578 -0
  144. md_processing/md_processing_utils/determine_width.py +103 -0
  145. md_processing/md_processing_utils/extraction_utils.py +547 -0
  146. md_processing/md_processing_utils/gen_report_specs.py +643 -0
  147. md_processing/md_processing_utils/generate_dr_help.py +193 -0
  148. md_processing/md_processing_utils/generate_md_cmd_templates.py +144 -0
  149. md_processing/md_processing_utils/generate_md_templates.py +83 -0
  150. md_processing/md_processing_utils/md_processing_constants.py +1228 -0
  151. md_processing/md_processing_utils/message_constants.py +19 -0
  152. pyegeria/__init__.py +201 -443
  153. pyegeria/core/__init__.py +40 -0
  154. pyegeria/core/_base_platform_client.py +574 -0
  155. pyegeria/core/_base_server_client.py +573 -0
  156. pyegeria/core/_exceptions.py +457 -0
  157. pyegeria/core/_globals.py +60 -0
  158. pyegeria/core/_server_client.py +6073 -0
  159. pyegeria/core/_validators.py +257 -0
  160. pyegeria/core/config.py +654 -0
  161. pyegeria/{create_tech_guid_lists.py → core/create_tech_guid_lists.py} +0 -1
  162. pyegeria/core/load_config.py +37 -0
  163. pyegeria/core/logging_configuration.py +207 -0
  164. pyegeria/core/mcp_adapter.py +144 -0
  165. pyegeria/core/mcp_server.py +212 -0
  166. pyegeria/core/utils.py +405 -0
  167. pyegeria/deprecated/__init__.py +0 -0
  168. pyegeria/{_client.py → deprecated/_client.py} +62 -24
  169. pyegeria/{_deprecated_gov_engine.py → deprecated/_deprecated_gov_engine.py} +16 -16
  170. pyegeria/{classification_manager_omvs.py → deprecated/classification_manager_omvs.py} +1988 -1878
  171. pyegeria/deprecated/output_formatter_with_machine_keys.py +1127 -0
  172. pyegeria/{runtime_manager_omvs.py → deprecated/runtime_manager_omvs.py} +216 -229
  173. pyegeria/{valid_metadata_omvs.py → deprecated/valid_metadata_omvs.py} +93 -93
  174. pyegeria/{x_action_author_omvs.py → deprecated/x_action_author_omvs.py} +2 -3
  175. pyegeria/egeria_cat_client.py +25 -51
  176. pyegeria/egeria_client.py +140 -98
  177. pyegeria/egeria_config_client.py +48 -24
  178. pyegeria/egeria_tech_client.py +170 -83
  179. pyegeria/models/__init__.py +150 -0
  180. pyegeria/models/collection_models.py +168 -0
  181. pyegeria/models/models.py +654 -0
  182. pyegeria/omvs/__init__.py +84 -0
  183. pyegeria/omvs/action_author.py +342 -0
  184. pyegeria/omvs/actor_manager.py +5980 -0
  185. pyegeria/omvs/asset_catalog.py +842 -0
  186. pyegeria/omvs/asset_maker.py +2736 -0
  187. pyegeria/omvs/automated_curation.py +4403 -0
  188. pyegeria/omvs/classification_manager.py +11213 -0
  189. pyegeria/omvs/collection_manager.py +5780 -0
  190. pyegeria/omvs/community_matters_omvs.py +468 -0
  191. pyegeria/{core_omag_server_config.py → omvs/core_omag_server_config.py} +157 -157
  192. pyegeria/{data_designer_omvs.py → omvs/data_designer.py} +1991 -1691
  193. pyegeria/omvs/data_discovery.py +869 -0
  194. pyegeria/omvs/data_engineer.py +372 -0
  195. pyegeria/omvs/digital_business.py +1133 -0
  196. pyegeria/omvs/external_links.py +1752 -0
  197. pyegeria/omvs/feedback_manager.py +834 -0
  198. pyegeria/{full_omag_server_config.py → omvs/full_omag_server_config.py} +73 -69
  199. pyegeria/omvs/glossary_manager.py +3231 -0
  200. pyegeria/omvs/governance_officer.py +3009 -0
  201. pyegeria/omvs/lineage_linker.py +314 -0
  202. pyegeria/omvs/location_arena.py +1525 -0
  203. pyegeria/omvs/metadata_expert.py +668 -0
  204. pyegeria/omvs/metadata_explorer_omvs.py +2943 -0
  205. pyegeria/omvs/my_profile.py +1042 -0
  206. pyegeria/omvs/notification_manager.py +358 -0
  207. pyegeria/omvs/people_organizer.py +394 -0
  208. pyegeria/{platform_services.py → omvs/platform_services.py} +113 -193
  209. pyegeria/omvs/product_manager.py +1825 -0
  210. pyegeria/omvs/project_manager.py +1907 -0
  211. pyegeria/omvs/reference_data.py +1140 -0
  212. pyegeria/omvs/registered_info.py +334 -0
  213. pyegeria/omvs/runtime_manager.py +2817 -0
  214. pyegeria/omvs/schema_maker.py +446 -0
  215. pyegeria/{server_operations.py → omvs/server_operations.py} +27 -26
  216. pyegeria/omvs/solution_architect.py +6490 -0
  217. pyegeria/omvs/specification_properties.py +37 -0
  218. pyegeria/omvs/subject_area.py +1042 -0
  219. pyegeria/omvs/template_manager_omvs.py +236 -0
  220. pyegeria/omvs/time_keeper.py +1761 -0
  221. pyegeria/omvs/valid_metadata.py +3221 -0
  222. pyegeria/omvs/valid_metadata_lists.py +37 -0
  223. pyegeria/omvs/valid_type_lists.py +37 -0
  224. pyegeria/view/__init__.py +28 -0
  225. pyegeria/view/_output_format_models.py +514 -0
  226. pyegeria/view/_output_formats.py +14 -0
  227. pyegeria/view/base_report_formats.py +2719 -0
  228. pyegeria/view/dr_egeria_reports.py +56 -0
  229. pyegeria/view/format_set_executor.py +397 -0
  230. pyegeria/{md_processing_utils.py → view/md_processing_utils.py} +5 -5
  231. pyegeria/{mermaid_utilities.py → view/mermaid_utilities.py} +2 -154
  232. pyegeria/view/output_formatter.py +1297 -0
  233. pyegeria-5.5.3.3.dist-info/METADATA +218 -0
  234. pyegeria-5.5.3.3.dist-info/RECORD +241 -0
  235. {pyegeria-5.3.9.9.3.dist-info → pyegeria-5.5.3.3.dist-info}/WHEEL +2 -1
  236. pyegeria-5.5.3.3.dist-info/entry_points.txt +103 -0
  237. pyegeria-5.5.3.3.dist-info/top_level.txt +4 -0
  238. commands/cat/.DS_Store +0 -0
  239. commands/cat/README.md +0 -16
  240. commands/cli/txt_custom_v2.tcss +0 -19
  241. commands/my/README.md +0 -17
  242. commands/ops/README.md +0 -24
  243. commands/ops/monitor_asset_events.py +0 -108
  244. commands/tech/README.md +0 -24
  245. pyegeria/.DS_Store +0 -0
  246. pyegeria/README.md +0 -35
  247. pyegeria/_globals.py +0 -47
  248. pyegeria/_validators.py +0 -385
  249. pyegeria/asset_catalog_omvs.py +0 -864
  250. pyegeria/automated_curation_omvs.py +0 -3765
  251. pyegeria/collection_manager_omvs.py +0 -2744
  252. pyegeria/dr.egeria spec.md +0 -9
  253. pyegeria/egeria_my_client.py +0 -56
  254. pyegeria/feedback_manager_omvs.py +0 -4573
  255. pyegeria/glossary_browser_omvs.py +0 -3728
  256. pyegeria/glossary_manager_omvs.py +0 -2440
  257. pyegeria/m_test.py +0 -118
  258. pyegeria/md_processing_helpers.py +0 -58
  259. pyegeria/md_processing_utils_orig.py +0 -1103
  260. pyegeria/metadata_explorer_omvs.py +0 -2326
  261. pyegeria/my_profile_omvs.py +0 -1022
  262. pyegeria/output_formatter.py +0 -389
  263. pyegeria/project_manager_omvs.py +0 -1933
  264. pyegeria/registered_info.py +0 -167
  265. pyegeria/solution_architect_omvs.py +0 -2156
  266. pyegeria/template_manager_omvs.py +0 -1414
  267. pyegeria/utils.py +0 -197
  268. pyegeria-5.3.9.9.3.dist-info/METADATA +0 -72
  269. pyegeria-5.3.9.9.3.dist-info/RECORD +0 -143
  270. pyegeria-5.3.9.9.3.dist-info/entry_points.txt +0 -99
  271. /pyegeria/{_exceptions.py → deprecated/_exceptions.py} +0 -0
  272. {pyegeria-5.3.9.9.3.dist-info → pyegeria-5.5.3.3.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,37 @@
1
+ """
2
+ Compatibility shim for legacy imports.
3
+ Re-exports configuration loading utilities from pyegeria.config.
4
+ """
5
+ # Import config lazily inside functions to avoid import-time side effects in tests
6
+ from importlib import import_module
7
+
8
+ def load_app_config(env_file: str | None = None):
9
+ return import_module('pyegeria.config').load_app_config(env_file)
10
+
11
+ def get_app_config(env_file: str | None = None):
12
+ return import_module('pyegeria.config').get_app_config(env_file)
13
+
14
+ class PyegeriaSettings:
15
+ def __new__(cls, *args, **kwargs):
16
+ # Construct a real settings instance from pyegeria.config
17
+ return import_module('pyegeria.config').PyegeriaSettings(*args, **kwargs)
18
+
19
+ @classmethod
20
+ def with_env_file(cls, env_file: str):
21
+ return import_module('pyegeria.config').PyegeriaSettings.with_env_file(env_file)
22
+
23
+ # expose the cached instance for tests that reset it directly
24
+ from pyegeria.core import config as _config
25
+
26
+
27
+ def __getattr__(name):
28
+ if name == "_app_config":
29
+ return _config._app_config
30
+ raise AttributeError(name)
31
+
32
+
33
+ def __setattr__(name, value):
34
+ if name == "_app_config":
35
+ _config._app_config = value
36
+ else:
37
+ globals()[name] = value
@@ -0,0 +1,207 @@
1
+
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+ This module configures logging using loguru. The pyegeria library modules do not configure
7
+ loguru automatically so that the calling application has control over the logging. However, if the
8
+ calling application doesn't have its own logging setup, it can use this module to configure loguru logging.
9
+
10
+ If the application uses another logging library, such as the built-in python logging, it can
11
+ do so by redirecting loguru output. Here is an example:
12
+
13
+ # application.py - App uses standard logging, redirects Loguru)
14
+
15
+ import logging
16
+ import logging.config
17
+ import sys # For sys.stderr
18
+ from loguru import logger # Import Loguru's logger
19
+ from my_library.my_module import MyLibraryClass, library_function
20
+
21
+ # --- Standard Logging Configuration (for the application) ---
22
+ # This is your application's primary logging setup.
23
+ LOGGING_CONFIG = {
24
+ "version": 1,
25
+ "disable_existing_loggers": False,
26
+ "formatters": {
27
+ "standard": {
28
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
29
+ }
30
+ },
31
+ "handlers": {
32
+ "console": {
33
+ "class": "logging.StreamHandler",
34
+ "level": "INFO",
35
+ "formatter": "standard",
36
+ "stream": "ext://sys.stdout"
37
+ },
38
+ "file": {
39
+ "class": "logging.handlers.RotatingFileHandler",
40
+ "level": "DEBUG",
41
+ "formatter": "standard",
42
+ "filename": "app_standard.log",
43
+ "maxBytes": 10485760,
44
+ "backupCount": 5
45
+ }
46
+ },
47
+ "loggers": {
48
+ # Root logger for the application
49
+ "": { # Empty string means the root logger
50
+ "handlers": ["console", "file"],
51
+ "level": "DEBUG", # Set the overall minimum level here
52
+ "propagate": False
53
+ }
54
+ }
55
+ }
56
+
57
+ try:
58
+ logging.config.dictConfig(LOGGING_CONFIG)
59
+ app_logger = logging.getLogger(__name__)
60
+ app_logger.info("Application standard logging configured successfully.")
61
+ except Exception as e:
62
+ print(f"Error configuring standard logging: {e}. Falling back to basicConfig.")
63
+ logging.basicConfig(level=logging.INFO)
64
+ app_logger = logging.getLogger(__name__)
65
+ app_logger.warning("Using basic logging due to configuration error.")
66
+
67
+ # --- Integrate Loguru with Standard Logging ---
68
+ # This is the key to "disabling" Loguru's separate output.
69
+
70
+ # 1. Remove Loguru's default handler (which outputs to stderr)
71
+ logger.remove(0)
72
+
73
+ # 2. Add a handler to Loguru that redirects messages to the standard logging module.
74
+ # The level here determines what Loguru sends to standard logging.
75
+ logger.add(
76
+ logging.StreamHandler(sys.stderr), # You can use any standard logging handler here
77
+ level="DEBUG", # Loguru will send messages at this level or higher to standard logging
78
+ format="{message}" # Keep Loguru's format simple, let standard logging handle formatting
79
+ )
80
+
81
+ # Optional: If you want to completely suppress Loguru's output and rely solely on standard logging
82
+ # for your library's messages, you can set Loguru's level to a very high value:
83
+ # logger.level("CRITICAL") # This would make it only log critical errors
84
+ # Or, if you want to completely disable it (not recommended for general use):
85
+ # logger.disable("my_library") # This disables logging for the 'my_library' hierarchy
86
+
87
+ app_logger.info("Loguru integrated with standard logging.")
88
+
89
+ # --- Main Application Logic ---
90
+ if __name__ == "__main__":
91
+ app_logger.info("Application started.")
92
+
93
+ # Your library's logs will now go through the standard logging system
94
+ my_instance = MyLibraryClass("test_value")
95
+ processed = my_instance.process_data("hello world")
96
+ app_logger.info("Processed data: %s", processed)
97
+
98
+ library_function()
99
+
100
+ try:
101
+ my_instance.perform_risky_operation()
102
+ except Exception:
103
+ app_logger.error("Caught exception from risky operation in library.")
104
+
105
+ app_logger.info("Application finished.")
106
+
107
+ To suppress logging, an application can do the following:
108
+ # application.py (Scenario C: App wants library to be silent)
109
+
110
+ from loguru import logger
111
+ from my_library.my_module import MyLibraryClass, library_function
112
+
113
+ # Remove Loguru's default handler
114
+ logger.remove(0)
115
+
116
+ # Completely disable logging for the 'my_library' hierarchy
117
+ logger.disable("my_library")
118
+
119
+ logger.info("Application started. Loguru for 'my_library' is disabled.")
120
+
121
+ my_instance = MyLibraryClass("test_value")
122
+ processed = my_instance.process_data("hello world") # These will not be logged by library
123
+ logger.info("Processed data: %s", processed) # This will be logged by app's logger
124
+
125
+ library_function() # This will not be logged by library
126
+
127
+ logger.info("Application finished.")
128
+
129
+ """
130
+
131
+ # application.py (Scenario A: App uses Loguru)
132
+ import os, sys
133
+ from loguru import logger
134
+ from pyegeria.core.config import settings as app_settings
135
+
136
+ def console_log_filter(record):
137
+ if len(record["module"]) > 0:
138
+ module_ok = True
139
+ else:
140
+ module_ok = record["module"] in app_settings.logging.console_logging_enabled
141
+
142
+
143
+ return (module_ok
144
+ and
145
+ record["level"].name in app_settings.Logging.console_filter_levels
146
+ )
147
+
148
+ def init_logging(log_init:bool= False):
149
+ if not log_init:
150
+ logger.disable("pyegeria")
151
+
152
+ def config_logging(verbose: bool=False):
153
+ """
154
+ Configures logging for the application using Loguru.
155
+
156
+ This function sets up logging functionalities for the application. It reads
157
+ the necessary logging configurations, ensures the desired log directory exists,
158
+ and defines logging handlers for both file-based and console-based logging.
159
+ Log messages can be retained with a rotation and compression policy for file logs.
160
+
161
+ Raises:
162
+ OSError: If the log directory cannot be created.
163
+
164
+ """
165
+
166
+
167
+ # Get the directory for log files from the environment variable
168
+ log_app_settings = app_settings.Logging
169
+ log_directory = log_app_settings.log_directory
170
+ console_logging_level = log_app_settings.console_logging_level
171
+ logging_console_format = log_app_settings.logging_console_format
172
+ file_logging_level = log_app_settings.file_logging_level
173
+ logging_file_format = log_app_settings.logging_file_format
174
+ console_logging_enabled = log_app_settings.console_logging_enabled
175
+ enable_logging = log_app_settings.enable_logging
176
+
177
+ # Ensure the directory exists
178
+ os.makedirs(log_directory, exist_ok=True)
179
+
180
+ # Define the log file path
181
+ log_file_path = os.path.join(log_directory, "pyegeria.log")
182
+ # Remove Loguru's default stderr handler (id=0) if you want full control
183
+ logger.remove()
184
+
185
+ # Add your desired handlers for the application (and thus the library)
186
+ logger.add(log_file_path,
187
+ level=file_logging_level,
188
+ format=logging_file_format,
189
+ # filter = "",
190
+ retention="7 days", # Keep logs for 7 days
191
+ rotation="10 MB", # rotate logs once they are 10mb
192
+ compression="zip")
193
+ logger.add(
194
+ sys.stderr,
195
+ level=console_logging_level,
196
+ format=logging_console_format,
197
+ filter=console_log_filter,
198
+ colorize=True
199
+ )
200
+
201
+ if enable_logging:
202
+ logger.enable("pyegeria")
203
+ logger.trace("Application started with Loguru configured.")
204
+
205
+
206
+
207
+
@@ -0,0 +1,144 @@
1
+ """
2
+ SPDX-License-Identifier: Apache-2.0
3
+
4
+ Thin adapter helpers to surface pyegeria FormatSets as MCP-style tools without
5
+ side effects. This does NOT implement an MCP transport/server; it focuses on
6
+ programmatic functions that an MCP server entry point can call.
7
+
8
+ Only format sets that advertise DICT or ALL are considered eligible.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import sys
14
+ from typing import Any, Dict, Optional
15
+
16
+ from loguru import logger
17
+
18
+ from pyegeria.view.base_report_formats import (
19
+ list_mcp_format_sets,
20
+ select_report_spec, find_report_specs,
21
+ )
22
+ from pyegeria.egeria_tech_client import EgeriaTech
23
+ from pyegeria.view.format_set_executor import exec_report_spec, _async_run_report
24
+
25
+
26
+ def list_reports() -> dict:
27
+ """List eligible format sets as MCP tools (support DICT or ALL)."""
28
+ return list_mcp_format_sets()
29
+
30
+ def run_find_report_specs(perspective: str= None, question: str= None, report_spec:str= None) -> Dict[str, Any]:
31
+ """
32
+ Find report specs that match the given perspective and question.
33
+
34
+ Args:
35
+ perspective (str): The perspective to search for (e.g., "Data Steward").
36
+ question (str): The question to search for (e.g., "What is the current status of the project?").
37
+ report_spec (str): The report spec to search for (e.g., "ProjectStatusReport").
38
+
39
+ Returns:
40
+ list[dict]: A list of dictionaries, each representing a matching report spec item.
41
+ """
42
+ perspective = None if perspective == "*" else perspective
43
+ question = None if question == "*" else question
44
+ report_spec = None if report_spec == "*" else report_spec
45
+
46
+ report_specs = find_report_specs(perspective=perspective, question=question, report_spec=report_spec)
47
+ if not report_specs:
48
+ raise ValueError(f"No report specs found for perspective '{perspective}' and question '{question}'")
49
+ return {"Matching Report Specs" : report_specs}
50
+
51
+ def describe_report(name: str, output_type: str = "DICT") -> Dict[str, Any]:
52
+ """
53
+ Describe a format set for MCP discovery. If outputType != ANY, a concrete format
54
+ will be resolved; otherwise only metadata/action are returned.
55
+ """
56
+ meta = select_report_spec(name, output_type)
57
+ if not meta:
58
+ raise ValueError(f"Unknown or incompatible format set: {name}")
59
+ return meta
60
+
61
+
62
+ def _execute_egeria_call_blocking(
63
+ *,
64
+ report: str,
65
+ params: Optional[Dict[str, Any]] = None,
66
+ view_server: Optional[str] = None,
67
+ view_url: Optional[str] = None,
68
+ user: Optional[str] = None,
69
+ user_pass: Optional[str] = None,) -> Dict[str, Any]:
70
+ """
71
+ Executes the synchronous, blocking Egeria client call on a dedicated worker thread.
72
+
73
+ You must replace the hardcoded return with your actual Egeria client logic here.
74
+ All code in this function runs in a blocking, synchronous manner.
75
+ """
76
+
77
+ print(
78
+ f"Format set: {report}\nparams: {json.dumps(params)}\nview_server: {view_server}\nview_url: {view_url}\nuser: {user}\nuser_pass: {user_pass}",
79
+ file=sys.stderr)
80
+ # Lazy import of settings to avoid circulars when optional args are None
81
+ # from pyegeria.config import settings as _settings
82
+ from pyegeria.core.config import settings as _settings
83
+
84
+
85
+ return exec_report_spec(
86
+ format_set_name=report,
87
+ output_format="DICT",
88
+ params=params or {},
89
+ view_server=view_server if view_server is not None else _settings.Environment.egeria_view_server,
90
+ view_url=view_url if view_url is not None else _settings.Environment.egeria_view_server_url,
91
+ user=user if user is not None else _settings.User_Profile.user_name,
92
+ user_pass=user_pass if user_pass is not None else _settings.User_Profile.user_pwd,
93
+ )
94
+ # # Returning the hardcoded success for now to prove the async structure works.
95
+ # return {
96
+ # "status": "SUCCESS (Thread Test)",
97
+ # "report_name": report_name,
98
+ # "message": "The blocking call was successfully run on a separate thread, preventing timeout."
99
+ # }
100
+
101
+
102
+
103
+ def run_report(
104
+ *,
105
+ report: str,
106
+ params: Optional[Dict[str, Any]] = None,
107
+ view_server: Optional[str] = None,
108
+ view_url: Optional[str] = None,
109
+ user: Optional[str] = None,
110
+ user_pass: Optional[str] = None,
111
+ ) -> Dict[str, Any]:
112
+ """
113
+ Execute a format set action as an MCP-style tool. Enforces DICT/ALL by default.
114
+ Caller may pass credentials explicitly; otherwise defaults are used from config.
115
+ """
116
+ print(f"Format set: {report}\nparams: {json.dumps(params)}\nview_server: {view_server}\nview_url: {view_url}\nuser: {user}\nuser_pass: {user_pass}", file=sys.stderr)
117
+ # Lazy import of settings to avoid circulars when optional args are None
118
+ from pyegeria.core.config import settings as _settings
119
+ logger.info(f"Format set: {report}\nparams: {json.dumps(params)}\nview_server: {view_server}\nview_url: {view_url}\nuser: {user}\nuser_pass: {user_pass}")
120
+ return exec_report_spec(
121
+ format_set_name=report,
122
+ output_format="DICT",
123
+ params=params or {},
124
+ view_server=view_server if view_server is not None else _settings.Environment.egeria_view_server,
125
+ view_url=view_url if view_url is not None else _settings.Environment.egeria_view_server_url,
126
+ user=user if user is not None else _settings.User_Profile.user_name,
127
+ user_pass=user_pass if user_pass is not None else _settings.User_Profile.user_pwd,
128
+ )
129
+
130
+ async def _async_run_report_tool(
131
+ *,
132
+ report: str,
133
+ egeria_client: EgeriaTech,
134
+ params: Optional[Dict[str, Any]] = None,
135
+ ) -> Dict[str, Any]:
136
+ """
137
+ Execute a format set action as an MCP-style tool. Enforces DICT/ALL by default.
138
+ Caller may pass credentials explicitly; otherwise defaults are used from config.
139
+ """
140
+ # Lazy import of settings to avoid circulars when optional args are None
141
+
142
+ print(f"Report: {report}\n params: {json.dumps(params)}\n", file=sys.stderr)
143
+ result = await _async_run_report(report, egeria_client, output_format="DICT", params=params)
144
+ return result
@@ -0,0 +1,212 @@
1
+ """PDX-License-Identifier: Apache-2.0
2
+ Copyright Contributors to the ODPi Egeria project.
3
+
4
+ This module provides a basic MCP server for Egeria.
5
+ """
6
+ import re
7
+ import sys
8
+ import nest_asyncio
9
+
10
+ from typing import Any, Dict, Optional
11
+
12
+ from mcp.server.fastmcp.exceptions import ValidationError
13
+
14
+ from pyegeria.egeria_tech_client import EgeriaTech
15
+ from pyegeria.core._exceptions import print_validation_error
16
+ # from pyegeria.base_report_formats import find_report_specs
17
+
18
+ GLOBAL_EGERIA_CLIENT: Optional[EgeriaTech] = None
19
+ nest_asyncio.apply()
20
+
21
+ try:
22
+ # We use Optional[] and List[] types, so we import them.
23
+ from mcp.server.fastmcp import FastMCP
24
+ from pyegeria.core.mcp_adapter import (
25
+ list_reports,
26
+ describe_report,
27
+ run_report, _execute_egeria_call_blocking,
28
+ _async_run_report_tool, run_find_report_specs
29
+ )
30
+
31
+ print("MCP import successful...", file=sys.stderr)
32
+ except ImportError:
33
+ print("MCP import failed.", file=sys.stderr)
34
+ raise
35
+
36
+
37
+ def _ok(result: Dict[str, Any]) -> Dict[str, Any]:
38
+ # Pass-through helper in case you want to normalize or add metadata
39
+ print("OK: Operation completed successfully.", file=sys.stderr)
40
+ return result
41
+
42
+
43
+ def main() -> None:
44
+ # Initialize the server
45
+
46
+ global GLOBAL_EGERIA_CLIENT
47
+
48
+ try:
49
+ """ Runs ONCE when the server starts.
50
+ Initializes the Egeria client and stores it in the server's state.
51
+ """
52
+ print("DEBUG: Initializing Egeria client...", file=sys.stderr)
53
+ from pyegeria.core.config import settings as _settings
54
+ user_id = _settings.User_Profile.user_name
55
+ user_pwd = _settings.User_Profile.user_pwd
56
+
57
+ GLOBAL_EGERIA_CLIENT = EgeriaTech(
58
+ _settings.Environment.egeria_view_server,
59
+ _settings.Environment.egeria_view_server_url,
60
+ user_id,
61
+ user_pwd
62
+ )
63
+ print("DEBUG: Egeria Client initialized", file=sys.stderr)
64
+ GLOBAL_EGERIA_CLIENT.create_egeria_bearer_token("erinoverview", "secret")
65
+ print("DEBUG: Egeria Client connected", file=sys.stderr)
66
+
67
+ except ValidationError as e:
68
+ print_validation_error(e)
69
+ raise
70
+ except Exception as e:
71
+ print(f"DEBUG: Exception occurred: {str(e)}", file=sys.stderr)
72
+ raise
73
+
74
+ srv = FastMCP(name="pyegeria-mcp")
75
+ print("Starting MCP server...", file=sys.stderr)
76
+
77
+ # list_reports tool (formerly list_format_sets)
78
+ @srv.tool(name="list_reports")
79
+ def list_reports_tool() -> Dict[str, Any]:
80
+ """Lists all available reports (FormatSets)."""
81
+ print("DEBUG: Listing reports...", file=sys.stderr)
82
+ return _ok(list_reports())
83
+
84
+ @srv.tool(name="find_report_specs")
85
+ def find_report_specs_tool(perspective: str=None, question: str=None, report_spec: str=None) -> Dict[str, Any]:
86
+ """Finds report specs that match the given perspective, question, and report spec."""
87
+ print("DEBUG: Finding report specs...", file=sys.stderr)
88
+ return _ok(run_find_report_specs(perspective=perspective, question=question, report_spec=report_spec))
89
+
90
+
91
+ @srv.tool(name="describe_report")
92
+ def describe_report_tool(name: str, output_type: str = "DICT") -> Dict[str, Any]:
93
+ """Returns the schema and details for a specified report."""
94
+ # FastMCP handles validation of 'name' and 'output_type' types automatically.
95
+ print(f"DEBUG: Describing report: {name} with output type: {output_type}", file=sys.stderr)
96
+ try:
97
+ return _ok(describe_report(name, output_type))
98
+ except Exception as e:
99
+ print(f"DEBUG: Exception during describe_report: {str(e)}", file=sys.stderr)
100
+ raise
101
+
102
+ @srv.tool(name="run_report")
103
+ async def run_report_tool(
104
+ report_name: str,
105
+ search_string: str = "*",
106
+ page_size: Optional[int] = 0,
107
+ start_from: Optional[int] = 0,
108
+ starts_with: Optional[bool] = None,
109
+ ends_with: Optional[bool] = None,
110
+ ignore_case: Optional[bool] = None,
111
+ output_format: str = "DICT"
112
+ ) -> Dict[str, Any]:
113
+ import asyncio
114
+ import nest_asyncio
115
+ nest_asyncio.apply()
116
+
117
+ """Run a report with the specified parameters."""
118
+ print("DEBUG: Running report...", file=sys.stderr)
119
+ # 1. Automatic Validation: FastMCP/Pydantic ensures types are correct.
120
+
121
+ # 2. Manual Validation (for specific values like output_format)
122
+ if output_format not in ["DICT", "JSON", "REPORT", "MERMAID", "HTML"]:
123
+ print(f"DEBUG: Invalid output_format: {output_format}", file=sys.stderr)
124
+ raise ValueError(
125
+ f"Invalid output_format: {output_format}. Must be one of ['DICT', 'JSON', 'REPORT', 'MERMAID', 'HTML'].")
126
+
127
+ # 3. Build params dictionary with only non-None values for clean passing
128
+ params = {
129
+ "search_string": search_string,
130
+ "page_size": page_size,
131
+ "start_from": start_from,
132
+ "starts_with": starts_with,
133
+ "ends_with": ends_with,
134
+ "ignore_case": ignore_case,
135
+ }
136
+ # Filter out None values before passing to run_report
137
+ params = {k: v for k, v in params.items() if v is not None}
138
+
139
+ print(f"DEBUG: Running report={report_name} with params={params}", file=sys.stderr)
140
+
141
+ try:
142
+
143
+ egeria_client: EgeriaTech = GLOBAL_EGERIA_CLIENT
144
+ print("DEBUG: Egeria Client connected", file=sys.stderr)
145
+ result = await asyncio.wait_for(
146
+ _async_run_report_tool(
147
+ report=report_name,
148
+ egeria_client=egeria_client,
149
+ params=params),
150
+ timeout=30 # Adjust timeout as needed
151
+ )
152
+
153
+ print("DEBUG: run_report completed successfully", file=sys.stderr)
154
+ return _ok(result)
155
+ except Exception as e:
156
+ # Re-raise the exception to be sent back as a JSON-RPC error
157
+ print(f"DEBUG: Exception occurred: {str(e)}", file=sys.stderr)
158
+ raise
159
+
160
+ @srv.tool(name="prompt")
161
+ async def natural_language_prompt(prompt: str) -> Dict[str, Any]:
162
+ """
163
+ Handles natural language queries from the user.
164
+ In a production environment, this would call an LLM API.
165
+ """
166
+ print(f"DEBUG: Received natural language prompt: {prompt}", file=sys.stderr)
167
+
168
+ # Example of simple logic: If the user asks to list reports, delegate to the tool.
169
+ if "list" in prompt.lower() and "reports" in prompt.lower():
170
+ print("DEBUG: Delegating prompt to list_reports tool.", file=sys.stderr)
171
+ return list_reports() # This is sync, so no await needed
172
+ elif "run" in prompt.lower() and "report" in prompt.lower():
173
+ print("DEBUG: Delegating prompt to run_report tool.", file=sys.stderr)
174
+
175
+ match = re.search(r'report\s+([a-zA-Z0-9]+)', prompt, re.IGNORECASE)
176
+ report_name = match.group(1) if match else None
177
+
178
+ if report_name:
179
+ print(f"DEBUG: Extracted report name: {report_name}", file=sys.stderr)
180
+
181
+ page_size_match = re.search(r'page size of\s+(\d+)', prompt, re.IGNORECASE)
182
+ page_size = int(page_size_match.group(1)) if page_size_match else None
183
+
184
+ search_match = re.search(r'search for\s+(.*?)(?:\s+in\s+report|\.|$)', prompt, re.IGNORECASE)
185
+
186
+ if search_match:
187
+ search_string = search_match.group(1).strip()
188
+
189
+ if search_string:
190
+ print(
191
+ f"DEBUG: Delegating prompt to run_report tool. Report: {report_name}, Search: '{search_string}'",
192
+ file=sys.stderr)
193
+
194
+ # AWAIT the async function call
195
+ return await run_report_tool(report_name=report_name, search_string=search_string,
196
+ page_size=page_size)
197
+
198
+ # AWAIT the async function call
199
+ return await run_report_tool(report_name=report_name, page_size=page_size)
200
+
201
+ return {
202
+ "response": f"Acknowledged natural language query: '{prompt}'. This would be sent to an LLM."
203
+ }
204
+
205
+ # CRITICAL: This is the missing step. It tells the server to read and process
206
+ # JSON-RPC messages from standard input (stdin).
207
+ srv.run()
208
+ print("MCP server finished running.", file=sys.stderr)
209
+
210
+
211
+ if __name__ == "__main__":
212
+ main()