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

Dependencies not executed for tasks selected on the command line #367

Open
henrus opened this issue Jul 28, 2020 · 1 comment
Open

Dependencies not executed for tasks selected on the command line #367

henrus opened this issue Jul 28, 2020 · 1 comment
Labels

Comments

@henrus
Copy link

henrus commented Jul 28, 2020

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

  1. OS: Ubuntu 16.04
  2. python version: 3.6
  3. doit version: 0.32
Fund with Polar
@schettino72
Copy link
Member

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"],

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

No branches or pull requests

2 participants