dvc: check updates and warn about using an older version

Fixes #687

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-05-06 22:12:28 +03:00
parent f11e19a92c
commit 6e20e1f845
5 changed files with 37 additions and 1 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ Make your data science projects reproducible and shareable.
"""
import os
__version__ = '0.9.6'
VERSION_BASE = '0.9.6'
__version__ = VERSION_BASE
PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
HOMEPATH = os.path.dirname(PACKAGEPATH)
+30
View File
@@ -0,0 +1,30 @@
from github import Github
from dvc import VERSION_BASE
from dvc.logger import Logger
GITHUB_USER = 'dataversioncontrol'
GITHUB_REPO = 'dvc'
def check_updates():
current = VERSION_BASE
try:
gh = Github()
user = gh.get_user(GITHUB_USER)
repo = user.get_repo(GITHUB_REPO)
latest = repo.get_latest_release().title
except Exception as exc:
Logger.debug('Failed to obtain latest version: {}'.format(str(exc)))
return
l_major, l_minor, l_patch = latest.split('.')
c_major, c_minor, c_patch = current.split('.')
if l_major <= c_major and \
l_minor <= c_minor and \
l_patch <= c_patch:
return
msg = 'You are using dvc version {}, however version {} is available. Consider upgrading.'
Logger.warn(msg.format(current, latest))
+3
View File
@@ -17,6 +17,7 @@ from dvc.scm import SCM, Base
from dvc.cache import Cache
from dvc.cloud.data_cloud import DataCloud
from dvc.system import System
from dvc.check_updates import check_updates
class InitError(DvcException):
@@ -52,6 +53,8 @@ class Project(object):
self.logger = Logger(self.config._config[Config.SECTION_CORE].get(Config.SECTION_CORE_LOGLEVEL, None))
self.cloud = DataCloud(cache=self.cache, config=self.config._config)
check_updates()
@staticmethod
def init(root_dir=os.curdir, no_scm=False):
"""
+1
View File
@@ -20,3 +20,4 @@ paramiko>=2.4.1
binaryornot==0.4.4
jsonpath-rw==1.4.0
reflink==0.2.0
PyGithub>=1.39
+1
View File
@@ -26,6 +26,7 @@ install_requires = [
"binaryornot==0.4.4",
"jsonpath-rw==1.4.0",
"reflink==0.2.0",
"PyGithub>=1.39",
]
setup(