Semantic of DataNodeBuilder key
guoquan opened this issue · comments
Usually, the return value of a sensor will be assigned to the DataNodeBuilder with a str
key, which is the fullname of the sensor. However, it seems @auszok needs to parse this key to understand how to associate the datanode, especially with CandidateSensor
s.
Can I instead pass the sensor instance so that @auszok can just query this python instance?
For example, instead of parsing the key
, removing the "graph" name, calculating the level of nesting and dropping the sensor name to get concept name, querying in the graph for this name to get a concept, you can do key.concept
to get the concept instance.
And for CandidateSensor
s, we don't need that naming convention to notify which edge its. Just do key.relations
.
@guoquan How we going to send sensor instance through Directory interface, specifically the method def setitem(self, key, value)?
It will be the key
here. key
can be any hashable instance.
@guoquan Ok, so after I get it in the Builder I will be able to call a method on it to get the type of the sensor (Candidate, Equality, ArgumentUpdate, etc ). I guess each of them could have different methods to get information - like Equality sensor needs key.equalityConcept method in addition to key.concept.
Hi, you may check sensor type by isinstance()
or type(key) ==
, where isinstance
is more preferable in python because it counts also the parent classed.
def __setitem__(self, key, value):
assert isinstance(key, CandidateSensor)
The Sensor
instance is nested in a tree architecture where you can query for any information about the graph
.
The hierarchy is, as you may guess from the full name style, Graph
/ (optional sub Graph
s) / Concept
/ Property
/ Sensor
, or Graph
/ (optional sub Graph
s) / Relation
/ Property
/ Sensor
. The first type is when the sensor is assign to a concept, and the sencond is when it is an edge sensor assigned to en edge/relation.
For example, with the equality sensor, you may have:
def __setitem__(self, key, value):
assert isinstance(key, CandidateEqualitySensor)
property = key.sup
relation = property.sup
concept1 = relation.src
concept2 = relation.dst
# In the graph there is: (relation,) = concept1.equalto(concept2)
Semantic changed.