aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-16 21:41:20 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-16 21:41:20 +0100
commit3504609e1ba1f7f653fa79910474bebd3ec24d8a (patch)
treed94cdf7ac540eb82630f78cbf564682b66007f51 /bsfs
parent76fa694911f54e293ddf517246c6c4a1e8e745fd (diff)
downloadbsfs-3504609e1ba1f7f653fa79910474bebd3ec24d8a.tar.gz
bsfs-3504609e1ba1f7f653fa79910474bebd3ec24d8a.tar.bz2
bsfs-3504609e1ba1f7f653fa79910474bebd3ec24d8a.zip
various minor fixes
Diffstat (limited to 'bsfs')
-rw-r--r--bsfs/query/validator.py4
-rw-r--r--bsfs/schema/serialize.py18
-rw-r--r--bsfs/triple_store/sparql/sparql.py2
-rw-r--r--bsfs/utils/errors.py3
4 files changed, 18 insertions, 9 deletions
diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py
index 1b7f688..904ac14 100644
--- a/bsfs/query/validator.py
+++ b/bsfs/query/validator.py
@@ -189,9 +189,7 @@ class Filter():
# reference matches type_
if len(node.reference) != type_.dimension:
raise errors.ConsistencyError(f'reference has dimension {len(node.reference)}, expected {type_.dimension}')
- # FIXME:
- #if node.reference.dtype != type_.dtype:
- # raise errors.ConsistencyError(f'')
+ # FIXME: test dtype
## conditions
diff --git a/bsfs/schema/serialize.py b/bsfs/schema/serialize.py
index 8b31737..acc009a 100644
--- a/bsfs/schema/serialize.py
+++ b/bsfs/schema/serialize.py
@@ -35,8 +35,11 @@ def from_string(schema_str: str) -> schema.Schema:
graph.parse(data=schema_str, format='turtle')
# helper functions
- # FIXME: type annotation
- def _fetch_value(subject: URI, predicate: rdflib.URIRef, value_factory) -> typing.Optional[typing.Any]:
+ def _fetch_value(
+ subject: URI,
+ predicate: rdflib.URIRef,
+ value_factory: typing.Callable[[typing.Any], typing.Any],
+ ) -> typing.Optional[typing.Any]:
"""Fetch the object of a given subject and predicate.
Raises a `errors.ConsistencyError` if multiple objects match.
"""
@@ -242,9 +245,14 @@ def to_string(schema_inst: schema.Schema, fmt: str = 'turtle') -> str:
for triple in _parse(node):
graph.add(triple)
# add known namespaces for readability
- # FIXME: more systematically (e.g. for all in ns?)
- graph.bind('bsfs', rdflib.URIRef('http://bsfs.ai/schema/'))
- graph.bind('bse', rdflib.URIRef('http://bsfs.ai/schema/Entity#'))
+ # FIXME: more generically?
+ graph.bind('bse', rdflib.URIRef(ns.bse['']))
+ graph.bind('bsfs', rdflib.URIRef(ns.bsfs['']))
+ graph.bind('bsm', rdflib.URIRef(ns.bsm['']))
+ graph.bind('rdf', rdflib.URIRef(ns.rdf['']))
+ graph.bind('rdfs', rdflib.URIRef(ns.rdfs['']))
+ graph.bind('schema', rdflib.URIRef(ns.schema['']))
+ graph.bind('xsd', rdflib.URIRef(ns.xsd['']))
# serialize to turtle
return graph.serialize(format=fmt)
diff --git a/bsfs/triple_store/sparql/sparql.py b/bsfs/triple_store/sparql/sparql.py
index dfd9871..fedd227 100644
--- a/bsfs/triple_store/sparql/sparql.py
+++ b/bsfs/triple_store/sparql/sparql.py
@@ -132,7 +132,7 @@ class SparqlStore(base.TripleStoreBase):
if isinstance(cand, bsc.Feature) and cand.distance not in DISTANCE_FU}
if len(invalid) > 0:
cand, dist = zip(*invalid)
- raise ValueError(
+ raise errors.UnsupportedError(
f'unknown distance function {",".join(dist)} in feature {", ".join(cand)}')
# commit the current transaction
diff --git a/bsfs/utils/errors.py b/bsfs/utils/errors.py
index be9d40e..6ae6484 100644
--- a/bsfs/utils/errors.py
+++ b/bsfs/utils/errors.py
@@ -41,4 +41,7 @@ class ConfigError(_BSFSError):
class BackendError(_BSFSError):
"""Could not parse an AST structure."""
+class UnsupportedError(_BSFSError):
+ """Some requested functionality is not supported by an implementation."""
+
## EOF ##