yhat / yhat-client

Python client for ScienceOps
https://www.yhat.com/products/scienceops
29 stars 10 forks source link

Can't deploy after pasting into ipython console #20

Open glamp opened 7 years ago

glamp commented 7 years ago
>>> from yhat import Yhat, YhatModel, preprocess
>>> class HelloWorld(YhatModel):
...     @preprocess(in_type=dict, out_type=dict)
...     def execute(self, data):
...         me = data['name']
...         greeting = "Hello %s!" % me
...         return { "greeting": greeting }
... 
>>> yh.deploy("HelloWorld", HelloWorld, globals())
Are you sure you want to deploy? (y/N): y
extracting model
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/yhat/api.py", line 436, in deploy
    bundle = self._extract_model(name, model, session, verbose=verbose, autodetect=autodetect, is_tensorflow=is_tensorflow)
  File "/usr/local/lib/python2.7/site-packages/yhat/api.py", line 342, in _extract_model
    bundle = save_function(model, session)
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/save_session.py", line 402, in save_function
    imports, source_code, pickles, modules = _spider_function(function, session)
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/save_session.py", line 289, in _spider_function
    source += _get_source(function) + '\n'
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/save_session.py", line 80, in _get_source
    return reindent(_get_source_no_reindent(func))
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/save_session.py", line 97, in _get_source_no_reindent
    wrapped_source = "\n" + reindent(wrapped_source) + "\n"
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/save_session.py", line 30, in reindent
    r.run()
  File "/usr/local/lib/python2.7/site-packages/yhat/deployment/reindenter.py", line 148, in run
    for _token in tokens:
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tokenize.py", line 374, in generate_tokens
    ("<tokenize>", lnum, pos, line))
  File "<tokenize>", line 2
    def execute(self, data):
    ^
IndentationError: unindent does not match any outer indentation level
glamp commented 7 years ago

better warning in v1.9.11