Skip to content

(WIP) Enabling of Knowledge Layer#50

Merged
slawr merged 81 commits intoCOVESA:mainfrom
chrizmc:feature/enabling-of-knowledgelayer
May 8, 2025
Merged

(WIP) Enabling of Knowledge Layer#50
slawr merged 81 commits intoCOVESA:mainfrom
chrizmc:feature/enabling-of-knowledgelayer

Conversation

@chrizmc
Copy link
Collaborator

@chrizmc chrizmc commented Jun 3, 2024

This PR is intended to commit the first basic components that enable a knowledge layer in the CDSP

Copy link
Collaborator

@slawr slawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @claireqiu, thinking to the future it would be good to get a little more information into the commit messages. "add files" forces someone to look into the commit itself to find the nature of the change.

Something like "json-rdf-connector: add data struct and utils headers" or "add data struct and utils headers to json-rdf-connector" would be more informative.

Update: I notice there is good information in the PR comment.

@slawr
Copy link
Collaborator

slawr commented Jun 4, 2024

Great to see this work becoming public and new functionality being added to the Playground itself.

When we first discussed the Knowledge Layer Connector in the May 21st call I remember that we debated whether the Information Layer part should be parallel to the Knowledge Layer part or under it. One point of concern was that in parallel it might be interpreted as an abstraction layer and that whilst it can do that, it would have potentially high performance consequences for latency, high frequency data and ability to access advanced DB queries.

To be honest I do not recall and it is not recorded in the minutes if we came to a conclusion. I do recall saying that one possible approach would be to keep it as presented here and be careful in documenting the circumstances for its use. Also that we might not limit ourselves to it whilst developing the connector as performance was an attribute we were interested in.

So what am I saying? I think we need to be clear on how we are approaching this and the planning should reflect it.

@chrizmc
Copy link
Collaborator Author

chrizmc commented Jun 5, 2024

I understand what you mean. One disadvantage of a structure like this
-knowledge layer
-- information layer
could be that you might think that the information layer can only be used together with the knowledge layer. But in the case of RealmDB (maybe also for IoTDB or other DBs), the websocket IF on the information layer can also be used by a simple UI app or something, without "starting" and using the knowledge layer.

But yes, I agree, we should be clear about how we want to do it....

@slawr
Copy link
Collaborator

slawr commented Jun 6, 2024

I understand what you mean. One disadvantage of a structure like this -knowledge layer -- information layer could be that you might think that the information layer can only be used together with the knowledge layer. But in the case of RealmDB (maybe also for IoTDB or other DBs), the websocket IF on the information layer can also be used by a simple UI app or something, without "starting" and using the knowledge layer.

Agreed. I think you would do something like that if you were communicating that at the current state of development it is specified for the demands of the knowledge layer connector. Moving it later as it evolves. However as you go onto say that might confuse people who would like to use it for other purposes.

I understand that point. Also of course in terms of having a workaround for the fact that Realm is an Embedded Application Database normally bound into a specific application.

But yes, I agree, we should be clear about how we want to do it....

I think for me it is a possible communications issue around explaining the playground and avoidance of people grossly under utilising the tool-set.

I think it's great that this PR already contains some documentation.
Of course doc will always be a challenge.
When I read the root readme for the info layer it authoritatively states the components for the playground info layer are the database handlers and router. It goes on to say data access is through this web socket server and that Realm is the single database supported.
From the viewpoint of the existing BMW UX app development and in the context of the connector I think this is good documentation but it doesn't put it in context for the more general case.
For example:
Does this WS server handle a broad range of use cases? Is it simple single key/value get/set only for example?
How does it handles complex queries?
The Playground presented at the Autumn AMM discussed in part the possibilities of TS DBs, then if this was merged as it is now people could be confused by discussion of data access through this WS and IoTDB is not supported, but a new DB Realm is..

If I'm someone from one of the COVESA BoFs what do I understand about data access in the Playground in reading this?

Of course a balance in doc needs to be struck. We are not a supplier and people need to put some effort in.

I've not thought about it deeply, but one approach could be a large info box at the top putting the rest of the doc in context. This was developed for X,Y, Z requirements, if your requirements are different then you may consider using other means such as directly accessing a component.

Does that make sense?

@chrizmc chrizmc force-pushed the feature/enabling-of-knowledgelayer branch 2 times, most recently from 443a609 to 2407bf3 Compare June 19, 2024 12:04
chrizmc and others added 13 commits June 19, 2024 14:32
Signed-off-by: chrizmc <muehlbauer.cc@gmail.com>
…lmdb-handler including some resdme updates

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: haonan-qiu <claireqiu2012@gmail.com>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
@sschleemilch sschleemilch force-pushed the feature/enabling-of-knowledgelayer branch from 2407bf3 to 0da163a Compare June 19, 2024 12:38
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Copy link
Collaborator

