OpenAstronomy / publish-wheels-anaconda

GitHub action to publish wheels to Anaconda.org and clear away old wheels
3 stars 3 forks source link

Improve sorting of versions to remove #4

Closed ConorMacBride closed 8 months ago

ConorMacBride commented 1 year ago

The script for removing old wheels sorts the version strings alphanumerically: https://github.com/OpenAstronomy/publish-wheels-anaconda/blob/a86edb56f72cb212858e5266b2e6f112043940e2/remove_old_wheels.py#L26

This should be fine in most case, but if a version changes from single to double digits (e.g. 1.9.0 to 1.10.0, or 2022.9.1 to 2022.10.1) it'll delete the newest version instead. We should write a function to pass as a key to sorted. Probably, drop leading characters such as v, split on ., - and + into a tuple, and convert to an integer if only digits.

pllim commented 8 months ago

This actually manifested as a horrible bug in astropy, see https://github.com/astropy/astropy/issues/15935 .

https://github.com/OpenAstronomy/publish-wheels-anaconda/blob/a86edb56f72cb212858e5266b2e6f112043940e2/remove_old_wheels.py#L26-L29

It kept a very old dev98 but deleted the dev359 that it was supposed to upload. I had to disable this feature in astropy until this is fix at the risk of filling up the disk quota.

Any chance this will get fixed soon?

astrofrog commented 8 months ago

Maybe we could also sort on upload date if there is a way to get that information.

ConorMacBride commented 8 months ago

Good point. Upload date would be ideal as that would allow for patches to older major releases.

ConorMacBride commented 8 months ago

Just had a look at the JSON the API returns. Each file has an upload_time with a value e.g. 2018-10-19 19:03:58.717000+00:00. I'll open a PR that parses and then sorts based on the upload time.