GetObjectPropertiesFromClassWorkflow
What it is
A workflow that loads an OWL/RDF ontology (from a Turtle file or a triple store schema graph) and returns all OWL object properties whose domain matches a given class URI, including simple handling for domain expressions (e.g., unionOf / intersectionOf / complementOf mapped to or / and / not).
Public API
-
GetObjectPropertiesFromClassWorkflowConfiguration- Purpose: Configure the workflow.
- Fields:
triple_store: ITripleStoreService(required) — used when no ontology file is provided.ontology_file_path: Optional[str]— path to a Turtle ontology file; when set, it is parsed into an RDFLibGraph.
-
GetObjectPropertiesFromClassWorkflowParameters- Purpose: Input parameters for execution.
- Fields:
class_uri: str— must match^http.*(validated by Pydantic).
-
GetObjectPropertiesFromClassWorkflow(configuration)- Purpose: Loads the ontology into an RDF graph and prepares internal indices for class/property traversal.
-
GetObjectPropertiesFromClassWorkflow.get_object_properties_from_class(parameters) -> dict- Purpose: For a given class URI, returns matching object properties.
- Output shape:
{"class_uri": <str>, "object_properties": [{"object_property_uri": <str>, "object_property_label": <str>, "ranges": <processed ranges>}, ...]}
- Notes:
- Validates the input URI is an
owl:Classin the loaded graph; otherwise raisesValueError. - Matches properties typed as
owl:ObjectProperty. - Domain matching supports:
- direct string match to
class_uri - simple
{"or": [...]}and{"and": [...]}dicts produced by internal parsing.
- direct string match to
- Validates the input URI is an
-
GetObjectPropertiesFromClassWorkflow.as_tools() -> list[BaseTool]- Purpose: Exposes the workflow as a LangChain
StructuredToolnamedget_object_properties_from_class.
- Purpose: Exposes the workflow as a LangChain
-
GetObjectPropertiesFromClassWorkflow.as_api(...) -> None- Purpose: API exposure stub; currently does nothing and returns
None.
- Purpose: API exposure stub; currently does nothing and returns
Configuration/Dependencies
- Requires an
ITripleStoreServiceimplementation (fromnaas_abi_core.services.triple_store). - Ontology source:
ontology_file_path(Turtle) parsed viardflib.Graph.parse(..., format="turtle"), ortriple_store.get_schema_graph()whenontology_file_pathis not provided.
- Key libraries:
rdflib(Graph, RDF/OWL/RDFS vocabulary)pydash(used for collection utilities)pydantic(parameter validation)langchain_core(tool wrapper)
Usage
from naas_abi import ABIModule
from naas_abi_core.engine.Engine import Engine
from naas_abi.workflows.GetObjectPropertiesFromClassWorkflow import (
GetObjectPropertiesFromClassWorkflow,
GetObjectPropertiesFromClassWorkflowConfiguration,
GetObjectPropertiesFromClassWorkflowParameters,
)
engine = Engine()
engine.load(module_names=["naas_abi"])
workflow = GetObjectPropertiesFromClassWorkflow(
GetObjectPropertiesFromClassWorkflowConfiguration(
triple_store=ABIModule.get_instance().engine.services.triple_store,
# ontology_file_path="path/to/ontology.ttl", # optional
)
)
result = workflow.get_object_properties_from_class(
GetObjectPropertiesFromClassWorkflowParameters(
class_uri="http://purl.obolibrary.org/obo/BFO_0000015"
)
)
print(result)
Caveats
is_class()prints the entire graph serialized as Turtle (print(self.graph.serialize(...))), which can be very noisy/expensive for large ontologies.- Domain/range expression handling is limited to structures derived from
unionOf,intersectionOf, andcomplementOf, mapped toor,and,not. as_api()is a no-op (no routes are registered).