[RFC][monarch] Typed global configuration from python integrated with the Attrs system #1398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
This diff is an RFC for introducing a typed global configuration system in python for monarch, integrated with the hyperactor
Attrs
system and thehyperactor::global::config
module. It introduces thepy_configurable
macro, which automatically generates typed python bindings for instances ofhyperactor::attrs::Key<T>
. Example usage:This means, "for the
DEFAULT_TRANSPORT
attribute, generate a python class with the following stub/functionality:The leading
py
in the macro invocation is used in the implementation to indicate thatPyChannelTransport
needs to be converted to/from the actual type of theDEFAULT_TRANSPORT
attribute (which ishyperactor::channel::ChannelTransport
). If I were better at rust macros (or rust in general) I could probably figure out how to get rid of it.I also added functionality to allow for a callback function when the config value is set from python. This could be useful when the root client needs to be re-initialized after setting
DEFAULT_TRANSPORT
.Differential Revision: D83701581