Open kalekundert opened 1 year ago
DocoptConfig
: Using parameters when loading configsload()
twice, with different config arguments. Some ways to do this:
Config.iter_layers(params, configs)
.DocoptConfig
a method like calc_usage_text(params, configs)
that would need to be called manually.DocoptConfig
a filled-in object.__config__
factory.UpstreamConfig
: Reusing configs from other appsUpstreamConfig
takes an app, and finds it's partner within that app itself. Maybe instead I could just give it the config to use.UpstreamConfig
isn't a good fit for BYOC: I could move it to stepwise-sample
along with a protocol for saving the configs and accessing them later.
stepwise-sample
is meant to help facilitate.ConfigCache
object.
load()
. It will be necessary to efficiently implement the DocoptConfig
factory. Plus it's a useful tool for things like this.stepwise-sample
would associate one of these caches with each Sample
object. UpstreamConfig
would be able to read and populate this cache.Part
: Deriving multiple parameters from a single config valueload()
function:load()
function, since the natural thing to do would just be to overwrite everything.__config__
factories will take responsibility for actually configuring the configs.sample.parent
before calling load()
, but that doesn't seem to onerous. Configs are immutable, so it doesn't matter what order the configs are used in.load()
, so once a value has been set, I need to respect it.load(force=True)
flag to override this.load()
should accept an app argument, which is the object it will fill in.load()
.SimpleNamespace
before calling the method. But then it's not really a method, since it doesn't have access to all methods of the real class.getter.iter_values()
.Having thought about this for a while, I don't think I can transition stepwise to a stateless architecture:
However, the stateless architecture makes much more sense for a general-purpose library: it's simpler, more efficient, and more extensible. Without a stateless architecture, I couldn't see myself recommending this library to other people, nor could I see myself using it for anything other than stepwise. So I think a stateless architecture is essential.
Putting this all together, I think I need to support both architectures. More specifically, I need to implement a stateful architecture using the stateless architecture. This would actually be a good way to demonstrate the extensibility of the stateless architecture.
Some implementation details I have in mind:
load()
needs to be called, (ii) attempt to load that parameter, or (iii) attempt to load all parameters.Part
), etc.
load()
function, stored in the app (so that all the parameters could find it), and deleted once everything has been loaded.cleanup()
function that could get rid of it.NotReadyYet
. This would indicate that the parameter could change value in the future (e.g. once more configs are loaded), but for now this getter should just be skipped.
Key
getters, even though I can't think of any reason why a non-Key
getter would need to raise this exception.load()
could get stuck in an infinite loop (by trying to keep going until all "pending" parameters have values). Maybe I could have the context keep an internal version number that increments every time something about the context changes. If I get NotReadyYet
twice for the same parameter with the same context version number, that's an infinite loop.NotReadyYet
idea. It seems pretty elegant.Pseudocode for load()
:
Pseudocode for stateful parameter access:
explicit=False
configsenable(app, configs)
, also include those configs.
Currently, BYOC is tightly coupled to the app object. This has some downsides:
I believe that moving to a functional/stateless architecture would address both of these points, and make the code more extensible in general. By "functional/stateless architecture", I mean roughly that there would be a
load(params, configs)
function that would return a dict/object with all the specified information.However, it's not clear how all of the useful features of BYOC would be reimplemented in such a system. The purpose of this thread is to enumerate and discuss such features.