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
[monarch] Typed global configuration from python integrated with the Attrs system
Pull Request resolved: #1414
This diff introduces a typed global configuration system in python for monarch, integrated with the hyperactor `Attrs` system and the `hyperactor::global::config` module. To make an attribute configurable via python, first add the meta attribute `PYTHON_CONFIG_KEY`, like so:
```
@meta(
CONFIG_ENV_VAR = "HYPERACTOR_MESH_DEFAULT_TRANSPORT".to_string(),
PYTHON_CONFIG_KEY = "default_transport".to_string(),
)
pub attr DEFAULT_TRANSPORT: ChannelTransport = ChannelTransport::Unix;
```
This makes it so that the `DEFAULT_TRANSPORT` attr can be configured using `monarch.configure(default_transport=...)`. In order to ensure that attrs with type `ChannelTransport` can be configured by passing `PyChannelTransport` values to `monarch.configure`, in `monarch_hyperactor/src/config.rs`, add the macro invocation:
```
declare_py_config_type!(PyChannelTransport as ChannelTransport);
```
For attrs with rust types that can be passed directly to and from python (like `String`), simply add:
```
declare_py_config_type!(String);
```
These macro invocations only need to be added once per unique attr type we want to support -- *not* once per actual attr.
From python, the `DEFAULT_TRANSPORT` attr is then configurable in the global config by calling
```
monarch._rust_bindings.monarch_hyperactor.config.configure(
default_transport=ChannelTransport.MetaTlsWithHostname,
...
)
```
You can then get the currently configured values with
```
monarch._rust_bindings.monarch_hyperactor.config.get_configuration()
```
which returns
```
{
"default_transport": ChannelTransport.MetaTlsWithHostname,
...
}
```
ghstack-source-id: 313996274
Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
0 commit comments