from __future__ import annotations

from contextlib import contextmanager

from flownet.utils.context_vars import ContextSlot


_flow_build_ctx = ContextSlot[bool]("flownet_flow_building", default=False)


def in_flow_build() -> bool:
    return _flow_build_ctx.get()


@contextmanager
def flow_build_context():
    with _flow_build_ctx.use(True):
        yield
