-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
directed graph serialization #330
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Hello @CagtayFabry! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-16 05:35:43 UTC |
Codecov Report
@@ Coverage Diff @@
## master #330 +/- ##
==========================================
+ Coverage 96.89% 96.96% +0.06%
==========================================
Files 82 84 +2
Lines 4769 4871 +102
==========================================
+ Hits 4621 4723 +102
Misses 148 148
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how do we proceed? Clear all the examples and merge the graph-related stuff?
weldx/asdf/schemas/weldx.bam.de/weldx/core/graph/signal-1.0.0.yaml
Outdated
Show resolved
Hide resolved
weldx/asdf/schemas/weldx.bam.de/weldx/core/graph/signal-1.0.0.yaml
Outdated
Show resolved
Hide resolved
weldx/asdf/schemas/weldx.bam.de/weldx/core/graph/graph-1.0.0.yaml
Outdated
Show resolved
Hide resolved
weldx/asdf/schemas/weldx.bam.de/weldx/core/graph/graph-1.0.0.yaml
Outdated
Show resolved
Hide resolved
Maybe we can dicuss the general approach here and if we are happy build on from there |
Co-authored-by: vhirtham <volker.hirthammer@gmail.com>
…yaml Co-authored-by: vhirtham <volker.hirthammer@gmail.com>
I have updated the default behavior to not serialize the node name if the node name is of type This should make it possible to use custom implementations for other classes that don't want or need to store node names |
weldx/asdf/schemas/weldx.bam.de/weldx/core/graph/di_node-1.0.0.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: vhirtham <volker.hirthammer@gmail.com>
any thoughts on this @marscher? Otherwise I will just merge :) |
The new directed graph implementation looks very good to me. |
Changes
Here is a simple implementation to handle
networkx.DiGraph
more generically via ASDF, represent a basic graph in a tree like structure.The motivation is to enable a simple way to define, describe and validate of specific graph structure/layout in ASDF schemas with minmal custom code on the python side.
Checks
basic implementation
Two basic types are introduced to represent and tag generic directed graph
nodes
andedges
in weldx files.Each
DiNode
has list ofDiEdges
that descend further "down" into the tree.Each edge points to a single
target_node
and also if the original edge direction descents into the tree"fwd"
or is pointing towards root"bwd"
.Here is the output of a simple directed graph
A->B->C
Here the same graph in reverse order, also starting at node A
A<-B<-C
Attributes that are added to nodes or edges via networkx will be serialized under the respective
attributes
property.ASDF customization
To use the graph with custom types, specialized
node
andedge
ASDF schemas can be defined.Here is an example on how one could specify a measurement chain graph with the following layout and restrictions.
Signal
SignalTransform
SignalTransform
must be defined inforward
direction (no inverse transformations)This simple structure corresponds to the
arborescence
layout in networkx, see https://networkx.org/documentation/stable//reference/algorithms/tree.htmlIn essence, a MeasurementChain is simply a graph where nodes and edges have a
Signal
orSignalTransform
in their attributes plus the above layout restrictions.Here is the yaml schema needed
measurement_chain-1.0.0
:The basic measurement chain only requires the
root_node
.The internal definitions
The minimal python implementation needed:
All schema requirements get validated on the ASDF level.
expanded example
If we want to introduce another node type to represent a
Source
and everyMeasurement
to start with a source we could do the following:Possible additions:
should be simple)