GetObjectPropertiesFromClassWorkflow
What it is
- A workflow that loads an OWL ontology (from a Turtle file or from a triple store schema graph) and returns OWL object properties whose domain matches a given class URI.
- Outputs object properties with their labels and range information, including basic handling of complex OWL class expressions (
unionOf,intersectionOf,complementOf) mapped to logical operators (or,and,not).
Public API
Configuration
GetObjectPropertiesFromClassWorkflowConfiguration(WorkflowConfiguration)triple_store: ITripleStoreService- triple store service used whenontology_file_pathis not provided.ontology_file_path: Optional[str] = None- path to a Turtle ontology file to parse with RDFLib.
Parameters
GetObjectPropertiesFromClassWorkflowParameters(WorkflowParameters)class_uri: str- required; must match pattern^http.*.
Workflow
GetObjectPropertiesFromClassWorkflow(Workflow)-
get_object_properties_from_class(parameters) -> dict- Validates the URI is an
owl:Class. - Finds all
owl:ObjectPropertyin the graph. - Selects those whose (mapped) domain contains the class URI (supports simple
or/anddict structures). - Returns:
{"class_uri": ..., "object_properties": [{"object_property_uri", "object_property_label", "ranges"}...]}
- Validates the URI is an
-
as_tools() -> list[BaseTool]- Exposes the workflow as a LangChain
StructuredToolnamedget_object_properties_from_class.
- Exposes the workflow as a LangChain
-
as_api(...) -> None- Present but not implemented (always returns
None).
- Present but not implemented (always returns
-
Helper methods (non-API but callable)
get_linked_classes(cls_id, rel_type=None)- Recursively expands OWL list structures and class expression nodes for
unionOf,intersectionOf,complementOf.
- Recursively expands OWL list structures and class expression nodes for
map_ranges_domains(x)- Maps
domain/rangeitems: if not an HTTP URI, attempts to expand viaget_linked_classes.
- Maps
is_class(uri) -> bool- Checks
(uri, rdf:type, owl:Class)membership in the graph. - Prints the entire graph serialized as Turtle (side-effect).
- Checks
_class_matches_domain(class_uri, domains) -> bool- Checks whether the class is in a domain list or inside simple
{"or": [...]}/{"and": [...]}.
- Checks whether the class is in a domain list or inside simple
_process_ranges(ranges) -> list- Converts range URIs into
{"uri": ..., "label": ...}and recurses throughor/and/notstructures.
- Converts range URIs into
Configuration/Dependencies
- Requires:
rdflib(Graph,URIRef,RDF,RDFS,OWL)pydashpydantic(for parameter validation)langchain_core.tools(foras_tools)naas_abi_coreworkflow base classes andITripleStoreService
- Ontology source:
- If
ontology_file_pathis set:Graph.parse(..., format="turtle") - Else:
configuration.triple_store.get_schema_graph()must return an RDFLib-like graph.
- If
Usage
Direct workflow call
from naas_abi.workflows.GetObjectPropertiesFromClassWorkflow import (
GetObjectPropertiesFromClassWorkflow,
GetObjectPropertiesFromClassWorkflowConfiguration,
GetObjectPropertiesFromClassWorkflowParameters,
)
# Provide an ITripleStoreService instance from your environment
triple_store_service = ...
wf = GetObjectPropertiesFromClassWorkflow(
GetObjectPropertiesFromClassWorkflowConfiguration(
triple_store=triple_store_service,
ontology_file_path=None, # or "path/to/ontology.ttl"
)
)
result = wf.get_object_properties_from_class(
GetObjectPropertiesFromClassWorkflowParameters(
class_uri="http://purl.obolibrary.org/obo/BFO_0000015"
)
)
print(result["class_uri"])
print(len(result["object_properties"]))
As a LangChain tool
tools = wf.as_tools()
tool = tools[0]
out = tool.run({"class_uri": "http://purl.obolibrary.org/obo/BFO_0000015"})
print(out)
Caveats
is_class()prints the entire graph serialized as Turtle, which can be very large and noisy.- Class-expression support is limited to
unionOf,intersectionOf,complementOfstructures discovered via internal preprocessing; domain matching only checks for:- exact string match, or
- membership in simple
{"or": [...]}/{"and": [...]}dicts (no deeper semantic reasoning).
as_api()is a stub and does not register any routes.