Skip to main content

souslesens

Python client for the SousLesSensVocables API.

Installation

pip install souslesens

Quick start

from souslesens import SlsClient

client = SlsClient(token="xxx", base_url="http://localhost:3010")
client.health()
client.ask.knowledge_model_graph("ISO-14224-IOF")

API

Each method mirrors the API path it calls. The /api/v1/ask/... endpoints live under client.ask.

Method Description
SlsClient(token, base_url="http://localhost:3010") Client for the SousLesSensVocables API. base_url defaults to the local backend port.
health() -> dict Calls GET /api/v1/health. Returns the parsed body ({"health": {...}}) whether the status is 200 or 500.
ask.knowledge_model_graph(source_label) -> dict GET /api/v1/ask/knowledgeModelGraph. Returns a {"nodes": [...], "edges": [...]} graph of the source's main concepts and their relations.
ask.linked_classes(source_label, uri1, uri2=None) -> dict GET /api/v1/ask/linkedClasses. Returns a map class URI -> relations for the given class URI (optionally restricted to the relations reaching uri2).
ask.term_classes_infos(source_label, term) -> dict GET /api/v1/ask/termClassesInfos. Returns a map class URI -> {id, label, ancestors, predicates, relations} for every class whose label matches term.
ask.terms_linked_classes(source_label, term1, term2=None) -> dict GET /api/v1/ask/termsLinkedClasses. Same as linked_classes but resolving the classes from plain words instead of URIs.
ask.two_terms_shortest_path(source_label, term1, term2) -> list GET /api/v1/ask/twoTermsShortestPath. Returns the chains of properties joining term1 and term2, each step being a [subject, property, object] list of {id, label} objects.
ask.ontology_summary() -> list GET /api/v1/ask/ontologySummary. Returns one {source, graphUri, imports, description} entry per source the caller may read that describes itself.
ask.uri_classes_infos(source_label, uri) -> dict GET /api/v1/ask/uriClassesInfos. Same description as term_classes_infos, starting from a class URI instead of a term.

Adding a new endpoint

A route inside an existing group (for example the /api/v1/ask/... endpoints under client.ask):

  1. Add a method to the group class in souslesens/client.py (e.g. Ask) that calls get_json(self._client.base_url, path, self._client.token, params=...).
  2. Mirror it in souslesens/testing.py: override the method in the mock group class (e.g. MockAsk) to delegate to self._client._get("<method_name>"), and add the default response to MockSlsClient.DEFAULT_RESPONSES.
  3. Add a test in tests/test_client.py asserting the URL and the params, then a row in the API table above.

A route in a new group (anything not under an existing one) needs a new group class, on the model of Ask:

  1. In client.py, define the class (its __init__ stores the client, one method per route) and instantiate it in SlsClient.__init__, next to self.ask = Ask(self).
  2. In testing.py, define a mock subclass overriding each method to delegate to self._client._get(...), add its default responses to DEFAULT_RESPONSES, and instantiate it in MockSlsClient.__init__.
  3. Add the same test and API table row.

Run uv run pytest then uv run ruff check.

Health response

The health value is a mapping of probed services to booleans (virtuoso, elasticsearch, spacyserver by default). The keys depend on the server-side health_enabled_services config.

data = client.health()
if data["health"] == "error":
    # server could not probe itself — see HealthCheckError below
    ...
if not all(data["health"].values()):
    # at least one upstream service is down
    ...

Exceptions

  • SlsClientError — base class for all client failures (network error, invalid JSON response).
  • HealthCheckError(SlsClientError) — the server returned {"health": "error"} (it could not probe itself).

Testing

A drop-in mock replaces SlsClient without any network calls. Inject the health payload and inspect recorded calls:

from souslesens.testing import MockSlsClient

client = MockSlsClient(health={"health": {"virtuoso": True, "elasticsearch": False, "spacyserver": True}})
data = client.health()  # returns the injected payload
assert client.calls == ["health"]

Development

uv run pytest
uv run pytest --cov
uv run ruff check
uv build

Metadata

Release files for souslesens 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for souslesens 0.3.0
File Size Uploaded Provenance
souslesens-0.3.0.tar.gz 32.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for souslesens 0.3.0
File Interpreter ABI Platform
souslesens-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.3 kB

Release files / souslesens-0.3.0.tar.gz

Download URL souslesens-0.3.0.tar.gz
Size 32.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a0ce92203572dd2a89441d7879cb7dff0509cb8a49a89134349cc3fef28457b3
BLAKE2b-256 checksum
How to use checksums
6999e7ddea3530ecdf24cf1117c215db7386c9de95ff3d5e5121a223e3c76660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / souslesens-0.3.0-py3-none-any.whl

Download URL souslesens-0.3.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2def61d226ea113143da4cebc527739461b09273fbb37030a9760ae3235a064c
BLAKE2b-256 checksum
How to use checksums
bac39c4f1c425d05a7a2e2e323df46bd846e7565d230e80a9d75a8331d3b88cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for souslesens 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page