我正在使用python将数据导入到运行预测的服务器上 我使用以下代码来设置EventClient:
import predictionio
client = predictionio.EventClient(
access_key='285',
url='http://localhost:7070',
threads=5,
qsize=500)
client.create_event(
event="rate",
entity_type="user",
entity_id="Bob",
target_entity_type="item",
target_entity_id="Fred",
properties= { "rating" : 5.0 }
)
但是我不断收到以下消息:
python imp.py
Traceback (most recent call last):
File "imp.py", line 6, in <module>
qsize=500)
File "C:\...\predictioni
"It seems like you are specifying an app_id. It is deprecate
DeprecationWarning: It seems like you are specifying an app_id.
ss_key instead. Or, you may use an earlier version of this sdk.
我明确没有指定app id,因为我正在向客户端传递一个命名参数:&#34; access_key&#34;。删除qsize
参数不执行任何操作,错误只会归咎于上面的行,依此类推。我无法在documentation中找到任何内容,可能是因为我对所有这些都很新,我无法找到我要去的地方错了。
我一直在研究的所有教程都以这种方式创建EventClients,它没有问题:
http://predictionio.incubator.apache.org/datacollection/eventapi/
任何帮助将不胜感激。感谢。
答案 0 :(得分:1)
access_key
的长度必须大于8个字符。
源代码
class EventClient(BaseClient):
def __init__(self, access_key,
url="http://localhost:7070",
threads=1, qsize=0, timeout=5, channel=None):
assert type(access_key) is str, ("access_key must be string. "
"Notice that app_id has been deprecated in Prediction.IO 0.8.2. "
"Please use access_key instead.")
super(EventClient, self).__init__(url, threads, qsize, timeout)
# SEE HERE...
if len(access_key) <= 8:
raise DeprecationWarning(
"It seems like you are specifying an app_id. It is deprecated in "
"Prediction.IO 0.8.2. Please use access_key instead. Or, "
"you may use an earlier version of this sdk.")
例如
>>> client = predictionio.EventClient(access_key='12345678')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/env/py2/lib/python2.7/site-packages/predictionio/__init__.py", line 178, in __init__
"It seems like you are specifying an app_id. It is deprecated in "
DeprecationWarning: It seems like you are specifying an app_id. It is deprecated in Prediction.IO 0.8.2. Please use access_key instead. Or, you may use an earlier version of this sdk.
>>> client = predictionio.EventClient(access_key='123456789')
>>>