Skip to content

Commit

Permalink
Merge pull request #63 from dwolfson/v5.2
Browse files Browse the repository at this point in the history
V5.2 Many small bug fixes and cosmetic improvements.
  • Loading branch information
dwolfson authored Dec 17, 2024
2 parents 7074747 + 03aa1ef commit a60da57
Show file tree
Hide file tree
Showing 69 changed files with 408 additions and 175 deletions.
6 changes: 4 additions & 2 deletions pyegeria/commands/cat/list_deployed_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ def generate_table() -> Table:
table.add_column("Catalog Schemas")

if catalog_server in [None, "*"]:
cats = c_client.get_elements_by_classification("Anchors", "DataManager")
cats = c_client.get_elements_by_classification(
"Anchors", "DataAccessManager"
)
else:
server_guid = c_client.get_guid_for_name(catalog_server)
cats = c_client.get_elements_by_classification_with_property_value(
"Anchors", server_guid, ["anchorGUID"], "DataManager"
"Anchors", server_guid, ["anchorGUID"], "DataAccessManager"
)
if type(cats) is list:
for cat in cats:
Expand Down
5 changes: 2 additions & 3 deletions pyegeria/commands/cat/list_deployed_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def generate_table() -> Table:
table.add_column("Qualified Name")
table.add_column("Type")
table.add_column("Created", width=23)
table.add_column("Home Store")
table.add_column("GUID", width=38, no_wrap=True)
table.add_column("Properties")
table.add_column("Schemas")
Expand All @@ -114,7 +113,8 @@ def generate_table() -> Table:
el_created_by = header["versions"]["createdBy"]
el_created_md = (
f"* **Created By**: {el_created_by}\n"
f"* **Created Time**: {el_create_time}"
f"* **Created Time**: {el_create_time}\n"
f"* **Home Store**: {el_home}"
)
el_created_out = Markdown(el_created_md)

Expand Down Expand Up @@ -151,7 +151,6 @@ def generate_table() -> Table:
el_q_name,
el_type,
el_created_out,
el_home,
el_guid,
el_props_out,
rel_el_out,
Expand Down
80 changes: 38 additions & 42 deletions pyegeria/commands/cli/egeria.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
This is an emerging capability based on the **click** package. Feedback welcome!
"""
import sys

import click
from trogon import tui
from pyegeria.commands.cli.egeria_login_tui import login
Expand Down Expand Up @@ -236,15 +238,15 @@ def cli(


# cli.add_command(login)
@cli.command("login")
@click.pass_context
def egeria_login(ctx):
"""Login to Egeria platform"""
user = login(
ctx.obj.userid, ctx.obj.password, ctx.obj.view_server, ctx.obj.view_server_url
)
ctx.obj.userid = user
click.echo(f" user is {ctx.obj.userid}")
# @cli.command("login")
# @click.pass_context
# def egeria_login(ctx):
# """Login to Egeria platform"""
# user = login(
# ctx.obj.userid, ctx.obj.password, ctx.obj.view_server, ctx.obj.view_server_url
# )
# ctx.obj.userid = user
# click.echo(f" user is {ctx.obj.userid}")


#
Expand Down Expand Up @@ -381,22 +383,37 @@ def show_guid_info(ctx, guid):
display_guid(guid, c.server, c.url, c.userid, c.password, c.jupyter, c.width)


@show_elements.command("anchored-elements")
@show_elements.command("anchored_elements")
@click.pass_context
@click.option("--search-string", help="value we are searching for")
@click.option(
"--prop-list", default="anchorTypeName", help="List of properties we are searching"
"--search-string",
default="DeployedDatabaseSchema",
help="value we are searching for",
)
@click.option(
"--prop-list",
default="anchorTypeName",
help="List of properties we are searching",
)
def list_anchored_elements(ctx, search_string: str, prop_list: str):
"""List elements with the specified properties"""
c = ctx.obj
if type(prop_list) is str:
property_names = prop_list.split(",")
elif type(prop_list) is list:
property_names = prop_list
else:
property_names = []
print(f"\nError --> Invalid property list - must be a string or list")
sys.exit(4)
display_anchored_elements(
search_string,
prop_list,
c.view_server,
c.view_server_url,
c.userid,
c.password,
c.timeout,
c.jupyter,
c.width,
)
Expand Down Expand Up @@ -752,7 +769,7 @@ def get_element_info(ctx, om_type):
@cli.group("cat")
@click.pass_context
def cat(ctx):
"""Commands for the more tech user"""
"""Commands for all users"""
pass


Expand Down Expand Up @@ -1325,27 +1342,6 @@ def show_tech_type_elements(ctx, tech_type):
tech_viewer(tech_type, c.view_server, c.view_server_url, c.userid, c.password)


@show_cat_info.command("collection")
@click.option(
"--root-collection",
default="Coco Pharmaceuticals Governance Domains",
help="View of tree of collections from a given root",
)
@click.pass_context
def show_collection(ctx, root_collection):
"""Display information about a collection"""
c = ctx.obj
collection_viewer(
root_collection,
c.view_server,
c.view_server_url,
c.userid,
c.password,
c.jupyter,
c.width,
)


@show_project_group.command("projects")
@click.option("--search-string", default="*", help="List Projects by Search String")
@click.pass_context
Expand Down Expand Up @@ -1632,14 +1628,14 @@ def gov_eng_status(ctx, engine_list, engine_host, list):
c = ctx.obj
display_gov_eng_status(
[engine_list],
engine_host,
c.view_server,
c.view_server_url,
c.userid,
c.password,
list,
c.jupyter,
c.width,
engine_host=engine_host,
view_server=c.view_server,
url=c.view_server_url,
username=c.userid,
user_pass=c.password,
paging=list,
jupyter=c.jupyter,
width=c.width,
)


Expand Down
16 changes: 8 additions & 8 deletions pyegeria/commands/cli/egeria_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,14 @@ def gov_eng_status(ctx, engine_list, engine_host, list):
c = ctx.obj
display_gov_eng_status(
[engine_list],
engine_host,
c.view_server,
c.view_server_url,
c.userid,
c.password,
list,
c.jupyter,
c.width,
engine_host=engine_host,
view_server=c.view_server,
url=c.view_server_url,
username=c.userid,
user_pass=c.password,
paging=list,
jupyter=c.jupyter,
width=c.width,
)


Expand Down
31 changes: 25 additions & 6 deletions pyegeria/commands/cli/egeria_tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
This is an emerging capability based on the **click** package. Feedback welcome!
"""
import sys

