algorithmiaio/algorithmia-python

Missing default API server and requiring string quotes when doing "algo auth"

Closed this issue · 2 comments

I came across a few unexpected behaviors, when installing the Python Client on deepPurple, for my own user. I'll list them altogether in this issue.

After the client is installed through the wheel, as per the instructions:

Trying to authorize, I would expect that the API adress is provided by default, as api.algorithmia.com and I would be able to pass this step without entering anything. Pressing enter gives the following error:

asli@deeppurple:~$ algo auth
Configuring authentication for profile: default
enter API address [api.algorithmia.com]:
Traceback (most recent call last):
  File "/home/asli/.local/bin/algo", line 10, in <module>
    sys.exit(main())
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/__main__.py", line 113, in main
    APIaddress = input("enter API address [api.algorithmia.com]:")
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing

Now entering api.algorithmia.com as the API address, but got the following error.
Apparently it’s asking me to use string quotes, but I don’t think this is the expectation. We’re more used to entering string inputs without the quotes.

asli@deeppurple:~$ algo auth
Configuring authentication for profile: default
enter API address [api.algorithmia.com]:api.algorithmia.com
Traceback (most recent call last):
  File "/home/asli/.local/bin/algo", line 10, in <module>
    sys.exit(main())
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/__main__.py", line 113, in main
    APIaddress = input("enter API address [api.algorithmia.com]:")
  File "<string>", line 1, in <module>
NameError: name 'api' is not defined

The same goes for the API key, again entering it without the quotes gives the same error.

asli@deeppurple:~$ algo auth
Configuring authentication for profile: default
enter API address [api.algorithmia.com]:"api.algorithmia.com"
enter API key:sim0/CA0mCa6Xz3FAkyoHb45G5I1
Traceback (most recent call last):
  File "/home/asli/.local/bin/algo", line 10, in <module>
    sys.exit(main())
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/__main__.py", line 114, in main
    APIkey = input("enter API key:")
  File "<string>", line 1, in <module>
NameError: name 'sim0' is not defined

Now using the quotes for both fields and the client is good to go.

asli@deeppurple:~$ algo auth
Configuring authentication for profile: default
enter API address [api.algorithmia.com]:"api.algorithmia.com"
enter API key:"sim0/CA0mCa6Xz3FAkyoHb45G5I1"
usage: algo [-h] [--profile PROFILE]
            {auth,clone,run,ls,rm,mkdir,rmdir,cp,cat,help} ..

@BenT00le I assigned this to you as it's related to your previous PR but please let me know if these were addressed already and I'm missing anything. Thank you!

Hey Ben, re-trying this again on deep purple, making sure that I'm on the right branch before I do the local install, I get the same error. Here's my steps:

  1. log in to deep purple
  2. pip uninstall algorithmia
  3. make sure algo command doesn't run:
asli@deeppurple:~$ algo
Command 'algo' not found, did you mean:
  1. checkout this repo and switch to UpdateCLI branch:
asli@deeppurple:~/algorithmia-python$ git branch
* UpdateCLI
  master
  1. Install the client as per the instructions: python setup.py bdist_wheel +pip install --user --upgrade dist/algorithmia-*.whl
  2. now the algo command runs and asks me to properly use it, as expected
  3. I do algo ls but get this exception:
asli@deeppurple:~/algorithmia-python$ algo ls
Traceback (most recent call last):
  File "/home/asli/.local/bin/algo", line 10, in <module>
    sys.exit(main())
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/__main__.py", line 155, in main
    print(CLI().ls(args.path, client, args.long))
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/CLI.py", line 210, in ls
    for f in listingDir.list():
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/datadirectory.py", line 108, in _get_directory_iterator
    response = self.client.getHelper(url, **query_params)
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/client.py", line 74, in getHelper
    return requests.get(self.apiAddress + url, headers=headers, params=query_parameters)
  File "/home/asli/.local/lib/python2.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/home/asli/.local/lib/python2.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/asli/.local/lib/python2.7/site-packages/requests/sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "/home/asli/.local/lib/python2.7/site-packages/requests/sessions.py", line 459, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/asli/.local/lib/python2.7/site-packages/requests/models.py", line 314, in prepare
    self.prepare_url(url, params)
  File "/home/asli/.local/lib/python2.7/site-packages/requests/models.py", line 388, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'api.algorithmia.com/v1/data/': No schema supplied. Perhaps you meant http://api.algorithmia.com/v1/data/?
  1. Then I do algo auth and get this, as expected:
    asli@deeppurple:~/algorithmia-python$ algo auth Configuring authentication for profile: default enter API address [https://api.algorithmia.com]:
  2. just pressing enter gives this error:
asli@deeppurple:~/algorithmia-python$ algo auth
Configuring authentication for profile: default
enter API address [https://api.algorithmia.com]:    
Traceback (most recent call last):
  File "/home/asli/.local/bin/algo", line 10, in <module>
    sys.exit(main())
  File "/home/asli/.local/lib/python2.7/site-packages/Algorithmia/__main__.py", line 114, in main
    APIaddress = input("enter API address [https://api.algorithmia.com]:")
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing

Can you please check these and let me know if there's anything I should make sure to correctly test your branch, if that's not what I'm doing?
Thank you!