Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running example "invoke app.run" fails with "Type Error:Tasks must have an initial Context argument" #39

Closed
ilaif opened this issue Nov 18, 2016 · 5 comments

Comments

@ilaif
Copy link

ilaif commented Nov 18, 2016

Hey,

Sounds like a great project. However I'm trying to run it on my local machine (OSX El-Capitan, Python 2.7.10) and I receive an error:

>> invoke app.run
2016-11-18 12:15:27,067 [WARNING] [tasks.app.db] Alembic cannot be imported, so some app.db.* tasks won't be available!
Traceback (most recent call last):
  File "/usr/local/bin/invoke", line 11, in <module>
    sys.exit(program.run())
  File "/usr/local/lib/python2.7/site-packages/invoke/program.py", line 269, in run
    self._parse(argv)
  File "/usr/local/lib/python2.7/site-packages/invoke/program.py", line 325, in _parse
    self.load_collection()
  File "/usr/local/lib/python2.7/site-packages/invoke/program.py", line 473, in load_collection
    coll = loader.load(coll_name) if coll_name else loader.load()
  File "/usr/local/lib/python2.7/site-packages/invoke/loader.py", line 53, in load
    module = imp.load_module(name, fd, path, desc)
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/__init__.py", line 61, in <module>
    from . import app
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/__init__.py", line 8, in <module>
    from . import dependencies, env, db, run, users
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/db.py", line 272, in <module>
    def init_development_data(context, upgrade_db=True, skip_on_failure=False):
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/_utils.py", line 58, in app_context_task
    return Task(wrapper, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/invoke/tasks.py", line 58, in __init__
    self.positional = self.fill_implicit_positionals(positional)
  File "/usr/local/lib/python2.7/site-packages/invoke/tasks.py", line 149, in fill_implicit_positionals
    args, spec_dict = self.argspec(self.body)
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/_utils.py", line 21, in argspec
    return super(Task, self).argspec(body)
  File "/usr/local/lib/python2.7/site-packages/invoke/tasks.py", line 144, in argspec
    raise TypeError("Tasks must have an initial Context argument!")
TypeError: Tasks must have an initial Context argument!

I must be missing something very trivial, I event tried to manually pip install the requirements to make sure I have all the dependencies.

Thanks,
Ilai.

@frol
Copy link
Owner

frol commented Nov 18, 2016

It seems like you are using Invoke <0.13. Either update it or wait a couple of hours while I backport all new features and fixes back to this example project.

@ilaif
Copy link
Author

ilaif commented Nov 18, 2016

Thanks! However:

 » pip show invoke
Name: invoke
Version: 0.13.0
Summary: Pythonic task execution
Home-page: http://docs.pyinvoke.org
Author: Jeff Forcier
Author-email: jeff@bitprophet.org
License: BSD
Location: /usr/local/lib/python2.7/site-packages
Requires: 

@frol
Copy link
Owner

frol commented Nov 18, 2016

Maybe it is the other way around... Try downgrading it to <0.13.

@ilaif
Copy link
Author

ilaif commented Nov 18, 2016

Thanks, I've downgraded and upgraded pip and now it's no longer an issue.

Now I'm having a problem with migrations:

2016-11-18 17:10:47,940 [INFO] [tasks.app.dependencies] Swagger UI is installed.
/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.babel is deprecated, use flask_babel instead.
  .format(x=modname), ExtDeprecationWarning
Traceback (most recent call last):
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/bin/inv", line 11, in <module>
    sys.exit(program.run())
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/program.py", line 270, in run
    self.execute()
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/program.py", line 379, in execute
    executor.execute(*self.tasks)
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/executor.py", line 114, in execute
    result = call.task(*args, **call.kwargs)
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/tasks.py", line 113, in __call__
    result = self.body(*args, **kwargs)
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/run.py", line 37, in run
    context.invoke_execute(context, 'app.db.upgrade', app=app)
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/__init__.py", line 72, in invoke_execute
    results = Executor(namespace, config=context.config).execute((command_name, kwargs))
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/executor.py", line 114, in execute
    result = call.task(*args, **call.kwargs)
  File "/Users/ilaif/.virtualenvs/flask_restplus_example/lib/python2.7/site-packages/invoke/tasks.py", line 113, in __call__
    result = self.body(*args, **kwargs)
  File "/Users/ilaif/Desktop/flask-restplus-server-example/tasks/app/_utils.py", line 56, in wrapper
    return func(*args, **kwargs)
TypeError: upgrade() takes at least 1 argument (0 given)

Really appreciating your help, I think I'm close :)

@frol frol closed this as completed in cef3d20 Nov 18, 2016
@frol
Copy link
Owner

frol commented Nov 18, 2016

Please, try the latest master. Both invoke 0.12 and 0.13 should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants