pyegeria 5.3.7.1__py3-none-any.whl → 5.3.7.7__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.
- pyegeria/__init__.py +1 -1
- pyegeria/commands/cat/dr_egeria_md.py +11 -8
- pyegeria/commands/cat/glossary_actions.py +11 -18
- pyegeria/dr.egeria spec.md +9 -0
- pyegeria/glossary_browser_omvs.py +1 -1
- pyegeria/glossary_manager_omvs.py +1 -1
- pyegeria/md_processing_helpers.py +68 -0
- pyegeria/md_processing_utils.py +409 -32
- pyegeria/md_processing_utils_orig.py +1103 -0
- {pyegeria-5.3.7.1.dist-info → pyegeria-5.3.7.7.dist-info}/METADATA +2 -2
- {pyegeria-5.3.7.1.dist-info → pyegeria-5.3.7.7.dist-info}/RECORD +14 -11
- {pyegeria-5.3.7.1.dist-info → pyegeria-5.3.7.7.dist-info}/LICENSE +0 -0
- {pyegeria-5.3.7.1.dist-info → pyegeria-5.3.7.7.dist-info}/WHEEL +0 -0
- {pyegeria-5.3.7.1.dist-info → pyegeria-5.3.7.7.dist-info}/entry_points.txt +0 -0
pyegeria/__init__.py
CHANGED
@@ -93,7 +93,7 @@ from .x_action_author_omvs import ActionAuthor
|
|
93
93
|
from .md_processing_utils import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
94
94
|
process_categories_upsert_command,
|
95
95
|
get_current_datetime_string, process_per_proj_upsert_command, command_list,
|
96
|
-
render_markdown, process_provenance_command)
|
96
|
+
render_markdown, process_provenance_command, process_blueprint_upsert_command)
|
97
97
|
|
98
98
|
#
|
99
99
|
# The following assignments were generated by the `create_tech_guid_lists.py` utility that uses the pyegeria functions
|
@@ -13,9 +13,11 @@ import click
|
|
13
13
|
from pyegeria import (extract_command, process_glossary_upsert_command, process_term_upsert_command,
|
14
14
|
process_categories_upsert_command, process_provenance_command,
|
15
15
|
get_current_datetime_string, process_per_proj_upsert_command, command_list,EgeriaTech,
|
16
|
+
process_blueprint_upsert_command
|
16
17
|
)
|
17
18
|
from datetime import datetime
|
18
19
|
|
20
|
+
|
19
21
|
EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
|
20
22
|
EGERIA_KAFKA_ENDPOINT = os.environ.get("KAFKA_ENDPOINT", "localhost:9092")
|
21
23
|
EGERIA_PLATFORM_URL = os.environ.get("EGERIA_PLATFORM_URL", "https://localhost:9443")
|
@@ -39,10 +41,6 @@ EGERIA_ROOT_PATH = os.environ.get("EGERIA_ROOT_PATH", "/Users/dwolfson/localGit/
|
|
39
41
|
EGERIA_INBOX_PATH = os.environ.get("EGERIA_INBOX_PATH", "pyegeria/commands/cat/dr_egeria_inbox")
|
40
42
|
EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat/dr_egeria_outbox")
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
44
|
@click.command("process_markdown_file", help="Process a markdown file and return the output as a string.")
|
47
45
|
@click.option("--file-path", help="File path to markdown file",
|
48
46
|
default="glossary_exp.md", required=True, prompt=False)
|
@@ -52,6 +50,7 @@ EGERIA_OUTBOX_PATH = os.environ.get("EGERIA_OUTBOX_PATH", "pyegeria/commands/cat
|
|
52
50
|
@click.option(
|
53
51
|
"--url", default=EGERIA_VIEW_SERVER_URL, help="URL of Egeria platform to connect to"
|
54
52
|
)
|
53
|
+
|
55
54
|
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
56
55
|
@click.option("--user_pass", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
57
56
|
def process_markdown_file(
|
@@ -65,7 +64,7 @@ def process_markdown_file(
|
|
65
64
|
"""
|
66
65
|
Process a markdown file by parsing and executing Dr. Egeria commands. Write output to a new file.
|
67
66
|
"""
|
68
|
-
|
67
|
+
cmd_list = command_list
|
69
68
|
console = Console(width=int(EGERIA_WIDTH))
|
70
69
|
client = EgeriaTech(server, url, user_id=userid)
|
71
70
|
token = client.create_egeria_bearer_token(userid, user_pass)
|
@@ -97,7 +96,7 @@ def process_markdown_file(
|
|
97
96
|
return # No block to process
|
98
97
|
|
99
98
|
potential_command = extract_command(current_block) # Extract command
|
100
|
-
if potential_command in
|
99
|
+
if potential_command in cmd_list:
|
101
100
|
# Process the block based on the command
|
102
101
|
if potential_command == "Provenance":
|
103
102
|
result = process_provenance_command(file_path, current_block)
|
@@ -111,6 +110,8 @@ def process_markdown_file(
|
|
111
110
|
result = process_term_upsert_command(client, element_dictionary, current_block, directive)
|
112
111
|
elif potential_command in ["Create Personal Project", "Update Personal Project"]:
|
113
112
|
result = process_per_proj_upsert_command(client, element_dictionary, current_block, directive)
|
113
|
+
elif potential_command in ["Create Blueprint", "Update Blueprint", "Create Solution Blueprint", "Update Solution Blueprint"]:
|
114
|
+
result = process_blueprint_upsert_command(client, element_dictionary, current_block, directive)
|
114
115
|
else:
|
115
116
|
# If command is not recognized, keep the block as-is
|
116
117
|
result = None
|
@@ -120,7 +121,7 @@ def process_markdown_file(
|
|
120
121
|
updated = True
|
121
122
|
final_output.append(result)
|
122
123
|
# print(json.dumps(element_dictionary, indent=4))
|
123
|
-
|
124
|
+
elif directive == "validate":
|
124
125
|
print(json.dumps(element_dictionary, indent=4))
|
125
126
|
elif directive == "process":
|
126
127
|
# Handle errors (skip this block but notify the user)
|
@@ -181,7 +182,7 @@ def process_markdown_file(
|
|
181
182
|
f2.write(final_output)
|
182
183
|
if not prov_found:
|
183
184
|
f2.write(prov_output)
|
184
|
-
click.echo(f"\n==>
|
185
|
+
click.echo(f"\n==> Output written to {new_file_path}")
|
185
186
|
else:
|
186
187
|
click.echo("\nNo updates detected. New File not created.")
|
187
188
|
|
@@ -215,3 +216,5 @@ def process_markdown_file(
|
|
215
216
|
#
|
216
217
|
# if __name__ == "__main__":
|
217
218
|
# main()
|
219
|
+
if __name__ == "__main__":
|
220
|
+
process_markdown_file()
|
@@ -141,6 +141,7 @@ def delete_glossary(server, url, userid, password, timeout, glossary_guid):
|
|
141
141
|
@click.command("create-term")
|
142
142
|
@click.option("--glossary-name", help="Name of Glossary", required=True)
|
143
143
|
@click.option("--term-name", help="Name of Term", required=True)
|
144
|
+
@click.option("--qualified-name", help="Qualified name of Term", default=None)
|
144
145
|
@click.option(
|
145
146
|
"--summary",
|
146
147
|
help="Summary definition",
|
@@ -170,31 +171,23 @@ def delete_glossary(server, url, userid, password, timeout, glossary_guid):
|
|
170
171
|
@click.option("--userid", default=EGERIA_USER, help="Egeria user")
|
171
172
|
@click.option("--password", default=EGERIA_USER_PASSWORD, help="Egeria user password")
|
172
173
|
@click.option("--timeout", default=60, help="Number of seconds to wait")
|
173
|
-
def create_term(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
summary,
|
181
|
-
description,
|
182
|
-
abbrev,
|
183
|
-
examples,
|
184
|
-
usage,
|
185
|
-
version,
|
186
|
-
status,
|
187
|
-
timeout: int = 120,
|
188
|
-
) -> str:
|
189
|
-
"""Create a new term"""
|
174
|
+
def create_term(server, url, userid, password, glossary_name, term_name, summary, description, abbrev, examples, usage,
|
175
|
+
version, status, timeout: int = 120, qualified_name=None) -> str:
|
176
|
+
"""Create a new term
|
177
|
+
|
178
|
+
Args:
|
179
|
+
qualified_name:
|
180
|
+
"""
|
190
181
|
m_client = EgeriaTech(server, url, user_id=userid, user_pwd=password)
|
191
182
|
token = m_client.create_egeria_bearer_token()
|
183
|
+
if qualified_name is None:
|
184
|
+
qualified_name = m_client.__create_qualified_name__('Term', term_name)
|
192
185
|
try:
|
193
186
|
body = {
|
194
187
|
"class": "ReferenceableRequestBody",
|
195
188
|
"elementProperties": {
|
196
189
|
"class": "GlossaryTermProperties",
|
197
|
-
"qualifiedName":
|
190
|
+
"qualifiedName": qualified_name,
|
198
191
|
"displayName": term_name,
|
199
192
|
"summary": summary,
|
200
193
|
"description": description,
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
| Attribute Name | Input Required? | Generated/Default? | Unique? | Notes | Type
|
3
|
+
|:----------------| :- | :- | :- | :-|:-------------------------|
|
4
|
+
| Term Name | Yes | No | No | A display name (informal name). | string |
|
5
|
+
| Owning Glossary | Yes | No | Yes | This is the qualified name of the glossary that owns this term. | Qualified name reference |
|
6
|
+
| Categories | No | No | Yes | This is the qualified (unique) name of the category. Multiple categories can be assigned, separated by a `,` or line. | qualified name reference
|
7
|
+
| Description | No | No | No | A textual description of this term | string |
|
8
|
+
| Qualified Name | No | Yes | Yes | The qualified name can either be provided by the user or generated. If generated, a pattern is followed. | mfg or supplied q_name |
|
9
|
+
| GUID | No | Yes | Yes | GUIDs are always generated by Egeria. They are meant for automation, not people. | Generated
|
@@ -149,7 +149,7 @@ class GlossaryBrowser(Client):
|
|
149
149
|
description = element_properties.get("description", None)
|
150
150
|
examples = element_properties.get("examples", None)
|
151
151
|
usage = element_properties.get("usage", None)
|
152
|
-
pub_version = element_properties.get("
|
152
|
+
pub_version = element_properties.get("publishfinVersionIdentifier", None)
|
153
153
|
qualified_name = element_properties.get("qualifiedName", None)
|
154
154
|
status = element['elementHeader'].get('status', None)
|
155
155
|
|
@@ -936,7 +936,7 @@ class GlossaryManager(GlossaryBrowser):
|
|
936
936
|
continue
|
937
937
|
|
938
938
|
# Add the term
|
939
|
-
term_qualified_name = self.
|
939
|
+
term_qualified_name = self.__create_qualified_name__("Term", display_name),
|
940
940
|
|
941
941
|
body = {
|
942
942
|
"class": "ReferenceableRequestBody",
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
from typing import List, Optional
|
3
|
+
|
4
|
+
import os
|
5
|
+
import re
|
6
|
+
|
7
|
+
from rich import box, print
|
8
|
+
from rich.console import Console
|
9
|
+
from rich.markdown import Markdown
|
10
|
+
|
11
|
+
from pyegeria import body_slimmer
|
12
|
+
from pyegeria._globals import NO_TERMS_FOUND, NO_GLOSSARIES_FOUND, NO_TERMS_FOUND, NO_ELEMENTS_FOUND, NO_PROJECTS_FOUND, NO_CATEGORIES_FOUND
|
13
|
+
from pyegeria.egeria_tech_client import EgeriaTech
|
14
|
+
from pyegeria.md_processing_utils import extract_attribute
|
15
|
+
from pyegeria.project_manager_omvs import ProjectManager
|
16
|
+
from pyegeria.glossary_manager_omvs import GlossaryManager
|
17
|
+
ERROR = "ERROR-> "
|
18
|
+
INFO = "INFO- "
|
19
|
+
WARNING = "WARNING-> "
|
20
|
+
pre_command = "\n---\n==> Processing command:"
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
def process_q_name_list(egeria_client: EgeriaTech, element_type:str, txt:str )-> tuple[str,str,str,bool,bool]:
|
25
|
+
msg = ""
|
26
|
+
known_guid = None
|
27
|
+
valid = True
|
28
|
+
exists = False
|
29
|
+
|
30
|
+
elements_txt = extract_attribute(txt, [element_type])
|
31
|
+
|
32
|
+
if elements_txt is None:
|
33
|
+
msg += f"* {INFO}No Solution Blueprints found\n"
|
34
|
+
|
35
|
+
else:
|
36
|
+
element_list = re.split(r'[,\n]+', elements_txt)
|
37
|
+
elements = ""
|
38
|
+
new_element_list = []
|
39
|
+
for element in element_list:
|
40
|
+
element_el = element.strip()
|
41
|
+
if element_el not in element_dictionary:
|
42
|
+
# Get the element using the generalized function
|
43
|
+
|
44
|
+
el = get_element_by_name(egeria_client, element_type, element_el)
|
45
|
+
if isinstance(el, str):
|
46
|
+
msg += (f"* {WARNING}Blueprint `{element_el}` not found -> "
|
47
|
+
f"Blueprints for this Solution Component won't be processed!\n")
|
48
|
+
el_exist = False
|
49
|
+
break
|
50
|
+
|
51
|
+
# Extract properties using the element type name to construct property access
|
52
|
+
properties_key = f"{element_type}Properties"
|
53
|
+
el_qname = el[0][properties_key].get('qualifiedName', None)
|
54
|
+
|
55
|
+
if el_qname not in element_dictionary:
|
56
|
+
el_guid = el[0]['elementHeader']['guid']
|
57
|
+
el_display_name = el[0][properties_key].get('displayName', None)
|
58
|
+
element_dictionary[el_qname] = {
|
59
|
+
'guid': el_guid,
|
60
|
+
'displayName': el_display_name
|
61
|
+
}
|
62
|
+
elements = f"{el_qname}, {elements}"
|
63
|
+
new_element_list.append(el_qname)
|
64
|
+
if el_exist:
|
65
|
+
elements += '\n'
|
66
|
+
element_list = new_element_list
|
67
|
+
else:
|
68
|
+
elements = None
|