associatedpress / geomancer

Open source tool to help journalists easily mash up data based on shared geography.
MIT License
58 stars 12 forks source link

Parameter in api/geomance endpoint should possibly be input_file, not file #96

Open michelleminkoff opened 8 years ago

michelleminkoff commented 8 years ago

According to the code here, https://github.com/associatedpress/geomancer/blob/master/geomancer/api.py

a colleague and I wondered if the file param specified in the api docs should actually be input_file, since that is what the code seems to be looking for in the request.

myersjustinc commented 8 years ago

Specifically, the /api/geomance/ documentation at this line suggests the uploaded file should be named file: geomance

The code, though, consistently refers to it as input_file:

zstumgoren commented 8 years ago

@myersjustinc Did you try the API call using "input_file" instead of file? And if so, what were the results?

In my tests, any incantation of the api call was failing at the previous line where the JSON is deserialized (see stack trace below), which makes me think this is not purely a documentation problem.

Even if it is, can you post code samples of the calls you were making? I can test as well and see if the calls get farther into the stack before failing.

Meantime, here's the stack trace I was getting from various API calls (please ignore the fact that it says line 54 below; that's due to a print statement i dropped into code for debugging).

Traceback (most recent call last):
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/ubuntu/.virtualenvs/geomancer/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ubuntu/code/geomancer/geomancer/api.py", line 54, in geomance_api
    field_defs = json.loads(request.data)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
zstumgoren commented 8 years ago

In my tests, any incantation of the api call was failing at the previous line where the JSON is deserialized (see stack trace below), which makes me think this is not purely a documentation problem.

To be clear, it's quite likely I was botching the API call signatures/construction, which is why I'm hoping you can provide some sample calls to see if they get farther into the stack.