-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module's config references should refer back to the base config loaded by Halibot core #88
Comments
Turns out this has some problems. Tests fail since they use temporary modules that have no config, therefore the agent's call to I have two thoughts on this:
The former is obviously more complex and invasive. However, it does mean that all config is one neat location, and there is now a separation between object configuration, and what objects are actually meant to be loaded. This separation might be useful for debugging or testing, or something. Maybe even templates. The latter option, is easily the simplest, though it will require agent/module devs to actively call that whenever they need to flush their config back, OR a config editing module to do that. I think I'm actually in favor of separating the config keys (as an unrelated change), but keeping object config local. There might be cases where it will be useful to instantiate a temporary module without needing to define a key in the Halibot config for it (especially testing). |
Additional (beneficial?) side effect: Loading modules separate from config will also (potentially) allow a deterministic load order -- dictionaries have a non-deterministic key order, but a list will not. Therefore, we could (potentially) allow for config directives or other magic that handle |
Okay, another wild thought. We can define named configs, and therefore reuse configs for different instances. Example: {
"object-configs": {
"foo": {
"of":"foobar:Default",
"some-config":"yes"
}
},
"load-modules": [
"bar:foo",
"baz:foo"
]
} In this example, the config for the module This does raise a question though of if either module actually "owns" the config. That is, if one module wants to write back its config, should it write to a new config instance (which means we need to change the |
I don't see how merging |
This is almost a completely unrelated proposal now. I'm arguing that modules should have complete ownership over their config (config is local to their class instance, like how it is now), and configuration should be separate from the list of modules to load. Tests should be fine with this, since they don't rely on a callback to |
Currently, when module is instantiated, it is handed a dictionary blob of configuration data that it stores as
self.config
. However, this is a copy of the data contained in theconfig.json
file loaded by Halibot on start up. Any changes to either Halibot's copy, or the module's copy, are not shared.This can be fixed by converting the
self.config
reference on modules (All HalObjects, actually) into a dynamic attribute that ongetattr
parses Halibot's config for the relevant blob. This way, the current usage will be exactly the same to module developers, the only difference is that changes to config will be reflected back into the config file.Note: the
conf
argument to a HalObject's__init__
may be useless now.The text was updated successfully, but these errors were encountered: