diff --git a/.changes/unreleased/Fixes-20241025-104339.yaml b/.changes/unreleased/Fixes-20241025-104339.yaml new file mode 100644 index 00000000000..ea7f4e060b6 --- /dev/null +++ b/.changes/unreleased/Fixes-20241025-104339.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: update adapter version messages +time: 2024-10-25T10:43:39.274723-05:00 +custom: + Author: dave-connors-3 + Issue: "10230" diff --git a/core/dbt/version.py b/core/dbt/version.py index 4155cc0a707..f5a28996e13 100644 --- a/core/dbt/version.py +++ b/core/dbt/version.py @@ -8,7 +8,7 @@ import requests import dbt_common.semver as semver -from dbt_common.ui import green, red, yellow +from dbt_common.ui import green, yellow PYPI_VERSION_URL = "https://pypi.org/pypi/dbt-core/json" @@ -19,7 +19,7 @@ def get_version_information() -> str: core_msg_lines, core_info_msg = _get_core_msg_lines(installed, latest) core_msg = _format_core_msg(core_msg_lines) - plugin_version_msg = _get_plugins_msg(installed) + plugin_version_msg = _get_plugins_msg() msg_lines = [core_msg] @@ -97,7 +97,7 @@ def _format_core_msg(lines: List[List[str]]) -> str: return msg + "\n".join(msg_lines) -def _get_plugins_msg(installed: semver.VersionSpecifier) -> str: +def _get_plugins_msg() -> str: msg_lines = ["Plugins:"] plugins = [] @@ -113,7 +113,7 @@ def _get_plugins_msg(installed: semver.VersionSpecifier) -> str: if display_update_msg: update_msg = ( - " At least one plugin is out of date or incompatible with dbt-core.\n" + " At least one plugin is out of date with dbt-core.\n" " You can find instructions for upgrading here:\n" " https://docs.getdbt.com/docs/installation" ) @@ -130,11 +130,6 @@ def _get_plugin_msg_info( needs_update = False - if plugin.major != core.major or plugin.minor != core.minor: - compatibility_msg = red("Not compatible!") - needs_update = True - return (compatibility_msg, needs_update) - if not latest_plugin: compatibility_msg = yellow("Could not determine latest version") return (compatibility_msg, needs_update) diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index efd51872576..bf4afb37e84 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -1,5 +1,5 @@ import dbt.version -from dbt_common.ui import green, red, yellow +from dbt_common.ui import green, yellow class TestGetVersionInformation: @@ -239,7 +239,7 @@ def test_plugin_match_core_behind_latest(self, mocker): "Plugins:", f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -269,7 +269,7 @@ def test_plugin_match_core_ahead_latest(self, mocker): "Plugins:", f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -279,11 +279,11 @@ def test_plugin_match_core_ahead_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_major_match_latest(self, mocker): + def test_plugin_diff_core_minor_match_latest(self, mocker): mock_versions( mocker, - installed="2.0.0", - latest="2.0.0", + installed="1.1.0", + latest="1.1.0", plugins={ "foobar": ("1.0.0", "1.0.0"), }, @@ -293,15 +293,11 @@ def test_plugin_diff_core_major_match_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", + " - installed: 1.1.0", + f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {green('Up to date!')}", "", "", ] @@ -309,11 +305,11 @@ def test_plugin_diff_core_major_match_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_major_no_latest(self, mocker): + def test_plugin_diff_core_minor_no_latest(self, mocker): mock_versions( mocker, - installed="2.0.0", - latest="2.0.0", + installed="1.1.0", + latest="1.1.0", plugins={ "foobar": ("1.0.0", None), }, @@ -323,15 +319,11 @@ def test_plugin_diff_core_major_no_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", + " - installed: 1.1.0", + f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {yellow('Could not determine latest version')}", "", "", ] @@ -339,11 +331,11 @@ def test_plugin_diff_core_major_no_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_major_ahead_latest(self, mocker): + def test_plugin_diff_core_minor_ahead_latest(self, mocker): mock_versions( mocker, - installed="2.0.0", - latest="2.0.0", + installed="1.1.0", + latest="1.1.0", plugins={ "foobar": ("1.0.0", "0.0.1"), }, @@ -353,15 +345,11 @@ def test_plugin_diff_core_major_ahead_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", + " - installed: 1.1.0", + f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.0.0 - {yellow('Ahead of latest version!')}", "", "", ] @@ -369,13 +357,18 @@ def test_plugin_diff_core_major_ahead_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_major_behind_latest(self, mocker): + def test_plugin_diff_plugin_minor_ahead_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + mock_versions( mocker, - installed="2.0.0", - latest="2.0.0", + installed="1.8.0", + latest="1.8.0", plugins={ - "foobar": ("1.0.0", "1.1.0"), + "foobar": ("1.9.0", "1.9.0"), }, ) @@ -383,15 +376,11 @@ def test_plugin_diff_core_major_behind_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 2.0.0", - f" - latest: 2.0.0 - {green('Up to date!')}", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.9.0 - {green('Up to date!')}", "", "", ] @@ -399,13 +388,18 @@ def test_plugin_diff_core_major_behind_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_minor_match_latest(self, mocker): + def test_plugin_diff_plugin_patch_ahead_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + mock_versions( mocker, - installed="1.1.0", - latest="1.1.0", + installed="1.8.0", + latest="1.8.0", plugins={ - "foobar": ("1.0.0", "1.0.0"), + "foobar": ("1.8.4", "1.8.4"), }, ) @@ -413,15 +407,11 @@ def test_plugin_diff_core_minor_match_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 1.1.0", - f" - latest: 1.1.0 - {green('Up to date!')}", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.8.4 - {green('Up to date!')}", "", "", ] @@ -429,13 +419,18 @@ def test_plugin_diff_core_minor_match_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_minor_no_latest(self, mocker): + def test_plugin_diff_plugin_minor_ahead_no_latest(self, mocker): + """ + Now that adapters are decoupled from core, a higher minor version of a plugin + is compatible with a lower minor version of core. + """ + mock_versions( mocker, - installed="1.1.0", - latest="1.1.0", + installed="1.8.0", + latest="1.8.0", plugins={ - "foobar": ("1.0.0", None), + "foobar": ("1.9.0", None), }, ) @@ -443,15 +438,11 @@ def test_plugin_diff_core_minor_no_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 1.1.0", - f" - latest: 1.1.0 - {green('Up to date!')}", + " - installed: 1.8.0", + f" - latest: 1.8.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.9.0 - {yellow('Could not determine latest version')}", "", "", ] @@ -459,13 +450,18 @@ def test_plugin_diff_core_minor_no_latest(self, mocker): assert expected == actual - def test_plugin_diff_core_minor_ahead_latest(self, mocker): + def test_plugin_diff_plugin_minor_behind_core_no_latest(self, mocker): + """ + Now that adapters are decoupled from core, a lower minor version of a plugin (1.8) + is compatible with a higher minor version of core. (1.9) + """ + mock_versions( mocker, - installed="1.1.0", - latest="1.1.0", + installed="1.9.0", + latest="1.9.0", plugins={ - "foobar": ("1.0.0", "0.0.1"), + "foobar": ("1.8.0", "1.8.0"), }, ) @@ -473,15 +469,11 @@ def test_plugin_diff_core_minor_ahead_latest(self, mocker): expected = "\n".join( [ "Core:", - " - installed: 1.1.0", - f" - latest: 1.1.0 - {green('Up to date!')}", + " - installed: 1.9.0", + f" - latest: 1.9.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", - "", - " At least one plugin is out of date or incompatible with dbt-core.", - " You can find instructions for upgrading here:", - " https://docs.getdbt.com/docs/installation", + f" - foobar: 1.8.0 - {green('Up to date!')}", "", "", ] @@ -507,9 +499,9 @@ def test_plugin_diff_core_minor_behind_latest(self, mocker): f" - latest: 1.1.0 - {green('Up to date!')}", "", "Plugins:", - f" - foobar: 1.0.0 - {red('Not compatible!')}", + f" - foobar: 1.0.0 - {yellow('Update available!')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "", @@ -528,7 +520,6 @@ def test_plugins_various(self, mocker): "foobar": ("2.1.0", "2.1.0"), "bazqux": ("2.1.0", None), "quuux": ("2.1.0", "2.1.0"), - "corge": ("22.21.20", "22.21.21"), "grault": ("2.1.0", "2.1.1"), "garply": ("2.1.0-b1", None), }, @@ -545,11 +536,10 @@ def test_plugins_various(self, mocker): f" - foobar: 2.1.0 - {green('Up to date!')}", f" - bazqux: 2.1.0 - {yellow('Could not determine latest version')}", f" - quuux: 2.1.0 - {green('Up to date!')}", - f" - corge: 22.21.20 - {red('Not compatible!')}", f" - grault: 2.1.0 - {yellow('Update available!')}", f" - garply: 2.1.0-b1 - {yellow('Could not determine latest version')}", "", - " At least one plugin is out of date or incompatible with dbt-core.", + " At least one plugin is out of date with dbt-core.", " You can find instructions for upgrading here:", " https://docs.getdbt.com/docs/installation", "",