mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dvc: check updates and warn about using an older version
Fixes #687 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+2
-1
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -20,3 +20,4 @@ paramiko>=2.4.1
|
||||
binaryornot==0.4.4
|
||||
jsonpath-rw==1.4.0
|
||||
reflink==0.2.0
|
||||
PyGithub>=1.39
|
||||
|
||||
Reference in New Issue
Block a user