You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am very confused, how the scope/context is applied resp. how _default_config is resolved.
My naive understanding was (before I moved the definitions to the module) that the scope/context is created at "init-time" and is somehow passed/"shining" from module level through the deeper schema tree... but now this issue confuses my a lot...
1. Minimal reproduce step (Required)
If I move schema/mixin/protocol definitions to a module a context var is not found: the working example is here
# INFO: this is in schemata.foo
protocol LoginProtocol:
a_url: str
b_url: str
mixin DefaultLoginMixin for LoginProtocol:
# INFO: If no a_url, b_url is defined in the final schema, we apply the
# value from _default_login
a_url: str = a_url or _default_login.a_url
b_url: str = b_url or _default_login.b_url
schema Config:
mixin [
DefaultLoginMixin
]
schema Stage:
[...str]: Config
_default_login: LoginProtocol
import schemata.foo
ci00 = foo.Stage {
# FIXME: how is _default_login reaching the mixin, when defined in one script,
# but not if the mixin is imported from a module?
_default_login = foo.LoginProtocol {
a_url = "https://default.a_url"
b_url = "https://default.b_url"
}
provider_1 = foo.Config {}
provider_2 = foo.Config {
# INFO: override the default
a_url = "https://custom.a_url"
b_url = "https://custom.b_url"
}
}
Even if I define the Config schema in the same module, as where _default_config is created/instantiated/scoped, it still does not work. So this seems to defy the meaning of "mixin"...
import schemata.foo
schema Config:
# FIXME: seems like resolution of _default_login is just looking into,
# where the mixin is defined and not where it is applied/used/mixed-in
mixin [
foo.DefaultLoginMixin
]
schema Stage:
[...str]: Config
_default_login: foo.LoginProtocol
ci00 = Stage {
# FIXME: how is _default_login reaching the mixin, when defined in one script,
# but not if the mixin is imported from a module?
_default_login = foo.LoginProtocol {
a_url = "https://default.a_url"
b_url = "https://default.b_url"
}
provider_1 = Config {}
provider_2 = Config {
# INFO: override the default
a_url = "https://custom.a_url"
b_url = "https://custom.b_url"
}
}
@Peefy can you confirm, that my observation makes sense to you...? I also tried to find the place in the code, where I can start to fix it by myself... (resolving this would greatly improve our kcl code)
Bug Report
I am very confused, how the scope/context is applied resp. how
_default_config
is resolved.My naive understanding was (before I moved the definitions to the module) that the scope/context is created at "init-time" and is somehow passed/"shining" from module level through the deeper schema tree... but now this issue confuses my a lot...
1. Minimal reproduce step (Required)
If I move schema/mixin/protocol definitions to a module a context var is not found: the working example is here
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your KCL components version? (Required)
The text was updated successfully, but these errors were encountered: