def gen_nodes(self, subject, product, variants): if FilesystemNode.is_filesystem_pair(type(subject), product): # Native filesystem operations. yield FilesystemNode(subject, product, variants) else: # Tasks. for task, anded_clause in self._tasks[product]: yield TaskNode(subject, product, variants, task, anded_clause)
def invalidate_files(self, filenames): """Given a set of changed filenames, invalidate all related FilesystemNodes in the graph.""" subjects = set(FilesystemNode.generate_subjects(filenames)) logger.debug('generated invalidation subjects: %s', subjects) def predicate(node, state): return type(node) is FilesystemNode and node.subject in subjects return self.invalidate(predicate)
def create(cls, task_entries): """Creates a NodeBuilder with tasks indexed by their output type.""" serializable_tasks = defaultdict(set) for entry in task_entries: if isinstance(entry, (tuple, list)) and len(entry) == 3: output_type, input_selects, task = entry serializable_tasks[output_type].add( TaskNodeFactory(tuple(input_selects), task, output_type) ) elif isinstance(entry, SnapshottedProcess): serializable_tasks[entry.output_product_type].add(entry) else: raise Exception("Unexpected type for entry {}".format(entry)) intrinsics = dict() intrinsics.update(FilesystemNode.as_intrinsics()) intrinsics.update(SnapshotNode.as_intrinsics()) return cls(serializable_tasks, intrinsics)
def as_node(self, subject, variants): assert type(subject) is self.subject_type return FilesystemNode.create(subject, self.product_type, variants)