-
Notifications
You must be signed in to change notification settings - Fork 54
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
[fix] Use Dynaconf lazy variables insted of re-importing the settings. #1130
base: main
Are you sure you want to change the base?
Conversation
I will be working on the issue https://github.com/rochacbruno/dynaconf/issues/690 which is a known bug, once that bug is fixed then we can apply this fix to pulp_ansible. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
This PR is still missing dynaconf fix first |
This issue is no longer marked for closure. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
Dynaconf fix still pending, will be fixed for v4.0 soon |
This issue is no longer marked for closure. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
this is probably fixed by dynaconf/dynaconf#944 I will test it |
This issue is no longer marked for closure. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details. |
This pull request is no longer marked for closure. |
This PR now depends on Dynaconf 3.3.0 that will include this dynaconf/dynaconf#1040 |
Instead of doing `from dynaconf import settings` which causes the whole settings load to be executed again, it is better to use the support for lazy evaluation and formatting https://www.dynaconf.com/dynamic/#format-token so it is possible to defina a variable that is a template to be formed from interpolation with other in settings variables. So inside a settings file that is managed by dynaconf like: ``` from dynaconf import settings FOO = settings.BAR + "/zaz" ``` It is better to do ``` FOO = "@Format {this.BAR}/zaz" ``` or if Jinja powers is needed ``` FOO = "@Jinja {{ this.BAR }}/zaz" ``` [noissue]
2f14752
to
bddb2e1
Compare
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
This pull request is no longer marked for closure. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
Do we need a versioned dependency on dynaconf here? |
This issue is no longer marked for closure. |
@mdellweg the feature used here is added on dynaconf 3.2.5 https://github.com/dynaconf/dynaconf/releases/tag/3.2.5 which is not available on pulpcore 3.49 https://github.com/pulp/pulpcore/blob/3.49/requirements.txt#L19 (the lower bound for pulp_ansible) We would need to change main pulp_ansible to require at least pulpcore 3.50. |
I thought, we could require that dynaconf version here until we bump pulpcore to >= 3.50. |
I think we cannot require the version here because pulpcore 3.49 has upper bounds for dynaconf. Maybe we can just wait the proper time to merget this, this is not blocking anything, it is just adding a bit of overhead on application startup time. |
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! |
I think I am ready to fix it now. |
This issue is no longer marked for closure. |
Instead of doing
from dynaconf import settings
which causes the wholesettings load to be executed again, it is better to use the support for
lazy evaluation and formatting https://www.dynaconf.com/dynamic/#format-token
so it is possible to define a variable that is a template to be formed from
interpolation with other in settings variables.
So inside a settings file that is managed by dynaconf like:
It is better to do
or if Jinja powers is needed
This way there is no need to reload all the settings and avoids circular dependencies.
[noissue]