-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
adapter compability messaging added. #4565
Merged
ChenyuLInx
merged 5 commits into
dbt-labs:main
from
nkyuray:adapter_compability_messaging
Feb 3, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4689318
adapter compability messaging added.
nkyuray e4e8e97
edited plugin version compatibility message
nkyuray ff8ca6b
edited test version for plugin compability
nkyuray 433f9fa
compare using only major and minor
ChenyuLInx 260e2bb
Add checking PYPI and update changelog
ChenyuLInx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,13 +10,15 @@ | |||||
import dbt.exceptions | ||||||
import dbt.semver | ||||||
|
||||||
from dbt.ui import green, red, yellow | ||||||
from dbt import flags | ||||||
|
||||||
PYPI_VERSION_URL = 'https://pypi.org/pypi/dbt-core/json' | ||||||
|
||||||
|
||||||
def get_latest_version(): | ||||||
def get_latest_version(version_url: str = PYPI_VERSION_URL): | ||||||
try: | ||||||
resp = requests.get(PYPI_VERSION_URL) | ||||||
resp = requests.get(version_url) | ||||||
data = resp.json() | ||||||
version_string = data['info']['version'] | ||||||
except (json.JSONDecodeError, KeyError, requests.RequestException): | ||||||
|
@@ -29,7 +31,13 @@ def get_installed_version(): | |||||
return dbt.semver.VersionSpecifier.from_version_string(__version__) | ||||||
|
||||||
|
||||||
def get_package_pypi_url(package_name: str) -> str: | ||||||
return f'https://pypi.org/pypi/dbt-{package_name}/json' | ||||||
|
||||||
|
||||||
def get_version_information(): | ||||||
flags.USE_COLORS = True if not flags.USE_COLORS else None | ||||||
|
||||||
installed = get_installed_version() | ||||||
latest = get_latest_version() | ||||||
|
||||||
|
@@ -44,16 +52,40 @@ def get_version_information(): | |||||
|
||||||
plugin_version_msg = "Plugins:\n" | ||||||
for plugin_name, version in _get_dbt_plugins_info(): | ||||||
plugin_version_msg += ' - {plugin_name}: {version}\n'.format( | ||||||
plugin_name=plugin_name, version=version | ||||||
) | ||||||
plugin_version = dbt.semver.VersionSpecifier.from_version_string(version) | ||||||
latest_plugin_version = get_latest_version(version_url=get_package_pypi_url(plugin_name)) | ||||||
plugin_update_msg = '' | ||||||
if installed == plugin_version or ( | ||||||
latest_plugin_version and plugin_version == latest_plugin_version | ||||||
): | ||||||
compatibility_msg = green('Up to date!') | ||||||
else: | ||||||
if latest_plugin_version: | ||||||
if installed.major == plugin_version.major: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If |
||||||
compatibility_msg = yellow('Update available!') | ||||||
else: | ||||||
compatibility_msg = red('Out of date!') | ||||||
plugin_update_msg = ( | ||||||
" Your version of dbt-{} is out of date! " | ||||||
"You can find instructions for upgrading here:\n" | ||||||
" https://docs.getdbt.com/dbt-cli/install/overview\n\n" | ||||||
).format(plugin_name) | ||||||
else: | ||||||
compatibility_msg = yellow('No PYPI version available') | ||||||
|
||||||
plugin_version_msg += ( | ||||||
" - {}: {} - {}\n" | ||||||
"{}" | ||||||
).format(plugin_name, version, compatibility_msg, plugin_update_msg) | ||||||
|
||||||
if latest is None: | ||||||
return ("{}The latest version of dbt could not be determined!\n" | ||||||
"Make sure that the following URL is accessible:\n{}\n\n{}" | ||||||
.format(version_msg, PYPI_VERSION_URL, plugin_version_msg)) | ||||||
.format(version_msg, PYPI_VERSION_URL, plugin_version_msg) | ||||||
) | ||||||
|
||||||
if installed == latest: | ||||||
return "{}Up to date!\n\n{}".format(version_msg, plugin_version_msg) | ||||||
return f"{version_msg}{green('Up to date!')}\n\n{plugin_version_msg}" | ||||||
|
||||||
elif installed > latest: | ||||||
return ("{}Your version of dbt is ahead of the latest " | ||||||
|
@@ -91,7 +123,7 @@ def _get_dbt_plugins_info(): | |||||
f'dbt.adapters.{plugin_name}.__version__' | ||||||
) | ||||||
except ImportError: | ||||||
# not an adpater | ||||||
# not an adapter | ||||||
continue | ||||||
yield plugin_name, mod.version | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible that plugins will put out patch releases before
dbt-core
puts out a patch release. Imagine:dbt-core==1.0.1
anddbt-synapse==1.0.2
are both availabledbt-synapse==1.0.1
installed locallyinstalled == plugin_version
will returnTrue
, at the same time, there's a compatible plugin update availableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize this case, and the rule in the next comment, I will open a new issue and get these changes in