From d41ab8a1547aa1f556c32d1b4e2dfc7b8a06b00c Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:44:06 -0600 Subject: [PATCH] handle pre-releases a different way --- src/_nebari/config_set.py | 7 ++----- tests/tests_unit/test_config_set.py | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/_nebari/config_set.py b/src/_nebari/config_set.py index 6bf7375869..95413ea1a7 100644 --- a/src/_nebari/config_set.py +++ b/src/_nebari/config_set.py @@ -22,14 +22,11 @@ class ConfigSetMetadata(BaseModel): def validate_version_requirement(cls, version_req): if isinstance(version_req, str): version_req = SpecifierSet(version_req, prereleases=True) - if version_req.prereleases is not True: - logger.warning( - "ConfigSetMetadata created with nebari_version SpecifierSet not allowing pre-releases." - ) + return version_req def check_version(self, version): - if version not in self.nebari_version: + if not self.nebari_version.contains(version, prereleases=True): raise ValueError( f'Nebari version "{version}" is not compatible with ' f'version requirement {self.nebari_version} for "{self.name}" config set.' diff --git a/tests/tests_unit/test_config_set.py b/tests/tests_unit/test_config_set.py index 2f280829f2..402068d521 100644 --- a/tests/tests_unit/test_config_set.py +++ b/tests/tests_unit/test_config_set.py @@ -13,16 +13,16 @@ [ # Standard version tests (">=2024.12.0,<2025.0.0", "2024.12.2", True), - (SpecifierSet(">=2024.12.0,<2025.0.0", prereleases=True), "2024.12.2", True), + (SpecifierSet(">=2024.12.0,<2025.0.0"), "2024.12.2", True), # Pre-release version requirement tests (">=2024.12.0rc1,<2025.0.0", "2024.12.0rc1", True), - (SpecifierSet(">=2024.12.0rc1", prereleases=True), "2024.12.0rc2", True), + (SpecifierSet(">=2024.12.0rc1"), "2024.12.0rc2", True), # Pre-release test version against standard requirement (">=2024.12.0,<2025.0.0", "2024.12.1rc1", True), - (SpecifierSet(">=2024.12.0,<2025.0.0", prereleases=True), "2024.12.1rc1", True), + (SpecifierSet(">=2024.12.0,<2025.0.0"), "2024.12.1rc1", True), # Failing cases (">=2025.0.0", "2024.12.2rc1", False), - (SpecifierSet(">=2025.0.0rc1", prereleases=True), "2024.12.2", False), + (SpecifierSet(">=2025.0.0rc1"), "2024.12.2", False), ], ) def test_version_requirement(version_input, test_version, should_pass):