question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python-action: detect which dependencies changed and which targets are missing

See original GitHub issue

Essentially need to get the same information in a python-action as provided by doit info on the console.

I need this to process only those dependencies of the task which have changed.

What I’ve tried:

def my_action(task):
    print(task.dep_changed)

However this will print all the dependencies, no matter what. I guess it is related to this comment in the code:

        # dep_changed is set on get_status()
        # Some commands (like `clean` also uses expand_args but do not
        # uses get_status, so `changed` is not available.

And need the missing targets as well, those seem to be separate from dep_changed in doit info.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
patrikturicommented, Sep 18, 2019

@smarie Thank you! This helper is exactly what I needed.

1reaction
smariecommented, Jul 29, 2019

Also concerning the other topic in this ticket: I had the issue today to try to debug “why did a task run again ??? It should not”.

Being able to print to stdout the reason why tasks are run (dependency change or file dep change or target change) using a simple commandline flag (for example a maven-style flag doit -X or a pytest-style doit -v) would really be a killer feature - if it is not already there (in which case it should probably be highlighted in the doc in a better way). Should we open a ticket for this in particular ?

EDIT: for what’s worth, my current workaround for this is to use the following why_am_i_running python action explicitly at the beginning of all my task actions lists:

from os.path import exists

def why_am_i_running(task, changed):
    for t in task.targets:
        if not exists(t):
            print("Running task '%s' because one of its targets does not exist anymore: '%s'" % (task, t))
            return

    print("Running task '%s' because the following changed: '%s'" % (task, changed))

EDIT2: There might be a case missing in this draft: the case where result_dep is the reason for re-running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pydoit task dependency system support
Note that since a target represents an output of the task, a missing target is enough to determine that a task is not...
Read more >
Make dependency with existing target and missing dependency
Is there any way ? I found the solution of using an empty rule. D : at the end, so that missing D...
Read more >
native_client/src/third_party/scons-2.0.1 - Git at Google
+ + - Add sources for files whose targets don't exist in $CHANGED_SOURCES. + + - Detect implicit dependencies on commands even when...
Read more >
SCons 4.4.0
What Dependencies Does SCons Know About? the --tree Option; 28.4. ... which will then run SCons for each target created by a Python...
Read more >
Dependency Checking: make vs. Shell Scripts
Because make does a complete dependency scan, changes to a source file are ... it begins the dependency check with the first target...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found