提交 71d0cc9d 编写于 作者: W wuzewu

Add verification of PaddlePaddle version and fix PaddleX download problem.

上级 81cf07b2
......@@ -13,12 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__ = '2.0.1'
import paddle
from packaging.version import Version
_paddle_version = Version(paddle.__version__)
if _paddle_version < Version('2.0.0'):
raise RuntimeError(
'Version mismatch in PaddleHub and PaddlePaddle, you need to upgrade PaddlePaddle to version 2.0.0 or above.')
import sys
from easydict import EasyDict
__version__ = '2.0.0'
from paddlehub import env
from paddlehub.config import config
from paddlehub import datasets
......
......@@ -16,7 +16,7 @@
import os
import shutil
from paddlehub.server.server import module_server
from paddlehub.server.server import module_server, CacheUpdater
from paddlehub.utils import log, utils, xarfile
......@@ -35,12 +35,15 @@ class ResourceNotFoundError(Exception):
def download(name: str, save_path: str, version: str = None):
'''The download interface provided to PaddleX for downloading the specified model and resource files.'''
CacheUpdater("x_download", name, version).start()
file = os.path.join(save_path, name)
file = os.path.realpath(file)
if os.path.exists(file):
return
resources = module_server.search_resouce(name=name, version=version, type='Model')
resources = module_server.search_resource(name=name, version=version, type='Model')
if not resources:
raise ResourceNotFoundError(name, version)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册