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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Clarify how to register custom resolvers in a project #2886

Closed
JulianoLagana opened this issue Apr 4, 2024 · 3 comments
Closed
Labels
enhancement Enhanvement request

Comments

@JulianoLagana
Copy link

馃殌 Feature Request

Clarify how to register custom resolvers project-wide.

Motivation

I couldn't find anything in the documentation about how to register custom resolvers project-wide. The recommended approach seems to be registering them by calling OmegaConf.register_new_resolver in every script that uses them

I however found this comment, which seems to accomplish exactly what I want.

Is this the recommended way for registering resolvers project-wide?

Pitch

Describe the solution you'd like
It would be nice to clarify this in the documentation.

Are you willing to open a pull request? (See CONTRIBUTING)
Sure, but I need clarification on the recommended approach first.

@JulianoLagana JulianoLagana added the enhancement Enhanvement request label Apr 4, 2024
@Jasha10
Copy link
Collaborator

Jasha10 commented Jun 4, 2024

@JulianoLagana Yes, OmegaConf.register_new_resolver is the primary entry-point for registering custom resolvers.

@Jasha10 Jasha10 closed this as completed Jun 4, 2024
@JulianoLagana
Copy link
Author

Hi @Jasha10. Just to clarify, this issue is about how to register custom resolvers project-wide. Even if the recommended approach for registering custom resolvers for a single script is to use OmegaConf.register_new_resolver, that approach does not directly solve the issue of how to register them for all scripts in a project.

Can you please clarify what's the recommended approach for project-wide registration of custom resolvers?

@Jasha10
Copy link
Collaborator

Jasha10 commented Jun 6, 2024

This depends on how your project is organized.

If your project has e.g. an __init__.py or a __main__.py file as its entrypoint, you could define a function def register_my_resolvers(): ... in a module my_resolvers.py and then call that function from your __init__ or __main__ file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhanvement request
Projects
None yet
Development

No branches or pull requests

2 participants