-
Notifications
You must be signed in to change notification settings - Fork 33
[hyperactor] attribute defaults #233
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
Conversation
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! [ghstack-poisoned]
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! ghstack-source-id: 289709203 Pull Request resolved: #233
This pull request was exported from Phabricator. Differential Revision: D76438138 |
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! [ghstack-poisoned]
Pull Request resolved: #233 An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! ghstack-source-id: 289710685
This pull request was exported from Phabricator. Differential Revision: D76438138 |
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! [ghstack-poisoned]
Pull Request resolved: #233 An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. ghstack-source-id: 289712267 Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)!
This pull request was exported from Phabricator. Differential Revision: D76438138 |
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! [ghstack-poisoned]
Pull Request resolved: #233 An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. ghstack-source-id: 289754395 Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)!
This pull request was exported from Phabricator. Differential Revision: D76438138 |
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)! [ghstack-poisoned]
Pull Request resolved: #233 An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling `contains_key`. Along with this, we implement `Index` and `IndexMut`, allowing a natural syntax: ``` declare_attrs! { /// My key. pub attr MY_KEY: u64 = 1; } let attrs = Attrs::new(); assert_eq!(attrs[MY_KEY], 1); attrs[MY_KEY] = 2; assert_eq!(attrs[MY_KEY], 2); ``` With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables. ghstack-source-id: 290144041 Differential Revision: [D76438138](https://our.internmc.facebook.com/intern/diff/D76438138/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D76438138/)!
This pull request was exported from Phabricator. Differential Revision: D76438138 |
This pull request has been merged in 45860ad. |
Stack from ghstack (oldest at bottom):
An attribute with a default returns the default value whenever an attribute does not exist in a dictionary. A caller can distinguish between a default and a set value by calling
contains_key
.Along with this, we implement
Index
andIndexMut
, allowing a natural syntax:With this, we can now simplify configs to maintaining a global attribute dictionary, and populating this by default from environment variables.
Differential Revision: D76438138
NOTE FOR REVIEWERS: This PR has internal Meta-specific changes or comments, please review them on Phabricator!