【问题标题】:predictionio seems to be misreading my argumentspredictionio 似乎误读了我的论点
【发布时间】:2016-12-22 21:22:51
【问题描述】:

我正在使用 python 将数据导入到运行 predictionio 的服务器上。
我正在使用以下代码来设置 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.

我显然没有指定应用程序 ID,因为我正在向客户端传递一个命名参数:“access_key”。删除qsizeargument 没有任何作用,错误只会归咎于上面的行,依此类推。我在documentation 中找不到任何东西,这可能是因为我对这一切都很陌生,所以我找不到哪里出错了。
我一直在看的所有教程都以这种方式创建 EventClients 并且没有问题:
http://predictionio.incubator.apache.org/datacollection/eventapi/
任何帮助将不胜感激。谢谢。

【问题讨论】:

  • "或者你可以使用这个sdk的早期版本"...试试pip install --upgrade predictionio
  • 我将其理解为“如果您想指定应用名称,请使用早期版本的 sdk”。我今天安装了 predictionio,所以它绝对是最新的,我运行了你给出的命令来确定。还是什么都没有
  • 这也可能意味着 :) 我将其解读为“弃用警告......您可能使用的是早期版本”。

标签: python localhost predictionio


【解决方案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')
>>>

【讨论】:

  • 谢谢,这有助于加载。不幸的是,我现在收到“predictionio.NotCreatedError:发生异常:[Errno 10061] 无法建立连接,因为目标机器主动拒绝它的请求 POST ...”知道为什么吗?
  • 不知道。我只是在帮助处理最初的错误消息。不过,听起来您的计算机上存在网络问题。
  • 换句话说,请阅读文档...“url – PredictionIO Event Server 的 url”。您问题的任何部分都没有EventServer
  • 事件服务器已经在 localhost:7070 启动。感谢您的帮助,听起来确实像网络问题。我有访客访问安装的服务器 predictionio,这可能是我的帖子请求被拒绝的原因吗?
  • 服务器是否有任何日志输出表明它确实已启动?因为如果您实际上使用了来自我提供的链接中的命令pio app new MyTestApp 的有效访问密钥,那么您不应该得到最初的错误。它比 8 个字符长得多,而不是您在问题中提到的 '285'
猜你喜欢
  • 1970-01-01
  • 2011-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-16
  • 1970-01-01
相关资源
最近更新 更多