pulp_ansible icon indicating copy to clipboard operation
pulp_ansible copied to clipboard

[fix] Use Dynaconf lazy variables insted of re-importing the settings.

Open rochacbruno opened this issue 3 years ago • 22 comments

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 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:

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"

This way there is no need to reload all the settings and avoids circular dependencies.

[noissue]

rochacbruno avatar Jul 21 '22 15:07 rochacbruno

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.

rochacbruno avatar Jul 21 '22 15:07 rochacbruno

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!

stale[bot] avatar Jan 02 '23 16:01 stale[bot]

This PR is still missing dynaconf fix first

rochacbruno avatar Jan 02 '23 20:01 rochacbruno

This issue is no longer marked for closure.

stale[bot] avatar Jan 02 '23 20:01 stale[bot]

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!

stale[bot] avatar Apr 02 '23 23:04 stale[bot]

Dynaconf fix still pending, will be fixed for v4.0 soon

rochacbruno avatar Apr 03 '23 09:04 rochacbruno

This issue is no longer marked for closure.

stale[bot] avatar Apr 03 '23 09:04 stale[bot]

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!

stale[bot] avatar Jul 02 '23 11:07 stale[bot]

this is probably fixed by https://github.com/dynaconf/dynaconf/pull/944 I will test it

rochacbruno avatar Jul 02 '23 15:07 rochacbruno

This issue is no longer marked for closure.

stale[bot] avatar Jul 02 '23 15:07 stale[bot]

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!

stale[bot] avatar Sep 30 '23 23:09 stale[bot]

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.

stale[bot] avatar Oct 31 '23 00:10 stale[bot]

This pull request is no longer marked for closure.

stale[bot] avatar Nov 17 '23 17:11 stale[bot]

This PR now depends on Dynaconf 3.3.0 that will include this https://github.com/dynaconf/dynaconf/pull/1040

rochacbruno avatar Jan 14 '24 12:01 rochacbruno

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!

stale[bot] avatar Apr 13 '24 15:04 stale[bot]

This pull request is no longer marked for closure.

stale[bot] avatar Apr 15 '24 10:04 stale[bot]

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!

stale[bot] avatar Jul 14 '24 12:07 stale[bot]

Do we need a versioned dependency on dynaconf here?

mdellweg avatar Jul 15 '24 09:07 mdellweg

This issue is no longer marked for closure.

stale[bot] avatar Jul 15 '24 09:07 stale[bot]

@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.

rochacbruno avatar Jul 15 '24 11:07 rochacbruno

@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. But we can also wait. What would be more convenient?

mdellweg avatar Jul 15 '24 11:07 mdellweg

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.

rochacbruno avatar Jul 15 '24 11:07 rochacbruno

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!

stale[bot] avatar Oct 17 '24 00:10 stale[bot]

I think I am ready to fix it now.

rochacbruno avatar Oct 17 '24 21:10 rochacbruno

This issue is no longer marked for closure.

stale[bot] avatar Oct 17 '24 21:10 stale[bot]

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!

stale[bot] avatar Jan 15 '25 22:01 stale[bot]

After 2.5 years of waiting, this PR is finally mergeable! 🎉

rochacbruno avatar Jan 16 '25 11:01 rochacbruno