Skip to content

Clean up handling of global settings#3152

Merged
eb8680 merged 6 commits into
devfrom
settings
Nov 1, 2022
Merged

Clean up handling of global settings#3152
eb8680 merged 6 commits into
devfrom
settings

Conversation

@fritzo

@fritzo fritzo commented Oct 30, 2022

Copy link
Copy Markdown
Member

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

@eb8680 eb8680 left a comment

Copy link
Copy Markdown
Member

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