def test_nodegraph_is_outdated__updates(): my_node = flexmock(input_files=("tests/data/timestamp_a_older",), output_files=("tests/data/timestamp_a_younger",)) assert not NodeGraph._is_outdated(my_node, FileStatusCache()) my_node = flexmock(input_files=("tests/data/timestamp_a_younger",), output_files=("tests/data/timestamp_a_older",)) assert NodeGraph._is_outdated(my_node, FileStatusCache())
def test_nodegraph_is_done__output_changes(temp_folder): temp_file_1 = os.path.join(temp_folder, "file_1.txt") temp_file_2 = os.path.join(temp_folder, "file_2.txt") my_node = flexmock(output_files=(temp_file_1, temp_file_2)) assert not NodeGraph._is_done(my_node, FileStatusCache()) set_file_contents(temp_file_1, "foo") assert not NodeGraph._is_done(my_node, FileStatusCache()) set_file_contents(temp_file_2, "bar") assert NodeGraph._is_done(my_node, FileStatusCache())
def run(self, max_running=1, dry_run=False, progress_ui="verbose"): assert max_running >= 1, max_running _update_nprocesses(self._pool, max_running) try: nodegraph = NodeGraph(self._nodes) except NodeGraphError, error: self._logger.error(error) return False
def to_dot(self, destination): """Writes a simlpe dot file to the specified destination, representing the full dependency tree, after MetaNodes have been removed. Nodes are named by their class. """ try: nodegraph = NodeGraph(self._nodes) except NodeGraphError, error: self._logger.error(error) return False
def list_output_files(self): output_files = {} nodegraph = NodeGraph(self._nodes) def collect_output_files(node): state = nodegraph.get_node_state(node) for filename in node.output_files: output_files[os.path.abspath(filename)] = state return True self.walk_nodes(collect_output_files) return output_files
def test_nodegraph_is_outdated__input_but_no_output(): my_node = flexmock(input_files=_IN_FILES, output_files=()) assert not NodeGraph._is_outdated(my_node, FileStatusCache())
def test_nodegraph_is_done__subnode_not_considered(temp_folder): temp_file = os.path.join(temp_folder, "file.txt") subnode = flexmock(output_files=(temp_file,)) my_node = flexmock(output_files=(), subnodes=(subnode,)) assert NodeGraph._is_done(my_node, FileStatusCache())
def test_nodegraph_is_done__no_output(): cache = FileStatusCache() node = flexmock(output_files=()) assert NodeGraph._is_done(node, cache)
def run(self, max_running=6, dry_run=False, collapse=True, verbose=True): try: nodegraph = NodeGraph(self._nodes) except NodeGraphError, error: ui.print_err(error, file=sys.stderr) return False