Dependencies not executed for tasks selected on the command line
henrus opened this issue · comments
Hi,
thanks for this great tool.
import json
def task_read():
def read():
with open('data.txt') as json_file:
data = json.load(json_file)
return data
return {
'file_dep': ['data.txt'],
'actions': [(read,)],
'verbosity': 2,
}
def show_getargs(x, y):
print("this is x: {}".format(x))
print("this is y: {}".format(y))
def task_use_python():
return {
'actions': [show_getargs],
'getargs': {'x': ('read', 'x'),
'y': ('read', 'y')},
'verbosity': 2,
}
user@machine-> cat data.txt
{
"a": 1,
"x": 2,
"y": 3,
"z": 4
}
user@machine-> doit
. read
. use_python
this is x: 2
this is y: 3
--> This is OK.
user@machine-> sed -i 's/2/12/g' data.txt
user@machine-> doit
. read
. use_python
this is x: 12
this is y: 3
--> This is OK.
user@machine-> sed -i 's/3/13/g' data.txt
user@machine-> doit use_python
-- use_python
IMHO this is not OK since the read task should be fired up. I expected the following output
user@machine-> doit use_python
. read
. use_python
this is x: 12
this is y: 13
Best Regards,
Henrik
Environment
- OS: Ubuntu 16.04
- python version: 3.6
- doit version: 0.32
This is the expected behaviour. Docs says "getargs" creates an implicit "setup_task".
But your expectation is also valid. I actually decided that it implicitly creates a "setup_task" because it is easy to explicitly add "task_dep" to achieve what you want.
But if the implicit creation was "task_dep" it would not be possible for it to behave like a "setup_task".
I will tag this issue as "doc", so we can make the documentation clear.
TLDR:
Add the following to use_python
:
"task_dep": ["read"],