From c515e883ea2f08aeacbf59a414340dfbdf4da229 Mon Sep 17 00:00:00 2001 From: John Muchovej <5000729+jmuchovej@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:09:30 -0500 Subject: [PATCH] Fix `max(stable_versions)` on Julia version finding (#2076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix `max(stable_versions)` Since the keys are semantic version strings, that means that `"1.9.4" > "1.10.0", which we know isn't true. 🙂 I just added some code to convert the string to tuples, find the max, then convert back to a string. I first noticed this on the `2024-01-05` build of the `datascience-notebook`, since Julia 1.10.0 was released ~2 weeks ago: https://github.com/JuliaLang/julia/releases/tag/v1.10.0. * Migrate to comparator on `max(stable_versions)` * Update setup_julia.py * Update setup_julia.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Ayaz Salikhov Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- images/minimal-notebook/setup-scripts/setup_julia.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/images/minimal-notebook/setup-scripts/setup_julia.py b/images/minimal-notebook/setup-scripts/setup_julia.py index 0cdbe0cf..890b253a 100755 --- a/images/minimal-notebook/setup-scripts/setup_julia.py +++ b/images/minimal-notebook/setup-scripts/setup_julia.py @@ -36,7 +36,10 @@ def get_latest_julia_url() -> tuple[str, str]: "https://julialang-s3.julialang.org/bin/versions.json" ).json() stable_versions = {k: v for k, v in versions.items() if v["stable"]} - latest_version_files = stable_versions[max(stable_versions)]["files"] + latest_stable_version = max( + stable_versions, key=lambda ver: [int(sub_ver) for sub_ver in ver.split(".")] + ) + latest_version_files = stable_versions[latest_stable_version]["files"] triplet = unify_aarch64(platform.machine()) + "-linux-gnu" file_info = [vf for vf in latest_version_files if vf["triplet"] == triplet][0] return file_info["url"], file_info["version"]