This guide provides an overview of how to use the pyegeria Python library to interact with Egeria.
pyegeria is designed around a set of client classes that correspond to Egeria's Open Metadata View Services (OMVS). These clients handle communication with the Egeria platform, authentication, and provide high-level Pythonic APIs for working with metadata.
BaseServerClient: The foundation class that manages thehttpxsession, authentication headers, and core request/response logic.ServerClient: ExtendsBaseServerClientwith Egeria-specific patterns like GUID resolution, qualified name creation, and request body validation using Pydantic models.- OMVS Clients: Individual classes for each Egeria service (e.g.,
GlossaryManager,AssetCatalog,DataDesigner). These contain the actual business logic. - Role-Based Facades: Convenient entry points that group multiple OMVS clients by user role (e.g.,
EgeriaTech,EgeriaCat).
pyegeria features a centralized configuration system that allows you to set defaults for all clients in one place.
When a client is initialized, it resolves its settings (like platform_url or user_id) using the following precedence:
- Explicit Arguments: Values passed directly to the class constructor.
- Environment Variables: OS environment variables (prefixed with
PYEGERIA_or as standard Egeria names). .envFile: Variables defined in a.envfile in the current working directory.config.json: A JSON configuration file.- Built-in Defaults: Hardcoded safe defaults.
| Variable | Description |
|---|---|
EGERIA_PLATFORM_URL |
The base URL of your Egeria platform. |
EGERIA_VIEW_SERVER |
The name of the View Server to use. |
EGERIA_USER |
The default user ID for authentication. |
EGERIA_USER_PASSWORD |
The password for the default user. |
EGERIA_LOCAL_QUALIFIER |
A prefix used when generating qualifiedNames. |
.env file:
EGERIA_PLATFORM_URL=https://localhost:9443
EGERIA_VIEW_SERVER=view-server
EGERIA_USER=erinoverview
EGERIA_USER_PASSWORD=secret
EGERIA_LOCAL_QUALIFIER=PDRBecause of the centralized configuration, you can often initialize a client without any arguments if your environment is set up:
from pyegeria import EgeriaTech
# Automatically picks up server, url, user, etc. from configuration
client = EgeriaTech()
# Create a bearer token (uses credentials from config)
client.create_egeria_bearer_token()
# Use any of the available methods
assets = client.list_assets()For most users, the role-based facade clients are the easiest way to start:
EgeriaTech: For technical users (data engineers, scientists). IncludesAssetCatalog,DataDesigner,GlossaryManager, and more.EgeriaCat: For catalog-oriented tasks. CombinesAssetCatalog,GlossaryManager,ProjectManager, andMyProfile.EgeriaConfig: For platform and server configuration.EgeriaOps: For operational monitoring and management.
The facade clients use lazy loading. Sub-clients (like GlossaryManager inside EgeriaTech) are only instantiated when you first access a method or attribute belonging to them. This keeps the initial footprint small.
client = EgeriaTech()
# GlossaryManager is NOT yet instantiated
client.list_glossaries()
# GlossaryManager is now instantiated and cachedIn Egeria, most elements require a unique qualifiedName. pyegeria provides a helper method __create_qualified_name__ (available on all OMVS clients) to help generate these consistently.
# Generates "PDR::Glossary::My-New-Glossary"
# (assuming EGERIA_LOCAL_QUALIFIER=PDR)
qname = client.__create_qualified_name__("Glossary", "My New Glossary")The helper:
- Prepends the
local_qualifier(if set). - Uses the provided type name.
- Cleans the display name (strips whitespace, replaces spaces with hyphens).
You can also use individual OMVS clients directly if you only need a specific service:
from pyegeria.omvs.glossary_manager import GlossaryManager
# Still supports automatic configuration
glossary_client = GlossaryManager()Most methods have an underlying asynchronous implementation (prefixed with _async_). While the public API is generally synchronous for ease of use in scripts and notebooks, you can use the async versions if building an asynchronous application:
import asyncio
from pyegeria import EgeriaTech
async def main():
client = EgeriaTech()
client.create_egeria_bearer_token()
# Use the async variant
assets = await client._async_find_in_asset_domain("*")
print(assets)
asyncio.run(main())pyegeria defines a hierarchy of exceptions in pyegeria.core._exceptions. It is recommended to catch PyegeriaException for general error handling:
from pyegeria.core._exceptions import PyegeriaException
try:
client.create_glossary(name="ExistingGlossary")
except PyegeriaException as e:
print(f"An error occurred: {e}")