gramener / gramex

A visual analytics platform to build data-based web apps with less code.
https://gramener.com/gramex/guide/
Other
142 stars 56 forks source link

Debuggable error message: Formhandler queryfunction for errors related to dependencies #169

Open tejesh0 opened 5 years ago

tejesh0 commented 5 years ago

For example:

If a project uses tweepy as third party library. The current python environment does not have the tweepy installed. The python file name is analyzetweets.py and tweepy is imported in this file. On running a formhandler endpoint like below

....
...
    pattern: /$YAMLURL/analysis
    handler: FormHandler
    kwargs:
      url: sqlite:///$YAMLPATH/twitterdata.db
      table: tweets
      queryfunction: analyzetweets.tweet_query(args)
ERROR   04-Jun 14:35:01 web Uncaught exception GET /analysis2?chart=tweet_count_year (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:8080', method='GET', uri='/analysis2?chart=tweet_count_year', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "c:\users\gramener.desktop-vq4qjvq\anaconda3\envs\py37\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "c:\users\gramener.desktop-vq4qjvq\anaconda3\envs\py37\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "c:\users\gramener.desktop-vq4qjvq\anaconda3\envs\py37\lib\site-packages\tornado\gen.py", line 326, in wrapper
    yielded = next(result)
  File "c:\users\gramener.desktop-vq4qjvq\anaconda3\envs\py37\lib\site-packages\gramex\handlers\formhandler.py", line 147, in get
    opt = self._options(dataset, self.args, path_args, path_kwargs, key)
  File "c:\users\gramener.desktop-vq4qjvq\anaconda3\envs\py37\lib\site-packages\gramex\handlers\formhandler.py", line 133, in _options
    filter_kwargs['query'] = queryfunction(args=args, key=key, handler=self)
  File "formhandler2.data.queryfunction", line 2, in transform
NameError: name 'analyzetweets' is not defined

instead of throwing tweepy not found error (which is the root cause).

pratapvardhan commented 5 years ago

tweepy error would have been throw during gramex launch (When handlers are being setup). Could you look up your console log and add that to description or confirm it doesn't do that either?

tejesh0 commented 5 years ago

Not actually. Rechecked