Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
92fdb878
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
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看板
提交
92fdb878
编写于
6月 11, 2019
作者:
B
BinLong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update interfaces
上级
ab0d33bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
15 deletion
+26
-15
paddlehub/commands/list.py
paddlehub/commands/list.py
+1
-1
paddlehub/commands/show.py
paddlehub/commands/show.py
+4
-4
paddlehub/common/hub_server.py
paddlehub/common/hub_server.py
+13
-4
paddlehub/common/server_config.py
paddlehub/common/server_config.py
+4
-2
paddlehub/module/manager.py
paddlehub/module/manager.py
+2
-2
paddlehub/module/module.py
paddlehub/module/module.py
+2
-2
未找到文件。
paddlehub/commands/list.py
浏览文件 @
92fdb878
...
...
@@ -41,7 +41,7 @@ class ListCommand(BaseCommand):
tp
=
TablePrinter
(
titles
=
[
"ModuleName"
,
"Path"
],
placeholders
=
placeholders
)
for
module_name
,
module_dir
in
all_modules
.
items
():
tp
.
add_line
(
contents
=
[
module_name
,
module_dir
])
tp
.
add_line
(
contents
=
[
module_name
,
module_dir
[
0
]
])
print
(
tp
.
get_text
())
return
True
...
...
paddlehub/commands/show.py
浏览文件 @
92fdb878
...
...
@@ -103,7 +103,7 @@ class ShowCommand(BaseCommand):
colors
=
[
"light_red"
,
None
],
aligns
=
[
"^"
,
"<"
])
tp
.
add_line
(
contents
=
[
"Location"
,
module_dir
],
contents
=
[
"Location"
,
module_dir
[
0
]
],
colors
=
[
"light_red"
,
None
],
aligns
=
[
"^"
,
"<"
])
print
(
tp
.
get_text
())
...
...
@@ -125,9 +125,9 @@ class ShowCommand(BaseCommand):
cwd
=
os
.
getcwd
()
module_dir
=
default_module_manager
.
search_module
(
module_name
)
module_dir
=
os
.
path
.
join
(
cwd
,
module_name
)
if
not
module_dir
else
module_dir
if
not
module_dir
or
not
os
.
path
.
exists
(
module_dir
):
module_dir
=
(
os
.
path
.
join
(
cwd
,
module_name
)
,
None
)
if
not
module_dir
else
module_dir
if
not
module_dir
or
not
os
.
path
.
exists
(
module_dir
[
0
]
):
print
(
"%s is not existed!"
%
module_name
)
return
True
...
...
paddlehub/common/hub_server.py
浏览文件 @
92fdb878
...
...
@@ -24,6 +24,7 @@ import requests
import
json
import
yaml
from
random
import
randint
from
paddlehub.common
import
utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.server_config
import
default_server_config
...
...
@@ -46,11 +47,19 @@ class HubServer(object):
with
open
(
config_file_path
)
as
fp
:
self
.
config
=
json
.
load
(
fp
)
utils
.
check_url
(
self
.
config
[
'server_url'
])
self
.
server_url
=
self
.
config
[
'server_url'
]
self
.
_load_resource_list_file_if_valid
()
def
get_server_url
(
self
):
HS_ENV
=
os
.
environ
.
get
(
'HUB_SERVER'
)
if
HS_ENV
:
HUB_SERVERS
=
HS_ENV
.
split
(
';'
)
return
HUB_SERVERS
[
uniform
(
0
,
len
(
self
.
server_url
))]
return
self
.
server_url
[
uniform
(
0
,
len
(
self
.
server_url
))]
def
resource_list_file_path
(
self
):
return
os
.
path
.
join
(
hub
.
CACHE_HOME
,
RESOURCE_LIST_FILE
)
...
...
@@ -84,7 +93,7 @@ class HubServer(object):
payload
=
{
'word'
:
resource_key
}
if
resource_type
:
payload
[
'type'
]
=
resource_type
r
=
requests
.
get
(
self
.
server_url
+
'/'
+
'search'
,
params
=
payload
)
r
=
requests
.
get
(
self
.
get_server_url
()
+
'/'
+
'search'
,
params
=
payload
)
r
=
json
.
loads
(
r
.
text
)
if
r
[
'status'
]
==
0
and
len
(
r
[
'data'
])
>
0
:
return
[(
item
[
'name'
],
item
[
'type'
],
item
[
'version'
],
item
[
'summary'
])
...
...
@@ -134,7 +143,7 @@ class HubServer(object):
payload
[
'type'
]
=
resource_type
if
version
:
payload
[
'version'
]
=
version
r
=
requests
.
get
(
self
.
server_url
+
'/'
+
'search'
,
params
=
payload
)
r
=
requests
.
get
(
self
.
get_server_url
()
+
'/'
+
'search'
,
params
=
payload
)
r
=
json
.
loads
(
r
.
text
)
if
r
[
'status'
]
==
0
and
len
(
r
[
'data'
])
>
0
:
return
r
[
'data'
][
0
]
...
...
@@ -193,7 +202,7 @@ class HubServer(object):
if
not
os
.
path
.
exists
(
hub
.
CACHE_HOME
):
utils
.
mkdir
(
hub
.
CACHE_HOME
)
try
:
r
=
requests
.
get
(
self
.
server_url
+
'/'
+
'search'
)
r
=
requests
.
get
(
self
.
get_server_url
()
+
'/'
+
'search'
)
data
=
json
.
loads
(
r
.
text
)
cache_path
=
os
.
path
.
join
(
hub
.
CACHE_HOME
,
RESOURCE_LIST_FILE
)
with
open
(
cache_path
,
'w+'
)
as
fp
:
...
...
paddlehub/common/server_config.py
浏览文件 @
92fdb878
...
...
@@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
HUB_SERVERS
=
[
"http://hub.paddlepaddle.org:8888"
]
default_server_config
=
{
"server_url"
:
"http://hub.paddlepaddle.org:8888"
,
"resource_storage_server_url"
:
"https
//bj.bcebos.com/paddlehub
"
"server_url"
:
HUB_SERVERS
,
"resource_storage_server_url"
:
"https
://bj.bcebos.com/paddlehub/
"
}
paddlehub/module/manager.py
浏览文件 @
92fdb878
...
...
@@ -79,7 +79,7 @@ class LocalModuleManager(object):
module_name
,
module_version
)
tips
=
"Module %s already installed in %s"
%
(
module_tag
,
module_dir
)
return
True
,
tips
,
module_dir
return
True
,
tips
,
self
.
modules_dict
[
module_name
]
search_result
=
hub
.
default_hub_server
.
get_module_url
(
module_name
,
version
=
module_version
)
...
...
@@ -115,7 +115,7 @@ class LocalModuleManager(object):
tips
=
"Successfully installed %s"
%
module_name
if
installed_module_version
:
tips
+=
"-%s"
%
installed_module_version
return
True
,
tips
,
module_dir
return
True
,
tips
,
(
module_dir
,
installed_module_version
)
tips
=
"Download %s-%s failed"
%
(
module_name
,
module_version
)
return
False
,
tips
,
module_dir
...
...
paddlehub/module/module.py
浏览文件 @
92fdb878
...
...
@@ -121,7 +121,7 @@ class Module(object):
if
name
:
self
.
_init_with_name
(
name
=
name
,
version
=
version
)
elif
module_dir
:
self
.
_init_with_module_file
(
module_dir
=
module_dir
)
self
.
_init_with_module_file
(
module_dir
=
module_dir
[
0
]
)
elif
signatures
:
if
processor
:
if
not
issubclass
(
processor
,
BaseProcessor
):
...
...
@@ -149,7 +149,7 @@ class Module(object):
logger
.
error
(
tips
)
exit
(
1
)
logger
.
info
(
tips
)
self
.
_init_with_module_file
(
module_dir
)
self
.
_init_with_module_file
(
module_dir
[
0
]
)
def
_init_with_url
(
self
,
url
):
utils
.
check_url
(
url
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录