Ontologies#

A central component of a project is the ontology - an in-depth description of which can be found here.

Ontologies are top-level entities that can be attached to projects that provide a template structure for labels. Please note that while a project can only have a single ontology attached to it, one ontology can be attached to multiple projects.

  • To access the ontology you can use the get_ontology() method, that allows you to work with its structure property.

  • The structure comes as the OntologyStructure class which has good self documenting examples on how to be used.

This section will cover some of the most common use-cases for ontologies.

Copying an ontology#

Copying an ontology allows you to make changes to the stucture without affecting the projects the original ontology is attached to.

from encord import EncordUserClient

user_client: EncordUserClient = EncordUserClient.create_with_ssh_private_key(
    "<your_private_key>"
)

ontology = user_client.get_ontology("<ontology_hash>")
new_ontology = user_client.create_ontology(
    "copy ontology",
    description="<my ontology description>",
    structure=ontology.structure,
)