Comments (1)
First tests show that one could use:
class NodeBaseMixin:
def __getattribute__(self, item):
value = super().__getattribute__(item)
if NodeBaseMixin._graph_ is not None:
if item not in ["_graph_"] and not item.startswith("__"):
connector = Connection(instance=self, attribute=item)
return connector
return value
def __setattr__(self, item, value) -> None:
if isinstance(value, Connection):
assert id(self) in self._graph_
assert id(value.instance) in self._graph_
self._graph_.add_edge(
id(value.instance), id(self), i_attr=value.attribute, j_attr=item
)
super().__setattr__(item, value)
with
@dataclasses.dataclass(frozen=True)
class Connection:
"""A Connector for Nodes.
instance: either a Node or FucntionFuture
attribute:
Node.attribute
or FunctionFuture.result
or None if the class is passed and not an attribute
"""
instance: any
attribute: any
it is REALLY important to mention, that within the DiGraph
something like the following does not work within the context manager. This affects also all calls inside the __init__
or generally everything that is not specifically excluded inside __getattribute__
.
@dataclasses.dataclass()
class Node(NodeBaseMixin):
input: int
output: int = None
def __post_init__(self):
self.output = self.input * 2 # this can not work, because self.input is Connection and not int
from znflow.
Related Issues (20)
- Issue with `znflow.Node.result` HOT 1
- `znflow.Property` does behave differently to `property`
- Fix Assertion Error
- add update=False
- Move all IterableHandlers into a module
- Better error messages: print node that causes the error
- I think this might be slow
- Test combine outside graph
- Tests for `znflow.combine`
- Dask worker resources
- Unexpected output
- Future / Connection result
- combine should also work with list of Nodes
- Change in_construction HOT 1
- Use `znflow.edges`
- Better error messages
- `_external_` Node
- Give the `empty` object a `__repr__` and `__str__`
- support / mention Python futures
- `znflow.map` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from znflow.