conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
456 stars 101 forks source link

Sort BaseLockedDependency.dependencies when alpha-sorting a Lockfile #654

Closed peterbygrave closed 16 hours ago

peterbygrave commented 2 days ago

Description

When writing a conda-lock.yml file, the package.dependencies are not sorted. This can cause more lines to change than strictly needed when e.g. adding a new package that does not alter any existing packages. This help with merge conflicts etc.

I was unsure of the ethos around testing in this repo, but very happy to add tests as needed with some guidance 🙂

netlify[bot] commented 2 days ago

Deploy Preview for conda-lock ready!

Name Link
Latest commit 9e5f94796712a5300f66fdad5a894ee81de71428
Latest deploy log https://app.netlify.com/sites/conda-lock/deploys/66812da9797a1e00085b7bd1
Deploy Preview https://deploy-preview-654--conda-lock.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

maresb commented 2 days ago

Thanks! LGTM.

I don't see any need for tests here because I don't think we need to guarantee this as an interface contract.

Do you know what's leading to the unsorted dependencies? Can you provide a minimal example? In my lockfiles they're sorted. Is it coming from pip dependencies?

peterbygrave commented 2 days ago

Thanks! LGTM.

I don't see any need for tests here because I don't think we need to guarantee this as an interface contract.

Do you know what's leading to the unsorted dependencies? Can you provide a minimal example? In my lockfiles they're sorted. Is it coming from pip dependencies?

Interesting question, I don't believe it was pip dependencies but will double check my local example where I saw it and post.

peterbygrave commented 1 day ago

Closing and reopening to trigger ci

peterbygrave commented 21 hours ago

Thanks! LGTM.

I don't see any need for tests here because I don't think we need to guarantee this as an interface contract.

Do you know what's leading to the unsorted dependencies? Can you provide a minimal example? In my lockfiles they're sorted. Is it coming from pip dependencies?

Looking at my example (unfortunately I cannot shared due to private repo) it happens for conda packages but only when adding packages to my source environment.yaml They were quite innocent (e.g. types-networkx). The conda-lock.yml started sorted to then became unsorted but only for some packages e.g:

Screenshot 2024-06-30 at 07 19 15

Wonder if this is only happening when loading from an existing lock file. Tried looking for something obvious, but nothing stood out.

Now ready for review.

maresb commented 17 hours ago

Thanks @peterbygrave! I made a few very minor tweaks and will squash-merge once the tests pass.