Build ontologies in Python
Construct object classes, classifications, attributes, options, and nested conditional logic.
from unitlab import (
OntologyStructure, RadioAttribute, Shape,
)
structure = OntologyStructure()
cat = structure.add_object("Cat", Shape.BOUNDING_BOX, color="#F59E0B")
colour = cat.add_attribute(RadioAttribute, "Colour", required=True)
black = colour.add_option("Black")
black.add_nested_attribute(RadioAttribute, "Pattern").add_option("Solid")
print(structure.to_dict())
ontology = client.ontologies.create("Cat labels", structure=structure)Public attribute types are RadioAttribute, ChecklistAttribute, TextAttribute, and NumericAttribute. dynamic=True marks time-varying values where supported. Create classifications with add_classification(level=...). Validate the serialized structure before publishing it into active project work.
Operating contract
Execution surface
Pinned unitlab==3.1.6 application environment on Python 3.10+.
Identity
Least-privilege API key supplied through approved configuration.
Target resolution
Stable resource IDs and an explicitly bounded target set.
Success evidence
Typed return fields, server-side state, and downstream acceptance of the result.
Failure and recovery boundary
Authentication or authorization fails
Stop, correct the service identity or access model, rotate exposed credentials, and rerun a read-only check.
Validation or entitlement rejects the operation
Correct the input or entitlement; do not retry an unchanged request.
A request times out
Inspect remote state before repeating a mutation because the server may have accepted it.
Asynchronous processing exceeds its deadline
Preserve the Batch Queue or release ID, continue bounded monitoring, and inspect item-level failures.
Only part of a batch succeeds
Keep successful identifiers, isolate failed rows, and retry only the corrected subset.
Explore related Unitlab capabilities: AI training-data annotation