Skip to content

Commit

Permalink
Merge pull request #62 from dwolfson/v5.2
Browse files Browse the repository at this point in the history
Minor updates to several commands and methods along with some bug fixes.
  • Loading branch information
dwolfson authored Dec 11, 2024
2 parents 4850f30 + 828986c commit 7074747
Show file tree
Hide file tree
Showing 63 changed files with 4,759 additions and 448 deletions.
2 changes: 2 additions & 0 deletions pyegeria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
from .create_tech_guid_lists import build_global_guid_lists
from .classification_manager_omvs import ClassificationManager
from .feedback_manager_omvs import FeedbackManager
from .metadata_explorer_omvs import MetadataExplorer
from .mermaid_utilities import load_mermaid, render_mermaid, generate_process_graph
from .egeria_my_client import EgeriaMy
from .egeria_cat_client import EgeriaCat
from .egeria_tech_client import EgeriaTech
from .egeria_config_client import EgeriaConfig
from .egeria_client import Egeria


#
# The following assignments were generated by the `create_tech_guid_lists.py` utility that uses the pyegeria functions
# to interrogate Egeria (and the Core Content Pack) for the GUIDS associates with integration connectors and templates.
Expand Down
9 changes: 7 additions & 2 deletions pyegeria/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,11 @@ async def __async_get_guid__(
result = await self._async_make_request("POST", url, body_slimmer(body))
return result.json().get("guid", "No elements found")

try:
view_server = self.view_server
except AttributeError:
view_server = os.environ.get("VIEW_SERVER", "view-server")

if (not qualified_name) and display_name:
if (tech_type) and (property_name == "qualifiedName"):
name = f"{tech_type}:{display_name}"
Expand All @@ -705,7 +710,7 @@ async def __async_get_guid__(
"effectiveTime": None,
}
url = (
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/classification-manager/"
f"{self.platform_url}/servers/{view_server}/api/open-metadata/classification-manager/"
f"elements/guid-by-unique-name?forLineage=false&forDuplicateProcessing=false"
)

Expand All @@ -721,7 +726,7 @@ async def __async_get_guid__(
"effectiveTime": None,
}
url = (
f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/classification-manager/"
f"{self.platform_url}/servers/{view_server}/api/open-metadata/classification-manager/"
f"elements/guid-by-unique-name?forLineage=false&forDuplicateProcessing=false"
)

Expand Down
40 changes: 37 additions & 3 deletions pyegeria/asset_catalog_omvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def create_postgres_server_element_from_template(
# Engine Actions
#

async def _async_find_assets_in_domain(
async def _async_find_in_asset_domain(
self,
search_string: str,
start_from: int = 0,
Expand Down Expand Up @@ -367,7 +367,7 @@ async def _async_find_assets_in_domain(
response = await self._async_make_request("POST", url, body, time_out=time_out)
return response.json().get("searchMatches", "no assets found")

def find_assets_in_domain(
def find_in_asset_domain(
self,
search_string: str,
start_from: int = 0,
Expand Down Expand Up @@ -416,7 +416,7 @@ def find_assets_in_domain(
"""
loop = asyncio.get_event_loop()
response = loop.run_until_complete(
self._async_find_assets_in_domain(
self._async_find_in_asset_domain(
search_string,
start_from,
page_size,
Expand Down Expand Up @@ -506,6 +506,40 @@ def get_asset_graph(
)
return response

def get_asset_mermaid_graph(
self,
asset_guid: str,
start_from: int = 0,
page_size: int = max_paging_size,
) -> str:
"""Return the asset graph as mermaid markdown string.
Parameters
----------
asset_guid : str
The unique identity of the asset to get the graph for.
start_from : int, optional
The index from which to start fetching the engine actions. Default is 0.
page_size : int, optional
The maximum number of engine actions to fetch in a single request. Default is `max_paging_size`.
Returns
-------
str
A mermaid string representing the asset graph.
Raises:
------
InvalidParameterException
PropertyServerException
UserNotAuthorizedException
"""

asset_graph = self.get_asset_graph(asset_guid, start_from, page_size)
return asset_graph.get("mermaidGraph")

async def _async_get_asset_lineage_graph(
self,
asset_guid: str,
Expand Down
5 changes: 2 additions & 3 deletions pyegeria/classification_manager_omvs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""PDX-License-Identifier: Apache-2.0
Copyright Contributors to the ODPi Egeria project.
This module contains an initial version of the classification_manager_omvs
module.
This module provides access to the classification_manager_omvs module.
"""

Expand Down Expand Up @@ -71,7 +70,7 @@ def __init__(
self.platform_url = platform_url
self.user_id = user_id
self.user_pwd = user_pwd
self.classification_command_root: str = f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/runtime-manager"
self.classification_command_root: str = f"{self.platform_url}/servers/{self.view_server}/api/open-metadata/classification-manager"
Client.__init__(
self,
view_server,
Expand Down
137 changes: 92 additions & 45 deletions pyegeria/collection_manager_omvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,9 @@ def delete_collection(self, collection_guid: str) -> None:

async def _async_get_collection_members(
self,
collection_guid: str,
collection_guid: str = None,
collection_name: str = None,
collection_qname: str = None,
effective_time: str = None,
start_from: int = 0,
page_size: int = None,
Expand All @@ -2189,12 +2191,16 @@ async def _async_get_collection_members(
Parameters
----------
collection_guid: str,
identity of the collection to return members for.
identity of the collection to return members for. If none, collection_name or
collection_qname are used.
collection_name: str,
display name of the collection to return members for. If none, collection_guid
or collection_qname are used.
collection_qname: str,
qualified name of the collection to return members for. If none, collection_guid
or collection_name are used.
effective_time: str, [default=None], optional
Effective time of the query. If not specified will default to any time.
start_from: int, [default=0], optional
When multiple pages of results are available, the page number to start from.
page_size: int, [default=None]
Expand All @@ -2220,7 +2226,13 @@ async def _async_get_collection_members(

if page_size is None:
page_size = self.page_size

collection_guid = self.__get_guid__(
collection_guid,
collection_name,
"name",
collection_qname,
None,
)
url = (
f"{self.collection_command_root}/{collection_guid}/"
f"members?startFrom={start_from}&pageSize={page_size}"
Expand All @@ -2231,27 +2243,33 @@ async def _async_get_collection_members(

def get_collection_members(
self,
collection_guid: str,
collection_guid: str = None,
collection_name: str = None,
collection_qname: str = None,
effective_time: str = None,
start_from: int = 0,
page_size: int = None,
) -> list | str:
"""Return a list of elements that are a member of a collection.
Parameters
----------
collection_guid: str,
identity of the collection to return members for.
effective_time: str, [default=None], optional
Effective time of the query. If not specified will default to any time.
"""Return a list of elements that are a member of a collection. Async version.
start_from: int, [default=0], optional
When multiple pages of results are available, the page number to start from.
page_size: int, [default=None]
The number of items to return in a single page. If not specified, the default will be taken from
the class instance.
Parameters
----------
collection_guid: str,
identity of the collection to return members for. If none, collection_name or
collection_qname are used.
collection_name: str,
display name of the collection to return members for. If none, collection_guid
or collection_qname are used.
collection_qname: str,
qualified name of the collection to return members for. If none, collection_guid
or collection_name are used.
effective_time: str, [default=None], optional
Effective time of the query. If not specified will default to any time.
start_from: int, [default=0], optional
When multiple pages of results are available, the page number to start from.
page_size: int, [default=None]
The number of items to return in a single page. If not specified, the default will be taken from
the class instance.
Returns
-------
List | str
Expand All @@ -2272,7 +2290,12 @@ def get_collection_members(
loop = asyncio.get_event_loop()
resp = loop.run_until_complete(
self._async_get_collection_members(
collection_guid, effective_time, start_from, page_size
collection_guid,
collection_name,
collection_qname,
effective_time,
start_from,
page_size,
)
)

Expand Down Expand Up @@ -2602,20 +2625,29 @@ def remove_from_collection(self, collection_guid: str, element_guid: str) -> Non
)
return

async def _async_get_member_list(self, root_collection_guid: str) -> list | bool:
async def _async_get_member_list(
self,
collection_guid: str = None,
collection_name: str = None,
collection_qname: str = None,
) -> list | bool:
"""Get the member list for the collection - async version.
Parameters
----------
root_collection_guid : str
The unique GUID of the root collection.
The name of the server. If not provided, the default server name will be used.
collection_guid: str,
identity of the collection to return members for. If none, collection_name or
collection_qname are used.
collection_name: str,
display name of the collection to return members for. If none, collection_guid
or collection_qname are used.
collection_qname: str,
qualified name of the collection to return members for. If none, collection_guid
or collection_name are used.
Returns
-------
list | bool
The list of member information if successful, otherwise False.
list | str
The list of member information if successful, otherwise the string "No members found"
Raises
------
Expand All @@ -2628,15 +2660,20 @@ async def _async_get_member_list(self, root_collection_guid: str) -> list | bool

# now find the members of the collection
member_list = []
members = await self._async_get_collection_members(root_collection_guid)
if type(members) is str:
return False
members = await self._async_get_collection_members(
collection_guid, collection_name, collection_qname
)
if (type(members) is str) or (len(members) == 0):
return "No members found"
# finally, construct a list of member information
for member_rel in members:
member_guid = member_rel["elementHeader"]["guid"]
member_resp = await self._async_get_collection(member_guid)
member = member_resp["element"]
member = member_resp.get("element", None)
if member is None:
continue
# print(json.dumps(member, indent = 4))

member_instance = {
"name": member["properties"]["name"],
"qualifiedName": member["properties"]["qualifiedName"],
Expand All @@ -2646,18 +2683,26 @@ async def _async_get_member_list(self, root_collection_guid: str) -> list | bool
}
member_list.append(member_instance)

return member_list
return member_list if len(member_list) > 0 else "No members found"

def get_member_list(self, root_collection_guid: str) -> list | bool:
"""Get the member list for the collection.
def get_member_list(
self,
collection_guid: str = None,
collection_name: str = None,
collection_qname: str = None,
) -> list | bool:
"""Get the member list for the collection - async version.
Parameters
----------
root_collection_guid : str
The GUID of the root collection.
The name of the server. If not provided, the default server name will be used.
collection_guid: str,
identity of the collection to return members for. If none, collection_name or
collection_qname are used.
collection_name: str,
display name of the collection to return members for. If none, collection_guid
or collection_qname are used.
collection_qname: str,
qualified name of the collection to return members for. If none, collection_guid
or collection_name are used.
Returns
-------
list | bool
Expand All @@ -2671,7 +2716,9 @@ def get_member_list(self, root_collection_guid: str) -> list | bool:
"""
loop = asyncio.get_event_loop()
resp = loop.run_until_complete(
self._async_get_member_list(root_collection_guid)
self._async_get_member_list(
collection_guid, collection_name, collection_qname
)
)
return resp

Expand Down
Loading

0 comments on commit 7074747

Please sign in to comment.