0

I am using python to import data onto a server running predictionio.
I am using the following code to set up the 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 }
            ) 

However I keep getting the following message:

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.

I'm clearly not specifying an app id, as I'm passing the client a named argument: "access_key". Removing the qsizeargument does nothing, the error just gets blamed on the line above, and so on. I can't find anything in the documentation and it's probably because I'm so new to all of this that I can't find out where I'm going wrong.
All of the tutorials I have been looking at create EventClients in this way and it works no problem:
http://predictionio.incubator.apache.org/datacollection/eventapi/
Any help would be greatly appreciated. Thanks.

  • "Or you may use an earlier version of this sdk"... Try a `pip install --upgrade predictionio` – OneCricketeer Dec 22 '16 at 21:34
  • I read that as "if you want to specify an app name instead, use an earlier version of the sdk". I installed predictionio today so its definitely up to date, and I ran the command you gave just to be sure. Still nothing – user6787998 Dec 22 '16 at 21:38
  • it could also mean that :) I read it as "Deprecation warning... you may be using an earlier version". – OneCricketeer Dec 22 '16 at 21:39

1 Answers1

1

access_key must be greater than 8 characters long.

Source code

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.")

For example

>>> 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')
>>>
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Thank you, that helps loads. Unfortunately I'm now getting "predictionio.NotCreatedError: Exception happened: [Errno 10061] No connection could be made because the target machine actively refused it for request POST..." any idea why? – user6787998 Dec 22 '16 at 22:03
  • No idea. I was just helping with the initial error message. That sounds like you have networking issues on your computer, though. – OneCricketeer Dec 22 '16 at 22:04
  • In other words, read the documentation... "**url** – the url of PredictionIO **Event Server**". No part of your question has an `EventServer` – OneCricketeer Dec 22 '16 at 22:06
  • The Event Server is already started at localhost:7070. I appreciate the help, sounds like networking issues indeed. I have guest access to the server predictionio is installed on, could that be why my post request is being refused? – user6787998 Dec 22 '16 at 22:19
  • Does the server have any log output saying that it has indeed started? Because you should not have ever gotten your initial error if you had actually used a valid access key from the command `pio app new MyTestApp` from that link I provided. It is much longer than 8 characters and not `'285'` as you have in your question. – OneCricketeer Dec 22 '16 at 23:52
  • Yep, when I send a GET request to localhost:7070 I get back {"status":"alive"}. I already changed the access key to 285285285 after you said and that got rid of the initial error however now I am facing this. – user6787998 Dec 23 '16 at 00:00
  • Are you able to do a Raw HTTP request using `curl` or Postman? The problem could be related to the Python SDK, so you should at least verify that the server is working in some other way – OneCricketeer Dec 23 '16 at 00:04
  • Yes, it works perfectly fine with curl, see my new question: http://stackoverflow.com/questions/41293457/predictionio-why-can-i-make-post-requests-with-curl-but-not-python – user6787998 Dec 23 '16 at 00:07