@slawr slawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a requirement for merging but for the actual code modules you might consider adding SPDX information in a header to allow automation of license handling.

Here is an example: https://github.com/slawr/cdsp/blob/iotdb-udf-grafana/docker/iotdb/Dockerfile

    Use dotenv package to laod environment variables from a .env file into the process.env
    Rename files and update code
    Remove unused file

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
@chrizmc
Copy link
Collaborator Author

chrizmc commented Jul 10, 2024

We will have a look into SPDX, thank's for the hint.

chrizmc added 3 commits July 24, 2024 12:23
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Add git ignore for the docker generated files
Add Read method to IoTDBHandler
Rename Data Type Object
Apply format and remove invalid comment
Optimize code to standarize the response between handlers.
Repair documentation for the project configuration
Add anonym data
Manage Sessions
Add Write method add client message data to IoTDB

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Return messages to all clients when write in IoTDB
Update IoTDB supported fields and documentation
Update read dependencies and send error to clients
Add read messaging in RealmDB
Resolve Ajv warining about fields with multiple types
Add subcribe message handling
Remove unused import
Repair findings

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Copy link
Collaborator

@slawr slawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial review comments

Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Fix: Remove extra 'dot' from endpoint into update message.
Fix unknown function issue

Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
chrizmc and others added 5 commits March 5, 2025 08:23
…st of objects.

    Implement subscription on data field level for IotDB

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
… finished yet.

    Refactor websocket-server to be better readable

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
Signed-off-by: Sebastian Schleemilch <sebastian.schleemilch@bmw.de>
chrizmc and others added 18 commits March 26, 2025 09:49
…SUBSCRIBED clients. Always include the received timestamp to metadata.

Make sure that IL expects schema and path fields as sub path of data points, not just a prefix.
Enable IL (IotDB only) to store metadata for valid datapoints on SET request.
Make rl-bridge send generated timestamps of each datapoint as metadata to IL.
Rename nanoseconds field to nanos in all IL messages.

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Updated timestamp formatting:
Now includes 9-digit nanoseconds appended to the observation identifier.
Ensures leading zeros are retained in the nanoseconds value.
Modified Helper::extractNanoseconds to guarantee a consistent 9-digit output.
Adjusted triple generation logic to incorporate nanoseconds correctly into the observation identifier.
Refactored tests to verify the new identifier format.

Signed-off-by: q632394 <haonan.qiu@bmw.de>
… api key have not been provided.

    Move aggressive driving example into the knowledgelayer-hello-world folder. Add first part of `Installation and Running` documentation to the readme of the example.
    Let IL make sure that the needed database for IotDB is available after successful client connections.
    Dockerize RemotiveLabs python script rl-bridge.py. Create first template for an example (aggressive driving detection) that starts multiple services and binds correct volumes.
    Add to rl-bridge infinite retries for connecting to Remotive Labs to make the startup process more stable
    Make Information Layer url overwritable with arguments in the rl-bridge script, so it can be set on script startup.
    Remove obsolete hostname configuration because it is per default set to container_name.

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
…the logic for finding the latest data point values to the IotDB.

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
This PR enables the WebSocket client to send inferred data—based on reasoning engine results—back to the WebSocket server using the SET method. It covers end-to-end integration, including DTO generation, data transformation, and validation through unit and integration tests.
Summary of Work Completed in This PR
• Added BoToDTO integration test to verify Business Object to DTO transformation logic
• Extended BoService tests to cover GetMessage, SubscribeMessage, and SetMessage creation
• Implemented logic to generate SetMessageDTO from Business Objects
• Ensured SetMessageDTO is structured according to the DASH API SET format
• Successfully sent SetMessage back to the WebSocket server with proper structure
• Metadata now includes both seconds and nanoseconds (for higher resolution timestamps)
• Introduced proper schema extraction based on class name in the inferred triples to create the new generated Data Points
• Refactored message creation into service layer for separation of concerns and testability
• Simplified and standardized WebSocket message format (defaulted to flat)
• Updated InitReasonerFactory unit tests to verify ontology behavior
• Added unit test to verify parsing of JSON reasoning result into SetMessageDTO
• Updated README and documentation to reflect system behavior and usage instructions
• Verified logs include query executions and sent messages for debugging and traceability
• Ensured system logs and continues gracefully if SPARQL query fails
• Exceptions are thrown when ontology uploads fail, consistent with rules behavior
• Added support for handling multiple rows in reasoning query results:
• Each row is transformed into an individual message
• Messages are grouped by schema and sent accordingly
• Data points that cannot be mapped to a schema are logged as errors
• Added CLI developer option to clear the RDFox dataset on application startup
• Removed obsolete code and improved consistency across services and tests
Important tests:
	• Json Writer Unit and Integration tests
	• BO Service Integration Test
	• BO To DTO Integration Test
	• Reasoner Factory Integration Test

   Add missing library

    Update Readme with the correct naming of the ENV variables

 #   Merge remote-tracking branch 'origin/feature/enabling-of-knowledgelayer' into ESSENCE-784/Websocket_Client_Sends_Inferred_Data_Back_to_Websocket_Server

 #   Extract message creation into the corresponding service

 #   Remvoe unnecessary code

 #   Send set message back to weboscket server

 #   Use schema in the JSON result of the reasoning query and update the output for the JSON file

 #   Update console helper and add development options in application

 #   Add data property to observation id in the triple

 #   remove unnecessary code

 #   Make the query and rules work with the ttl data

 #   Symplify function to mangage different messaging types. Execute the reasoning query after each incomming message. Symplify reasoning query service. Ajust test of the json writer to be shure that it works as expected. Repair the SetMessageDTO passing with the expected JSON.

 #   Add SetMesseage DTO and BO, add reasoning query service and load the reasoning queries into the model config BO

 #   Load ontologies in Reasoner Engine

 #   Apply review changes

