-
Notifications
You must be signed in to change notification settings - Fork 116
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
Deprecation of register_resolver()
to introduce new functionalities
#426
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am confused because I called If I understand the plan correctly, using |
Don't ignore the warning (and use @Jasha10 thoughts? |
I am developing new code so I am flexible. In other words, skipping from version 2.0 directly to a future version where the |
Yes, this is what happened. In OmegaConf 2.2, I've updated the issue description above and will create a follow-up issue. |
Migrating custom resolvers from OmegaConf 2.0 to 2.1
Summary
register_resolver
withregister_new_resolver
use_cache=True
is passed toregister_new_resolver
Detailed migration instructions
Here are the main changes between resolvers registered with
register_new_resolver()
vs the oldregister_resolver()
:${func: [3.14, ${oc.env:VAR}], true}
use_cache=True
toregister_new_resolver()
)_parent_
and_root_
to the callable respectively) (Support optional _parent_ and _root_ parameters in custom resolvers #599).In most cases, migrating an existing resolver from OmegaConf 2.0 to 2.1 means replacing
register_resolver()
withregister_new_resolver()
and ensuring the resolver is correctly handling non-string inputs, if applicable.As an example, imagine you had the following resolver in OmegaConf 2.0:
In this example arguments will now expected to be integers in OmegaConf 2.1:
Note that here we didn't register the resolver with
use_cache=True
: it is expected that most resolvers should not need to use the cache. If you are depending on the caching behavior by assuming that your resolver is always returning the same value even when the underlying function may return a different value (e.g.random()
,time()
), then register your resolver withuse_cache=True
.The new resolver behavior is documented in detail in the documentation.
Additional remarks:
legacy_register_resolver()
(without updating your resolver), but this is only a temporary workaround that will be deprecated in future versions.register_new_resolver()
(compared toregister_resolver()
in 2.0), see Improve the API of register_resolver() #370 for detailsDeprecation plan for
register_resolver()
The following deprecation plan is being applied to
register_resolver()
so as to enable new functionalities introduced in OmegaConf 2.1 (#445):In 2.1
register_resolver()
is deprecated, and users calling this function will see a warning redirecting them to this issue. The old behavior ofregister_resolver()
remains temporarily available throughlegacy_register_resolver()
. Users are strongly encouraged to switch to the new functionregister_new_resolver()
(see above for an example).In 2.2
register_new_resolver()
will be renamed intoregister_resolver()
, and users callingregister_new_resolver()
will be warned to callregister_resolver()
instead. Users calling the oldlegacy_register_resolver()
will also be warned to switch toregister_resolver()
, updating their resolver accordingly.In 2.3
register_new_resolver()
andlegacy_register_resolver()
will be removedUpdate (2022-06-21)
The deprecation plan outlined above wasn't followed exactly for the OmegaConf 2.2 release. The schedule above will need to be modified.
The text was updated successfully, but these errors were encountered: