Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
f87bfd44
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f87bfd44
编写于
7月 09, 2019
作者:
B
BinLong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compitable problem with paddle_version
上级
3319d88c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
16 deletion
+38
-16
paddlehub/commands/hub.py
paddlehub/commands/hub.py
+2
-3
paddlehub/common/hub_server.py
paddlehub/common/hub_server.py
+5
-7
paddlehub/common/srv_utils.py
paddlehub/common/srv_utils.py
+26
-1
paddlehub/module/manager.py
paddlehub/module/manager.py
+5
-5
未找到文件。
paddlehub/commands/hub.py
浏览文件 @
f87bfd44
...
...
@@ -19,11 +19,10 @@ from __future__ import print_function
import
six
import
sys
import
requests
from
paddlehub.common.logger
import
logger
from
paddlehub.common.utils
import
sys_stdin_encoding
from
paddlehub.common
import
s
tat
s
from
paddlehub.common
import
s
rv_util
s
from
paddlehub.commands.base_command
import
BaseCommand
from
paddlehub.commands
import
show
from
paddlehub.commands
import
help
...
...
@@ -52,7 +51,7 @@ class HubCommand(BaseCommand):
help
.
command
.
execute
(
argv
)
exit
(
1
)
return
False
s
tat
s
.
hub_stat
([
'hub'
]
+
argv
)
s
rv_util
s
.
hub_stat
([
'hub'
]
+
argv
)
command
=
BaseCommand
.
command_dict
[
sub_command
]
return
command
.
execute
(
argv
[
1
:])
...
...
paddlehub/common/hub_server.py
浏览文件 @
f87bfd44
...
...
@@ -26,7 +26,7 @@ import yaml
import
random
from
random
import
randint
from
paddlehub.common
import
utils
from
paddlehub.common
import
utils
,
srv_utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.server_config
import
default_server_config
from
paddlehub.io.parser
import
yaml_parser
...
...
@@ -95,9 +95,8 @@ class HubServer(object):
payload
=
{
'word'
:
resource_key
}
if
resource_type
:
payload
[
'type'
]
=
resource_type
r
=
requests
.
get
(
self
.
get_server_url
()
+
'/'
+
'search'
,
params
=
payload
)
r
=
json
.
loads
(
r
.
text
)
api_url
=
srv_utils
.
uri_path
(
self
.
get_server_url
(),
'search'
)
r
=
srv_utils
.
hub_request
(
api_url
,
payload
)
if
r
[
'status'
]
==
0
and
len
(
r
[
'data'
])
>
0
:
return
[(
item
[
'name'
],
item
[
'type'
],
item
[
'version'
],
item
[
'summary'
])
for
item
in
r
[
'data'
]]
...
...
@@ -149,9 +148,8 @@ class HubServer(object):
payload
[
'type'
]
=
resource_type
if
version
:
payload
[
'version'
]
=
version
r
=
requests
.
get
(
self
.
get_server_url
()
+
'/'
+
'search'
,
params
=
payload
)
r
=
json
.
loads
(
r
.
text
)
api_url
=
srv_utils
.
uri_path
(
self
.
get_server_url
(),
'search'
)
r
=
srv_utils
.
hub_request
(
api_url
,
payload
)
if
r
[
'status'
]
==
0
and
len
(
r
[
'data'
])
>
0
:
return
r
[
'data'
][
0
]
except
:
...
...
paddlehub/common/s
tat
s.py
→
paddlehub/common/s
rv_util
s.py
浏览文件 @
f87bfd44
...
...
@@ -15,8 +15,10 @@
import
os
import
requests
import
time
import
paddle
from
random
import
randint
,
seed
from
paddlehub
import
version
from
paddlehub.common.server_config
import
default_stat_config
...
...
@@ -33,8 +35,31 @@ def get_stat_server():
def
hub_stat
(
argv
):
try
:
params
=
{
'command'
:
' '
.
join
(
argv
),
'version'
:
version
.
hub_version
}
params
=
{
'command'
:
' '
.
join
(
argv
),
'hub_version'
:
version
.
hub_version
,
'paddle_version'
:
paddle
.
__version__
}
stat_api
=
get_stat_server
()
r
=
requests
.
get
(
stat_api
,
params
=
params
,
timeout
=
0.5
)
except
:
pass
def
uri_path
(
server_url
,
api
):
srv
=
server_url
if
server_url
.
endswith
(
'/'
):
srv
=
server_url
[:
-
1
]
if
api
.
startswith
(
'/'
):
srv
+=
api
else
:
api
=
'/'
+
api
srv
+=
api
return
srv
def
hub_request
(
api
,
params
):
params
[
'hub_version'
]
=
version
.
hub_version
params
[
'paddle_version'
]
=
paddle
.
__version__
r
=
requests
.
get
(
api
,
params
)
return
r
.
json
()
paddlehub/module/manager.py
浏览文件 @
f87bfd44
...
...
@@ -21,7 +21,7 @@ import os
import
shutil
from
paddlehub.common
import
utils
from
paddlehub.common
import
s
tat
s
from
paddlehub.common
import
s
rv_util
s
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.dir
import
MODULE_HOME
from
paddlehub.module
import
module_desc_pb2
...
...
@@ -81,7 +81,7 @@ class LocalModuleManager(object):
module_dir
=
self
.
modules_dict
[
module_name
][
0
]
module_tag
=
module_name
if
not
module_version
else
'%s-%s'
%
(
module_name
,
module_version
)
s
tat
s
.
hub_stat
([
'installed'
,
module_tag
])
s
rv_util
s
.
hub_stat
([
'installed'
,
module_tag
])
tips
=
"Module %s already installed in %s"
%
(
module_tag
,
module_dir
)
return
True
,
tips
,
self
.
modules_dict
[
module_name
]
...
...
@@ -100,7 +100,7 @@ class LocalModuleManager(object):
tips
+=
" with version %s"
%
module_version
module_tag
=
module_name
if
not
module_version
else
'%s-%s'
%
(
module_name
,
module_version
)
s
tat
s
.
hub_stat
([
'install fail'
,
module_tag
])
s
rv_util
s
.
hub_stat
([
'install fail'
,
module_tag
])
return
False
,
tips
,
None
result
,
tips
,
module_zip_file
=
default_downloader
.
download_file
(
...
...
@@ -122,7 +122,7 @@ class LocalModuleManager(object):
shutil
.
move
(
module_dir
,
save_path
)
module_dir
=
save_path
tips
=
"Successfully installed %s"
%
module_name
s
tat
s
.
hub_stat
([
'install'
,
module_name
,
url
])
s
rv_util
s
.
hub_stat
([
'install'
,
module_name
,
url
])
if
installed_module_version
:
tips
+=
"-%s"
%
installed_module_version
return
True
,
tips
,
(
module_dir
,
installed_module_version
)
...
...
@@ -138,7 +138,7 @@ class LocalModuleManager(object):
1
]:
tips
=
"%s-%s is not installed"
%
(
module_name
,
module_version
)
return
True
,
tips
s
tat
s
.
hub_stat
([
'uninstall'
,
module_name
])
s
rv_util
s
.
hub_stat
([
'uninstall'
,
module_name
])
tips
=
"Successfully uninstalled %s"
%
module_name
if
module_version
:
tips
+=
'-%s'
%
module_version
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录