-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add a method for removing/unregistering/clearing a single registered resolver #769
Comments
Hi, why do you need ignore_default_resolver (and the corresponding list of intenal resolvers?) |
@omry I kept The functionality is like certain methods in pandas where you can pass an This is just an idea and I would like reviewers' opinion on whether that will make sense or not. At the time of proposing this, I did not see any method that yields a list of default resolvers or checks if a resolver is default or custom. 💡 In hind sight, I think perhaps it's better to remove the parameter # code for OmegaConf.is_default_resolver
@classmethod
def is_default_resolver(cls, name: str) -> bool:
"""Check if a resolver is default or not."""
return name in DEFAULT_RESOLVER_NAMES What do you think? |
I think we should keep minimal and not do things because other libraries are doing them. A simple API for clear resolver can be: def clear_resolver(name: str) -> bool:
... This will remove a resolver and return False if it's not found, allowing the user to handle this case. |
@omry I like your suggestion. But, since this lets the user remove any resolver, shouldn't there be a method to check if a given resolver is default or not? What do you think about adding a separate method to check if a resolver is default or not? Please let me know your thoughts. @classmethod
def is_default_resolver(cls, name: str) -> bool:
"""Check if a resolver is default or not."""
return name in BaseContainer._resolvers.keys() In this case, the user could do something like this: # If the user wants to ensure removing only non-default
# resolvers, the following snippet should suffice.
resolver_name = "os.env"
if not OmegaConf.is_default_resolver(resolver_name):
OmegaConf.clear_resolver(resolver_name)
# If the user wants to remove resolver without any check
OmegaConf.clear_resolver(resolver_name) A question
|
Let's add For now:
Note that Edit: Exposing a public API like |
I don't think we should really care about internal resolvers. |
The Problem
At present, you can only remove/clear/unregister all the user-defined registered resolvers using
OmegaConf.clear_resolvers()
. But there is no method dedicated to removing a single user-defined registered resolver.Describe the solution you'd like
Add a method
OmegaConf.clear_resolver(name)
with the following API footprint:This would also require a way to track the default resolver names. I propose to add a variable
DEFAULT_RESOLVER_NAMES
inomegaconf.py
as follows:Describe alternatives you've considered
I have already implemented the code and will send a PR. So, please assign it to me. Thank you.
The text was updated successfully, but these errors were encountered: