I'm reading pyinvoke docs and I'm searching any easy way to execute invoke tasks from other python script. Tasks don't have method run so I can't import them and simply .run(). I found that there is Executor Class but how I understand I need to first declare Collection of tasks and then I can run one of tasks from script. Maybe there is another way to do it easiest from other python script which isn't task?
Asked
Active
Viewed 604 times
3
-
This is not part of Invoke's API yet. See https://github.com/pyinvoke/invoke/issues/112 and https://github.com/pyinvoke/invoke/issues/170 – florisla Jan 08 '20 at 11:13
1 Answers
0
The point is "task is also a python function", so you can invoke task by calling task function as following:
Define a task function test
in a.py
.
#a.py
from invoke import task
@task
def test(c):
print("hello, I'm a-test!")
Import module a
and execute task by calling a.test()
function.
#tasks.py
from invoke import task
import a
@task
def executeatest(c):
print('executing [a-test] task defined in "a.py"')
a.test(c)
When you execute inv executeatest
, it results:
executing [a-test] task defined in "a.py"
hello, I'm a-test!

Fhope Cc
- 35
- 5