From ac756f99109b9dc233f71d9f8d9dd7539ac57de0 Mon Sep 17 00:00:00 2001 From: Fabian Zills Date: Fri, 18 Oct 2024 17:47:39 +0200 Subject: [PATCH 1/2] draft --- znflow/base.py | 8 +++++++- znflow/dynamic.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/znflow/base.py b/znflow/base.py index 3f0b0bd..1db3cf5 100644 --- a/znflow/base.py +++ b/znflow/base.py @@ -12,6 +12,12 @@ from znflow.graph import DiGraph +class _NOT_RESVOLED_TYPE: + pass + +NOT_RESVOLED = _NOT_RESVOLED_TYPE() + + @contextlib.contextmanager def disable_graph(*args, **kwargs): """Temporarily disable set the graph to empty. @@ -354,7 +360,7 @@ class FunctionFuture(NodeBaseMixin): kwargs: typing.Dict item: any = None - result: any = dataclasses.field(default=None, init=False, repr=True) + result: any = dataclasses.field(default=NOT_RESVOLED, init=False, repr=True) _protected_ = NodeBaseMixin._protected_ + ["function", "args", "kwargs"] diff --git a/znflow/dynamic.py b/znflow/dynamic.py index 75d1b7b..f290776 100644 --- a/znflow/dynamic.py +++ b/znflow/dynamic.py @@ -1,6 +1,6 @@ import typing as t -from znflow.base import Connection, disable_graph, get_graph, FunctionFuture +from znflow.base import Connection, disable_graph, get_graph, FunctionFuture, NOT_RESVOLED def resolve(value: t.Union[Connection, t.Any]) -> t.Any: @@ -25,7 +25,7 @@ def resolve(value: t.Union[Connection, t.Any]) -> t.Any: # get the actual value with disable_graph(): result = value.result - if result is not None: + if result is not NOT_RESVOLED: return result # we assume, that if the result is None, the node has not been run yet graph = get_graph() From dfcf9759ad28b7fc495fcb71f3f36d4aa54ac22e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:51:16 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- znflow/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/znflow/base.py b/znflow/base.py index 1db3cf5..1d7cc05 100644 --- a/znflow/base.py +++ b/znflow/base.py @@ -15,6 +15,7 @@ class _NOT_RESVOLED_TYPE: pass + NOT_RESVOLED = _NOT_RESVOLED_TYPE()