Skip to content

Commit

Permalink
Merge pull request #32 from dwolfson/v.5.0
Browse files Browse the repository at this point in the history
V.5.5.10 - minor updates
  • Loading branch information
dwolfson authored Jul 18, 2024
2 parents a763beb + 9bac970 commit 03b9895
Show file tree
Hide file tree
Showing 27 changed files with 2,697 additions and 157 deletions.
415 changes: 415 additions & 0 deletions examples/Coco_config/config_coco_datalake.py

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions examples/Coco_config/start_all_coco.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import json

from globals import (adminUserId, cocoMDS1Name, dataLakePlatformURL, cocoCohort)
from globals import (adminUserId, cocoMDS1Name, dataLakePlatformURL, cocoCohort, adminUserId)
from pyegeria import CoreServerConfig, Platform
from pyegeria import (
print_exception_response,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
239 changes: 239 additions & 0 deletions examples/coco_config/config_coco_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
#!/usr/bin/env python3
"""
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the ODPi Egeria project.
Egeria Coco Pharmaceutical demonstration labs.
This script creates and configures the cocoMDS2 - Governance metadata server
"""


import json
import argparse
from datetime import datetime

from globals import (cocoMDS2Name, corePlatformURL, cocoCohort, devCohort, iotCohort, max_paging_size, adminUserId,
cocoMDS5Name, cocoMDS6Name)
from pyegeria import CoreServerConfig, Platform
from pyegeria import (
print_exception_response,
)


def config_coco_core(url: str, userid: str):
disable_ssl_warnings = True
print("Configuring and activating the Datalake")
platform_url = url
admin_user = userid

# event_bus_config = {
# "producer": {
# "bootstrap.servers": "{{kafkaEndpoint}}"
# },
# "consumer": {
# "bootstrap.servers": "{{kafkaEndpoint}}"
# }
# }
event_bus_config = {
"producer": {
"bootstrap.servers": "host.docker.internal:9192"
},
"consumer": {
"bootstrap.servers": "host.docker.internal:9192"
}
}

security_connection_body = {
"class": "Connection",
"connectorType": {
"class": "ConnectorType",
"connectorProviderClassName":
"org.odpi.openmetadata.metadatasecurity.samples.CocoPharmaServerSecurityProvider"
}
}

#
# Configure MDS2
#
mdr_server = cocoMDS2Name
mdr_server_user_id = "cocoMDS2npa"
mdr_server_password = "cocoMDS2passw0rd"
metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d"
metadataCollectionName = "Governance Catalog"


try:
o_client = CoreServerConfig(mdr_server, platform_url, admin_user)

o_client.set_basic_server_properties("Governance Server",
"Coco Pharmaceuticals",
platform_url,
mdr_server_user_id, mdr_server_password,
max_paging_size)

o_client.set_event_bus(event_bus_config)
o_client.set_server_security_connection(security_connection_body)
o_client.add_default_log_destinations()

# o_client.set_in_mem_local_repository()
o_client.set_xtdb_local_kv_repository()

o_client.set_local_metadata_collection_id(metadataCollectionId)
o_client.set_local_metadata_collection_name(metadataCollectionName)

o_client.add_cohort_registration(cocoCohort)
o_client.add_cohort_registration(devCohort)
o_client.add_cohort_registration(iotCohort)

# o_client.configure_access_service("asset-catalog", {})
o_client.configure_access_service("asset-consumer", {})

o_client.configure_access_service("asset-owner", {})
o_client.configure_access_service("community-profile",
{"KarmaPointPlateau": "500"})
# o_client.configure_access_service("glossary-view", {})
# o_client.configure_access_service("subject-area", {})
o_client.configure_access_service("governance-engine", {})
o_client.configure_access_service("governance-server", {})
o_client.configure_access_service("governance-program", {})
# o_client.configure_access_service("data-privacy", {})
o_client.configure_access_service("digital-architecture", {})
o_client.configure_access_service("security-manager", {})
o_client.configure_access_service("asset-lineage", {})
o_client.configure_access_service("it-infrastructure", {})
o_client.configure_access_service("project-management", {})
print(f"Activating {mdr_server}")
p_client = Platform(mdr_server, platform_url, admin_user)
p_client.activate_server_stored_config()
print(f"{mdr_server} activated")
except Exception as e:
print_exception_response(e)
#
# Configure MDS5
#
disable_ssl_warnings = True

mdr_server = cocoMDS5Name
mdr_server_user_id = "cocoMDS5npa"
mdr_server_password = "cocoMDS5passw0rd"
metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d"
metadataCollectionName = "Business Systems Catalog"

print("Configuring " + mdr_server + "...")
try:
o_client = CoreServerConfig(mdr_server, platform_url, admin_user)

o_client.set_basic_server_properties("Business Systems",
"Coco Pharmaceuticals",
platform_url,
mdr_server_user_id, mdr_server_password,
max_paging_size)

o_client.set_event_bus(event_bus_config)
o_client.set_server_security_connection(security_connection_body)
o_client.add_default_log_destinations()

# o_client.set_in_mem_local_repository()
o_client.set_xtdb_local_kv_repository()

o_client.set_local_metadata_collection_id(metadataCollectionId)
o_client.set_local_metadata_collection_name(metadataCollectionName)

o_client.add_cohort_registration(cocoCohort)

proxy_details = ("org.odpi.openmetadata.adapters.repositoryservices.readonly.repositoryconnector." +
"ReadOnlyOMRSRepositoryConnectorProvider")
o_client.set_repository_proxy_details(proxy_details)
print(f"Activating {mdr_server}")
p_client = Platform(mdr_server, platform_url, admin_user)
p_client.activate_server_stored_config()
print(f"{mdr_server} activated")
except Exception as e:
print_exception_response(e)

#
# Configure MDS6
#
disable_ssl_warnings = True

mdr_server = cocoMDS6Name
platform_url = corePlatformURL
admin_user = "garygeeke"
mdr_server_user_id = "cocoMDS6npa"
mdr_server_password = "cocoMDS6passw0rd"
metadataCollectionId = f"{mdr_server}-e915f2fa-aa3g-4396-8bde-bcd65e642b1d"
metadataCollectionName = "Manufacturing Catalog"

print("Configuring " + mdr_server + "...")

try:
o_client = CoreServerConfig(mdr_server, platform_url, admin_user)

o_client.set_basic_server_properties("Manufacturing",
"Coco Pharmaceuticals",
platform_url,
mdr_server_user_id, mdr_server_password,
max_paging_size)

o_client.set_event_bus(event_bus_config)

o_client.set_server_security_connection(security_connection_body)
o_client.add_default_log_destinations()

# o_client.set_in_mem_local_repository()
o_client.set_xtdb_local_kv_repository()

o_client.set_local_metadata_collection_id(metadataCollectionId)
o_client.set_local_metadata_collection_name(metadataCollectionName)

o_client.add_cohort_registration(cocoCohort)
o_client.add_cohort_registration(iotCohort)

access_service_options = {
"SupportedZones": ["manufacturing"],
"DefaultZones": ["manufacturing"]
}

# o_client.configure_access_service("asset-catalog", access_service_options)
o_client.configure_access_service("asset-consumer", access_service_options)
o_client.configure_access_service("asset-owner", access_service_options)
o_client.configure_access_service("community-profile",
{"KarmaPointPlateau": "500"})
# o_client.configure_access_service("glossary-view", {})
o_client.configure_access_service("data-science", access_service_options)
# o_client.configure_access_service("subject-area", {})
o_client.configure_access_service("asset-manager", access_service_options)
o_client.configure_access_service("governance-engine", access_service_options)
o_client.configure_access_service("governance-server", access_service_options)
o_client.configure_access_service("asset-owner", access_service_options)
# o_client.configure_access_service("data-engine", access_service_options)
o_client.configure_access_service("data-manager", access_service_options)
o_client.configure_access_service("it-infrastructure", access_service_options)
o_client.configure_access_service("project-management", access_service_options)

print(f"Activating {mdr_server}")
p_client = Platform(mdr_server, platform_url, admin_user)
p_client.activate_server_stored_config()
print(f"{mdr_server} activated")
except Exception as e:
print_exception_response(e)

def main():
parser = argparse.ArgumentParser()

parser.add_argument("--url", help="URL Platform to connect to")
parser.add_argument("--userid", help="User Id")
args = parser.parse_args()

url = args.url if args.url is not None else corePlatformURL
userid = args.userid if args.userid is not None else adminUserId

config_coco_core(url, userid)

if __name__ == "__main__":
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 27 additions & 21 deletions examples/widgets/catalog_user/view_asset_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def build_classifications(classification: dict) -> Markdown:
c_type = c["classificationName"]
if c_type == "Anchors":
continue
class_md += f"* Classification: {c_type}\n"
class_md += f"\n* Classification: {c_type}\n"
class_props = c.get("classificationProperties","---")
if type(class_props) is list:
if type(class_props) is dict:
for prop in class_props.keys():
class_md += f"\t* {prop}: {class_props[prop]}\n"
if class_md == "":
Expand All @@ -70,14 +70,15 @@ def build_nested_elements(nested_element: dict) -> Markdown:
ne_classifications = nested_element["classifications"]
ne_class_md = build_classifications(ne_classifications)
# ne_class_md = " " if ne_class_md is None else ne_class_md
ne_props = nested_element["properties"]

ne_prop_md = ""
for prop in ne_props.keys():
ne_prop_md += f"* {prop}: {ne_props[prop]}\n"
ne_props = nested_element.get("properties","---")
ne_prop_md = "\n"
if type(ne_props) is dict:
for prop in ne_props.keys():
ne_prop_md += f"\t* {prop}: {ne_props[prop]}\n"
ne_md = (f"Nested Element of Type: {ne_type} with GUID: {ne_guid} \n "
f"* created by {ne_created_by} at time {ne_created_at}\n"
f"{ne_prop_md}\n")
f"\n* Properties:\n{ne_prop_md}\n")

