Ontology Operations
Find Ontology
The find_ontology function allows you to retrieve a single ontology by its unique ID.
Synchronous
find_ontology
def find_ontology(id: str) -> Optional[Ontology]:Finds a single ontology by its ID.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The unique ID of the ontology. |
Returns
| Type | Description |
|---|---|
Optional[Ontology] | An Ontology object if found, otherwise None. |
Example
import perseus_client
try:
ontology = perseus_client.find_ontology("your_ontology_id")
if ontology:
print(f"Ontology found: {ontology.name}")
else:
print("Ontology not found.")
except Exception as e:
print(f"An error occurred: {e}")Asynchronous
find_ontology_async
async def find_ontology_async(id: str) -> Optional[Ontology]:Asynchronously finds a single ontology by its ID.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The unique ID of the ontology. |
Returns
| Type | Description |
|---|---|
Optional[Ontology] | An Ontology object if found, otherwise None. |
Example
import asyncio
import perseus_client
async def main():
try:
ontology = await perseus_client.find_ontology_async("your_ontology_id")
if ontology:
print(f"Ontology found: {ontology.name}")
else:
print("Ontology not found.")
except Exception as e:
print(f"An error occurred: {e}")
finally:
await perseus_client.close_async()
if __name__ == "__main__":
asyncio.run(main())