Skip to content

Conversation

samlurye
Copy link
Contributor

@samlurye samlurye commented Oct 3, 2025

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 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,
    ...
}

Differential Revision: D83701581

… the Attrs system

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 3, 2025
… the Attrs system

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

ghstack-source-id: 313909164
Pull Request resolved: #1414
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 3, 2025
Copy link

meta-codesync bot commented Oct 3, 2025

@samlurye has exported this pull request. If you are a Meta employee, you can view the originating Diff in D83701581.

…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 3, 2025
…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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
ghstack-source-id: 313935693
…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 3, 2025
…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/)
…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 3, 2025
…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: 314014793

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 4, 2025
…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: 314061849

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 4, 2025
…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: 314105483

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
…grated with the Attrs system"

This diff is an RFC for introducing 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,
    ...
}
```

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)

[ghstack-poisoned]
samlurye added a commit that referenced this pull request Oct 4, 2025
…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: 314105606

Differential Revision: [D83701581](https://our.internmc.facebook.com/intern/diff/D83701581/)
@samlurye samlurye closed this Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant