diff --git a/orchestra/actions/action.py b/orchestra/actions/action.py index 5af1ffb9e5b064cc143541c1beaeafd0be6b2943..77437eebf1cf32aae7aaf2f21cb44fefe052935c 100644 --- a/orchestra/actions/action.py +++ b/orchestra/actions/action.py @@ -1,7 +1,8 @@ from collections import OrderedDict -from loguru import logger from typing import Set +from loguru import logger + from .util import run_script @@ -56,6 +57,10 @@ class Action: """Returns true if the action is satisfied, false if it needs to run.""" raise NotImplementedError() + def can_run(self): + """Returns true if the action can be run (i.e. all its dependencies are satisfied)""" + return all(d.is_satisfied() for d in self.dependencies) + @property def environment(self) -> OrderedDict: """Returns additional environment variables provided to the script to be run""" diff --git a/orchestra/cmds/graph.py b/orchestra/cmds/graph.py index e703f51b25c1672164a9bf87dcb2ac4b64cc49f1..855f0a3f189efe76d4a4ef36a1706582f421ef10 100644 --- a/orchestra/cmds/graph.py +++ b/orchestra/cmds/graph.py @@ -4,7 +4,8 @@ from ..model.configuration import Configuration def install_subcommand(sub_argparser): cmd_parser = sub_argparser.add_parser("graph", handler=handle_graph) cmd_parser.add_argument("component", nargs="?") - cmd_parser.add_argument("--all-builds", action="store_true", help="Include all builds instead of only the default one.") + cmd_parser.add_argument("--all-builds", action="store_true", + help="Include all builds instead of only the default one.") def handle_graph(args, config: Configuration): @@ -32,7 +33,13 @@ def print_dependencies(actions): if action in already_visited_actions: return - color = "green" if action.is_satisfied(recursively=True) else "red" + if action.is_satisfied(recursively=True): + color = "green" + elif action.can_run(): + color = "orange" + else: + color = "red" + rows.add(f' "{action.name_for_graph}"[ shape=box, style=filled, color={color} ];') for d in action.dependencies: rows.add(f' "{d.name_for_graph}" -> "{action.name_for_graph}";')