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

Clean up handling of global settings #3152

Merged
merged 6 commits into from
Nov 1, 2022
Merged

Clean up handling of global settings #3152

merged 6 commits into from
Nov 1, 2022

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented Oct 30, 2022

This responds to a comment in #3151 where it is currently cumbersome to configure global settings in Pyro. The solution proposed in this PR is to add a pyro.settings module with the usual interface (set, get, context manager) while being extensible in the sense that settings are registered in their local modules, rather than in the settings module.

Hopefully this may slightly simplify @eb8680's new global setting in #3149, e.g. adding this one liner

# in pyro/poutine/runtime.py
settings.register("module_local_param", __name__, "_PYRO_MODULE_LOCAL_PARAM")

will allow things like pyro.settings.set("module_local_param", True) or

with pyro.settings(module_local_param=True):
    ...do stuff...

Tested

  • added some unit tests

@fritzo fritzo requested a review from eb8680 October 31, 2022 17:01
Copy link
Member

@eb8680 eb8680 left a comment

Choose a reason for hiding this comment

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

Looks great, I'll try to integrate this into #3149

@eb8680 eb8680 merged commit 891880f into dev Nov 1, 2022
@eb8680 eb8680 deleted the settings branch November 1, 2022 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants