Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update adapter version messages #10919

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241025-104339.yaml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 4 additions & 9 deletions core/dbt/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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]

Expand Down Expand Up @@ -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 = []
Expand All @@ -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"
)
Expand All @@ -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)
Expand Down
154 changes: 72 additions & 82 deletions tests/unit/test_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dbt.version
from dbt_common.ui import green, red, yellow
from dbt_common.ui import green, yellow


class TestGetVersionInformation:
Expand Down Expand Up @@ -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",
"",
Expand Down Expand Up @@ -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",
"",
Expand All @@ -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"),
},
Expand All @@ -293,27 +293,23 @@ 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!')}",
"",
"",
]
)

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),
},
Expand All @@ -323,27 +319,23 @@ 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')}",
"",
"",
]
)

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"),
},
Expand All @@ -353,135 +345,135 @@ 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!')}",
"",
"",
]
)

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"),
},
)

actual = dbt.version.get_version_information()
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!')}",
"",
"",
]
)

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"),
},
)

actual = dbt.version.get_version_information()
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!')}",
"",
"",
]
)

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),
},
)

actual = dbt.version.get_version_information()
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')}",
"",
"",
]
)

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"),
},
)

actual = dbt.version.get_version_information()
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!')}",
"",
"",
]
Expand All @@ -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",
"",
Expand All @@ -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),
},
Expand All @@ -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",
"",
Expand Down
Loading