if ne_class_md is not None:
ne_md += f"* {ne_class_md}"

Expand Down Expand Up @@ -117,6 +118,8 @@ def build_nested_elements(nested_element: dict) -> Markdown:
style = ""

asset_type = asset_graph["type"]["typeName"]
asset_deployed_imp_type = asset_graph.get("deployedImplementationType","---")

asset_origin = asset_graph["origin"]["homeMetadataCollectionName"]
asset_creation = asset_graph["versions"]["createTime"]
asset_created_by = asset_graph["versions"]["createdBy"]
Expand All @@ -126,12 +129,15 @@ def build_nested_elements(nested_element: dict) -> Markdown:
asset_class_md = build_classifications(asset_classifications)


asset_properties = asset_graph["extendedProperties"]
prop_md = "\n* Extended Properties:\n"
for prop in asset_properties:
prop_md = f"{prop_md}\n\t* {prop}: {asset_properties[prop]}\n"

asset_properties = asset_graph.get("extendedProperties",None)
if asset_properties is not None:
prop_md = "\n* Extended Properties:\n"
for prop in asset_properties:
prop_md = f"{prop_md}\n\t* {prop}: {asset_properties[prop]}\n"
else:
prop_md = ""
core_md = (f"**Type: {asset_type} Created by: {asset_created_by} on {asset_creation}**\n"
f"* Deployed Implementation Type: {asset_deployed_imp_type}\n"
f"* Qualified Name: {qualified_name}\n "
f"* Resource Name: {resource_name}\n"
f"* Display Name: {asset_name}\n"
Expand Down Expand Up @@ -162,16 +168,16 @@ def build_nested_elements(nested_element: dict) -> Markdown:
rel_end1 = relationship["end1"]
rel_end1_type = rel_end1["type"]["typeName"]
rel_end1_guid = rel_end1["guid"]
rel_end1_unique_name = rel_end1["uniqueName"]
rel_end1_unique_name = rel_end1.get("uniqueName","---")

rel_end2 = relationship["end2"]
rel_end2_type = rel_end2["type"]["typeName"]
rel_end2_guid = rel_end2["guid"]
rel_end2_unique_name = rel_end2["uniqueName"]
rel_end2_unique_name = rel_end2.get("uniqueName", "---")

if (rel_end1_guid not in guid_list) or (rel_end2_guid not in guid_list):
rel_end1_class_md = build_classifications(rel_end1["classifications"])
rel_end2_class_md = build_classifications(rel_end2["classifications"])
# rel_end1_class_md = build_classifications(rel_end1["classifications"])
# rel_end2_class_md = build_classifications(rel_end2["classifications"])

relationship_guid = relationship["guid"]
relationship_type = relationship["type"]["typeName"]
Expand All @@ -196,8 +202,8 @@ def build_nested_elements(nested_element: dict) -> Markdown:
f"\t* Unique Name: {rel_end1_unique_name}\n"
)

if rel_end1_class_md is not None:
rel_end1_md = rel_end1_class_md + rel_end1_md
# if rel_end1_class_md is not None:
# rel_end1_md = rel_end1_class_md + rel_end1_md

rel_end2_md = (
f"* End2:\n"
Expand All @@ -206,8 +212,8 @@ def build_nested_elements(nested_element: dict) -> Markdown:
f"\t* Unique Name: {rel_end2_unique_name}\n"
)

if rel_end2_class_md is not None:
rel_end1_md = rel_end2_class_md + rel_end1_md
# if rel_end2_class_md is not None:
# rel_end1_md = rel_end2_class_md + rel_end1_md
#
# for prop in relationship_properties.keys():
# relationship_md += f"* {prop}: {relationship_properties[prop]}\n"
Expand Down
Loading

0 comments on commit 03b9895

Please sign in to comment.