Ontology Operations
Upload Ontology
The upload_ontology function allows you to upload an ontology file to the Perseus server.
Synchronous
upload_ontology
def upload_ontology(ontology_path: str) -> Ontology:Uploads an ontology and returns an Ontology object.
Arguments
| Name | Type | Description |
|---|---|---|
ontology_path | str | The local path to the ontology file to upload. |
Returns
| Type | Description |
|---|---|
Ontology | An Ontology object representing the uploaded ontology. |
Example
import perseus_client
try:
ontology = perseus_client.upload_ontology("./path/to/your/ontology.owl")
print(f"Ontology uploaded successfully with ID: {ontology.id}")
except Exception as e:
print(f"An error occurred: {e}")Asynchronous
upload_ontology_async
async def upload_ontology_async(ontology_path: str) -> Ontology:Asynchronously uploads an ontology and returns an Ontology object.
Arguments
| Name | Type | Description |
|---|---|---|
ontology_path | str | The local path to the ontology file to upload. |
Returns
| Type | Description |
|---|---|
Ontology | An Ontology object representing the uploaded ontology. |
Example
import asyncio
import perseus_client
async def main():
try:
ontology = await perseus_client.upload_ontology_async("./path/to/your/ontology.owl")
print(f"Ontology uploaded successfully with ID: {ontology.id}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
await perseus_client.close_async()
if __name__ == "__main__":
asyncio.run(main())