semantic_log_generator
Python package to build SEGB-compatible RDF logs and publish them to the centralized backend.
Compatibility
- Python: 3.10, 3.11, 3.12
- License: Apache-2.0
- Versioning: Semantic Versioning (see
CHANGELOG.md)
What It Does
- Maps robot runtime facts to RDF triples
- Uses SEGB + PROV + ORO + ONYX + MLS + SOSA vocabularies
- Supports shared-event/shared-context linking across robots
- Publishes TTL payloads to backend
/ttl - Emits
schema:providerlinks as resources (URI or materializedschema:Organization), not literals
What It Does Not Do
- Sensor acquisition
- ROS transport/orchestration
- Robot decision making
- KG reasoning
Install
From PyPI (when available)
python -m pip install semantic-log-generator
From TestPyPI (current published channel)
python -m pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
"semantic-log-generator>=1.0.5,<2.0.0"
From GitHub subdirectory
python -m pip install "git+https://github.com/gsi-upm/segb.git@<tag_or_commit>#subdirectory=packages/semantic_log_generator"
Quick Example
from datetime import datetime, timezone
from semantic_log_generator import ActivityKind, SemanticSEGBLogger
robot_id = "r1"
# base_namespace is generated by your application/deployment config.
# End users do not need to manipulate RDF/Turtle details.
base_namespace = f"https://example.org/segb/robots/{robot_id}/"
logger = SemanticSEGBLogger(
base_namespace=base_namespace,
robot_id=robot_id,
)
logger.log_activity(
activity_id="listen_1",
activity_kind=ActivityKind.LISTENING,
started_at=datetime.now(timezone.utc),
)
ttl = logger.serialize(format="turtle")
Main APIs
SemanticSEGBLoggerSEGBPublisherHTTPSharedContextResolverActivityKind,RobotStateSnapshot,EmotionScore,ModelUsage
Shared Context (Cross-Robot)
SemanticSEGBLogger does not auto-read environment variables and does not call
POST /shared-context/resolve unless you pass a resolver explicitly.
To enable backend shared-context resolution, create a resolver and inject it:
from semantic_log_generator import SemanticSEGBLogger, build_http_shared_context_resolver_from_env
robot_id = "r1"
base_namespace = f"https://example.org/segb/robots/{robot_id}/"
resolver = build_http_shared_context_resolver_from_env()
logger = SemanticSEGBLogger(
base_namespace=base_namespace,
robot_id=robot_id,
shared_event_resolver=resolver,
)
Environment variables for build_http_shared_context_resolver_from_env():
- General SEGB API configuration (recommended):
SEGB_API_URLSEGB_API_TOKEN(only when backend auth is enabled)
- Optional:
SEGB_SHARED_CONTEXT_TIMEOUT_SECONDS(must be> 0, default5.0)SEGB_SHARED_CONTEXT_VERIFY_TLS(true/false, defaulttrue)SEGB_SHARED_CONTEXT_RAISE_ON_ERROR(true/false, defaultfalse)
Shared Event RDF Shape
- Shared events are serialized as
schema:Eventandprov:Entity. event_kindandmodalityare still used for resolver/fingerprint logic, but are not emitted asschema:eventType/schema:measurementTechnique.- When
modalityis provided, the logger emits asosa:Observationlinked to the shared event with:sosa:hasFeatureOfInterest(the shared event)sosa:usedProcedure(procedure resource labelled with modality, e.g.speech)sosa:resultTimesosa:hasSimpleResult(when text is available)
- Observation-to-shared-event confidence is emitted as
schema:additionalProperty(schema:PropertyValuewithschema:propertyID="shared_event_confidence").
Robot State RDF Shape
- Robot state snapshots are emitted as entities with
schema:PropertyValuenodes. - State properties are linked with
schema:additionalProperty. - State location is linked with
prov:atLocation.
Related Docs
- Installation guide:
docs/package/installation.md - Usage guide:
docs/package/usage.md - Internal TTL generation:
docs/internals/ttl-generation.md
Tests
Package-specific tests are in packages/semantic_log_generator/tests/unit.
PYTHONPATH=packages/semantic_log_generator/src:apps/backend/src ./.venv/bin/python -m unittest discover -s packages/semantic_log_generator/tests/unit -p 'test_*.py'
Metadata
Release files for semantic-log-generator 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| semantic_log_generator-1.0.5.tar.gz | 25.8 kB | Without provenance | Details for semantic_log_generator-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| semantic_log_generator-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for semantic_log_generator-1.0.5-py3-none-any.whl |
Total release size: 54.2 kB
Release files / semantic_log_generator-1.0.5.tar.gz
| Download URL | semantic_log_generator-1.0.5.tar.gz |
|---|---|
| Size | 25.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
935af60a5e3e8b59d1460e2f8e0fb38283c4ea626af91183869e699d6cc553ae
|
|
BLAKE2b-256 checksum How to use checksums |
d45fb7ae3356b7ce84c2b01c274e9b6f26a08d64f474bf1860244c2ba268a719
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Release files / semantic_log_generator-1.0.5-py3-none-any.whl
| Download URL | semantic_log_generator-1.0.5-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
142b3055e9d53a44110d7fb76f56e5de56bd20f7c9fb5700162afc77727b8d28
|
|
BLAKE2b-256 checksum How to use checksums |
eea64803d003d1ee98850e367325272b19d2a2e44bcefb9364ec1729a3f89d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.3
|
Security for semantic-log-generator 1.0.5
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.