import click
from trogon import tui

Expand Down Expand Up @@ -213,7 +215,7 @@ def show_elements(ctx):
@show_elements.command("guid-info")
@click.argument("guid", nargs=1)
@click.pass_context
def show_guid_infos(ctx, guid):
def show_guid_info(ctx, guid):
"""Display guid information
Usage: show guid-info <a guid>
Expand All @@ -240,22 +242,39 @@ def show_related_specifications(ctx, element_guid):
)


@show_elements.command("element-graph")
@show_elements.command("anchored-elements")
@click.pass_context
@click.option("--search-string", help="value we are searching for")
@click.option(
"--prop-list", default="anchorTypeName", help="List of properties we are searching"
"--search-string",
default="SoftwareCapability",
help="value we are searching for",
)
@click.option(
"--prop-list",
default="anchorDomainName",
help="List of properties we are searching",
)
def list_element_graph(ctx, search_string: str, prop_list: str):
def list_anchored_elements(ctx, search_string: str, prop_list: str):
"""List elements with the specified properties"""
c = ctx.obj
# put guards around this to make it a list?
if type(prop_list) is str:
property_names = prop_list.split(",")
elif type(prop_list) is list:
property_names = prop_list
else:
property_names = []
print(f"\nError --> Invalid property list - must be a string or list")
sys.exit(4)

display_anchored_elements(
search_string,
prop_list,
property_names,
c.view_server,
c.view_server_url,
c.userid,
c.password,
c.timeout,
c.jupyter,
c.width,
)
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions pyegeria/commands/doc/command-overview.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the Egeria project. -->
# Overview
**hey_egeria** is a command line interface (CLI) for Egeria with both a scriptable component and a textual user interface to guide
users through the different commands and options. This interface is being actively maintained and enhanced. There are
currently about 70 commands in the interface and new ones are added based on perceived need and community feedback.

The CLI is written in python using the [click](https://click.palletsprojects.com/en/stable/) package with [trogon](https://github.com/Textualize/trogon)
providing the textual user interface. The commands are written using [pyegeria](https://github.com/odpi/egeria-python) or
https://pypi.org/project/pyegeria/. The commands are also available standalone. Simple standalone installation instructions are
documented at [pyegeria](https://egeria-project.org/concepts/pyegeria). pyegeria and hey_egeria are pre-installed within
the **Egeria Workspaces** environment - [Egeria Workspaces](https://github.com/odpi/egeria-workspaces).



# Command Line Interfaces

A command line interface provides a simple language for users to invoke commands. In the case of **hey_egeria**, once it is installed, you can
start simply by typing `hey_egeria` on the command line and it will provide a list of options and commands that you can
use to interact with it. Commands are often arranged hierarchically - so, for instance if we type just `hey_egeria`, the
command options presented to us are:

```aiignore
Commands:
cat Commands for the more tech user
login Login to Egeria platform
my Work with my information
ops Commands to understand and manage operations
tech Commands for tech Users
tui Open Textual TUI.
```

## hey_egeria

## hey_egeria_cat
Expand Down
22 changes: 17 additions & 5 deletions pyegeria/commands/my/monitor_my_todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from rich import box
from rich.live import Live
from rich.markdown import Markdown
from rich.table import Table
from rich.console import Console

Expand Down Expand Up @@ -65,7 +66,7 @@ def add_rows(table: Table, guid: str, identity: str) -> None:
return

for item in todo_items:
assigned_actors = [" "]
assigned_actors = ''
if todo_items is None:
name = " "
type_name = " "
Expand All @@ -88,7 +89,8 @@ def add_rows(table: Table, guid: str, identity: str) -> None:
status = props.get("toDoStatus")

for actor in item["assignedActors"]:
assigned_actors.append(actor.get("uniqueName", "NoOne"))
assigned_actors+=f"{actor.get("uniqueName", "NoOne")}\n"
assigned_actors_out = Markdown(assigned_actors)
if status in ("WAITING", "OPEN"):
status = f"[yellow]{status}"
elif status in ("INPROGRESS", "COMPLETE"):
Expand All @@ -106,7 +108,7 @@ def add_rows(table: Table, guid: str, identity: str) -> None:
due,
completed,
status,
str(assigned_actors),
assigned_actors_out,
)

def generate_table() -> Table:
Expand Down Expand Up @@ -137,9 +139,19 @@ def generate_table() -> Table:
my_title = my_profile["profileProperties"].get("jobTitle", "No Title")
user_ids = []
for id in my_ids:
user_ids.append(id["userIdentity"]["properties"].get("userId", "NoOne"))
user_ids.append(id["userIdentity"]["properties"].get("userid", "NoOne"))
add_rows(
table,
id["userIdentity"]["elementHeader"]["guid"],
id["userIdentity"]["properties"]["userId"],
)

add_rows(table, my_guid, user_ids)

# user_id_guid = my_profile["userIdentity"]["guid"]
# user_id_name = my_profile["userIdentity"]["properties"]["userid"]
# add_rows(table, user_id_guid, user_id_name)

my_roles = my_profile["roles"]
if type(my_roles) is list:
for role in my_roles:
Expand Down Expand Up @@ -179,7 +191,7 @@ def main():

server = args.server if args.server is not None else EGERIA_VIEW_SERVER
url = args.url if args.url is not None else EGERIA_PLATFORM_URL
userid = args.userid if args.userid is not None else EGERIA_USER
userid = args.userid if args.userid is not None else "peterprofile"
user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD

try:
Expand Down
2 changes: 1 addition & 1 deletion pyegeria/commands/my/monitor_open_todos.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def generate_table(search_string: str = "*") -> Table:
if type(assigned_actors) is list:
for actor in assigned_actors:
actor_guid = actor["guid"]
assigned += f"* {m_client.get_actor_for_guid(actor_guid)} "
assigned += f"{m_client.get_actor_for_guid(actor_guid)} \n ({actor_guid}"
assigned_out = Markdown(assigned)

if status in ("WAITING", "OPEN"):
Expand Down
Loading

0 comments on commit a60da57

Please sign in to comment.