Signed-off-by: q632394 <haonan.qiu@bmw.de>
…h the C4 Diagrams. Mostly Websocket-Server was changed to Information-Layer(-Server) to reflect the responsibility of the component instead of the technology it is using.

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
This PR introduces support for an extended reasoning result format to be used in the JSON output and SetMessage creation pipeline. The format is controlled by the boolean flag IS_AI_Reasoner_Inference_Results defined in the model_config.json. When enabled, the output will wrap schema results in a stringified JSON object under the key AI.Reasoner.InferenceResults.

This change affects the entire reasoning-to-SetMessage flow and introduces flexible formatting logic for downstream integration (e.g., with Information Layer).

Conditional formatting of JSON results based on the IS_AI_Reasoner_Inference_Results flag
Support in JSONWriter::writeToJson() for both normal and inference-wrapped formats
Parameter loaded from model_config.json and injected into processing pipeline
Added explanation in README about how this parameter behaves
Date Time is added to the console logs in order to see, when the events happen
Add ENV variable to set the target URI for the Websocket Server
Related tests:

json_writer_integration_test
json_writer_unit_test
model_config_dto_service_unit_test

Signed-off-by: q632394 <haonan.qiu@bmw.de>
…fast working setup in case environment variable IOTDB_POLL_INTERVAL_LEN_IN_SEC is not provided.

    Fix IL GET request handling of string data points.
    Add Vehicle.AI.Reasoner.InferenceResults data point to VSS configuration.
    Adjust IL error message if unknown data points are provided.
    Add Knowledge-Layer and it dependencies to the hello world example docker compose, so all relevant services are started for a roundtrip. Finish `Installation and Running` chapter in the hello world example readme.

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
 Avoid to use CMake ENV variables into classes

Signed-off-by: Haonan Qiu <haonan.qiu@bmw.de>
commit 854d92d025f358853fd4489930efc5efec365dba
Author: Juan Camacho (ext.) <juan.camacho@partner.bmw.de>
Date:   Wed Apr 9 11:59:49 2025 +0200

    FIX: Simplified Project Root Handling

Signed-off-by: Haonan Qiu <haonan.qiu@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
Signed-off-by: Haonan Qiu <haonan.qiu@bmw.de>
Signed-off-by: Christian Muehlbauer <36862281+chrizmc@users.noreply.github.com>
Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
@chrizmc chrizmc requested a review from slawr May 8, 2025 11:44
Copy link
Collaborator

@slawr slawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst there are some review comments outstanding the maintainers have agreed there are no known show stoppers and it is preferable to get this large change set merged and to then make improvements

Signed-off-by: Christian Muehlbauer <christian.cm.muehlbauer@bmw.de>
@slawr slawr merged commit 5ac37e3 into COVESA:main May 8, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Central Data Service Playground May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request task Task not fitting other labels, e.g. project ops

Projects

Development

Successfully merging this pull request may close these issues.

6 participants