GithubHelp home page GithubHelp logo

Context-Broker not recognizing the mapping of same relationship type to multiple objects using python-ngsild-client about python-ngsild-client HOT 4 CLOSED

Miracle-lab avatar Miracle-lab commented on September 26, 2024
Context-Broker not recognizing the mapping of same relationship type to multiple objects using python-ngsild-client

from python-ngsild-client.

Comments (4)

fbattello avatar fbattello commented on September 26, 2024

Dear Miracle,

Fortunately I'm just working on the multiple-attr support.
ETSI specs have changed since I wrote this part of the library.

I've just committed to github.
May be you can try it directly from github : pip install git+https://github.com/Orange-OpenSource/python-ngsild-client

from ngsildclient import *

ctx = [
    "http://example.org/ngsi-ld/latest/commonTerms.jsonld",
    "http://example.org/ngsi-ld/latest/vehicle.jsonld",
    "http://example.org/ngsi-ld/latest/parking.jsonld",
    "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.5.jsonld",
]

e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown6"])

That way "object" is not repeated alone but the whole relationship is. Hope it could solve your issue.
You could also pass arrays for metadata.
For example :
e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown6"], datasetid=["source1", "source2", "source3"])

An alternative way is to create a single relationship and then convert to an array.

e = Entity("Vehicle", "A4567", ctx=ctx).prop("brandName", "Mercedes").rel("isParked", "OffStreetParking:Downtown4").rel(Rel.PROVIDED_BY, "Person:Bob", nested=True)
parked = e.arrayify("isParked")
# Update the Python dictionary
parked["object"] = "urn:ngsi-ld:OffStreetParking:Downtown5"
parked["providedBy"]["object"] = "urn:ngsi-ld:Person:Alice"
# Update the entity
e.append("isParked", parked)

Let me know if it's better.
It's still work in progress.

Regards

from python-ngsild-client.

Miracle-lab avatar Miracle-lab commented on September 26, 2024

Dear Fabien,

First of all thank you for the response. Please I want to inform you that the second alternative which you provided worked fine. However, the "datasetid" with "source1, source2, and source3" is not clear to me. I checked the documentation I could not see a detailed description of its use and function. Please can you provide me with some clarification on these concepts.

Secondly, I tried the first approach you suggested, it was able to create the several mapping to the different object with the same relationship. However, when parsing them to the stellio context broker it generated an error as shown in the image attached below. Thank you.

Screenshot from 2022-06-20 11-07-34
Screenshot from 2022-06-20 11-27-15
Screenshot from 2022-06-20 11-27-55

from python-ngsild-client.

fbattello avatar fbattello commented on September 26, 2024

Dear Miracle,

Depending on features, brokers have different implementations of the ETSI specifications.
I tested your code against the Orion broker. It works.
But Stellio complains that there are duplicates.
It happens to work by specifying a distinct datasetId field for each attribute (should be optional according to chapter 4.5.5 - Multiple Attribute Support).
You can try this :
e.rel("isParked", ["OffStreetParking:Downtown4", "OffStreetParking:Downtown5", "OffStreetParking:Downtown4"], datasetid=["datasource4", "datasource5", "datasource6"])

from python-ngsild-client.

fbattello avatar fbattello commented on September 26, 2024

Multiple-Relationship support added in v0.1.10.

from python-ngsild-client.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.