-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Description
When an adapter is injected, it doesn't get its provider updated from its new parent, so it can't access the context it should, as see in the following:
from refiners.fluxion.adapters.adapter import Adapter
from refiners.fluxion.context import Contexts
import refiners.fluxion.layers as fl
class P(fl.Chain):
def init_context(self) -> Contexts:
return {'foo': {'bar': None}}
class A(fl.Chain, Adapter[fl.Chain]):
def __init__(self, target: fl.Chain):
with self.setup_adapter(target):
super().__init__(
fl.Lambda(lambda: 1),
fl.SetContext('foo', 'bar'),
)
def inject(self, parent: fl.Chain | None = None):
x = super().inject(parent)
return x
m = P(
fl.Chain(
fl.Lambda(lambda: 1),
fl.SetContext('foo', 'bar'),
),
fl.UseContext('foo', 'bar'),
)
c, parent = next(m.walk(fl.Chain))
m() # no error
A(c).inject(parent)
# m._register_provider() # uncommenting this stops the next line's error
m() # error: "Context foo not found."
catwell
Metadata
Metadata
Assignees
Labels
No labels