-
Notifications
You must be signed in to change notification settings - Fork 113
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
Option to reset/clear gin register #115
Comments
You can clear gin registrations with |
Yes, but this does not solve the issue @gin.configurable
class A:
pass
gin.clear_config(clear_constants=True)
@gin.configurable # Error: A already registered
class A:
pass I guess I'm asking for The use-case is colab use: gin.clear_config(clear_registered=True)
with adhoc_import:
import my_project
reload_module(my_project) The second time this gets executed, this will raise an error. As explained above, |
Another example were this appear is in unittest: @pytest.mark.parametrize('default', [None, 123])
def test_default_factory_explicit(default):
gin.clear_config()
@gin.configurable
@dataclasses.dataclass
class Config:
x: Any = default Despite
Using |
This 334547d should fix this issue, and allow to register the same configurable twice, as far is the same class with the same name. Can you try to pull the latest version and try again? |
Currently, if a
@gin.configurable
is imported twice (e.g. throughimportlib.reload()
), it raises an error.This can be fixed by
gin.enter_interactive_mode()
, but interactive mode does not clear the previous scopes, which is potentially error prone as allimportlib.reload()
might interfere with one another. This makes it difficult to keep track of the current registered configurable state.I would like to be able to clear to reset gin to it's initial state, so I am confident my colab will behave similarly to python script, without having to restart the colab runtime.
The text was updated successfully, but these errors were encountered: