Ensure additional key versions are prioritised over number of additional keys in version_priority solving#2080
Conversation
|
An important edge case I've found here: With the example scenario in the PR description and the logic of this PR, if we have the variants Even if we run However, if we run This feels intended as since |
…nal keys in version_priority solving Signed-off-by: Jonah J. Newton <33105911+jonahjnewton@users.noreply.github.com> Signed-off-by: Jonah Newton <jonah@jonahnewton.com.au>
Signed-off-by: Jonah J. Newton <33105911+jonahjnewton@users.noreply.github.com> Signed-off-by: Jonah Newton <jonah@jonahnewton.com.au>
Signed-off-by: Jonah Newton <jonah@jonahnewton.com.au>
Signed-off-by: Jonah Newton <jonah@jonahnewton.com.au>
Signed-off-by: Jonah Newton <jonah@jonahnewton.com.au>
When resolving with version_priority solving, the number of additional keys is prioritised over the version number of additional keys.
This causes unexpected behaviour, especially when using package orderers.
Take the following example orderer from the docs: https://rez.readthedocs.io/en/stable/package_orderers.html#version-split
If I have a package named
pipelinewith two variants,[["python-2.7.16"], ["python-3.7.4"]], and I runrez-env pipeline, then it will correctly resolve thepython-2.7.16variant based on the package orderer.However, if I add another package to the variants, then we get unexepected behaviour.
If I change the variants to
[["python-2.7.16", "other_package"], ["python-3.7.4"]], and runrez-env pipelinethen the larger number of additional keys in variant 0 causes it to be pushed down in priority, and thepython-3.7.4variant is resolved (even though we specify thatpython-2should be prioritised). If we runrez-env pipeline python, thenpythonis recognised as a requested key rather than an additional key, and thepython-2.7.16variant is resolved.More unexpectedly, if I change the variants to
[["python-2.7.16"], ["python-3.7.4", "other_package"]], and runrez-env pipelinethen the smaller number of additional keys in variant 0 brings it back up in the priority, causing thepython-2.7.16variant to be resolved again.python-2.7.16variant to be resolved over thepython-3.7.4variant.To continue to ensure that unnecessary extra keys are not included, but the versioning of common additional keys is correctly respected, my solution is to separate common from non-common keys across all variants, and rework the sort ordering to ensure the correct version always takes priority, then prioritise based on non-common additional keys which were identified in the request, then the lowest number of additional keys. I believe this results in more robust and deterministic logic in which we make sure we are always getting the variants that make sense and are most correct.