Open laszewsk opened 5 years ago
https://rszalski.github.io/magicmethods/ iter(self) for node in g: contains(self, value) node in g, edge in g, check type so we can do both with in
& and(self, other) sequential | = object.or(self, other) parallel < = lt(self, other) edge, same as &
= gt(self, other), edge, same as & but other way around
especially important could be also the augmented assignment e.d.
g += a add a node
brackets would just work if each operation returns a graph as | and & are executed in sequence it would magically do the right thing
neet to check if networkx supporst this already
syntax may have to be
g += g.a | g.b
e.g. if the g is left of, it is simply added as we have += method this could than just be achieved from the names
g += a | b
so both methods are possible and the later is just rewritten into the first while using introspection on the name and adding the class method do it
we may laso need g += read(filename) which would add the graph specified in the file
This could be a great next step. I currently have it so you have to define the graph structure in a separate file (a yaml file or by entering command line arguments). However if a future student wants to add this, it should be easy to override methods on the base workflow class, and to transform those to calls in the WorkFlowDB class (in the WorkFlow file, cloudmesh/flow/WorkFlow
).
The main issue I had with this was finding a good convention for naming things. My Python skills are not good enough to define a class in a file (that inherits from the WorkFlow Base Class), instantiate it, define the workflow on there, and then export that particular instance when, for example, the cms flow run --flowname=blah
call is made.
I forgot to mention that python has also magic methods, fo this could be used for example to introduce the nodes and edges in a different way g = cloudmesh.flow.Graph()
g += a < b
adds an edge between a and b where a is executed first
g+= a | b
I have not looke into brackets or which operator has priority, but this may be good enough to hav a differnt way of adding a dag