Skip to content
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

Add sole_config function for enforced one-time configuring #1661

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

QuantuMope
Copy link
Contributor

This PR adds a new sole_init flag in the original alf.config along with a simple wrapper function, alf.sole_config.

If the flag is set to true, the config value can only be set once, with any previous or future calls raising a ValueError. This is helpful in enforcing a singular point of initialization, thus eliminating any potential side effects from possible prior or future overrides. This is especially a problem when working deeply nested alf.config calls.

Before, a somewhat similar behavior could be achieved through the mutable flag, but this flag would only raise a warning, which can easily get drowned out in logs.

@QuantuMope QuantuMope requested review from hnyu and breakds June 21, 2024 17:49
previous or future calls will raise a ValueError. This is helpful
in enforcing a singular point of initialization, thus eliminating
any potential side effects from possible prior or future overrides.
This flag overrides the mutable flag.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag only overwrites the mutable flag if it's True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Good catch. I've clarified this.

@QuantuMope QuantuMope merged commit 00881f7 into pytorch Jun 21, 2024
2 checks passed
@QuantuMope QuantuMope deleted the PR/andrew/add-sole-init-kwarg branch June 21, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants