def vtk_hasher(pipeline, module, chm): outgoing_connections = pipeline.graph.edges_from(module.id) incoming_connections = pipeline.graph.edges_to(module.id) current_hash = Hasher.module_signature(module, chm) chashes = [Hasher.connection_signature(pipeline.connections[c_id]) for (_, c_id) in outgoing_connections] chashes += [Hasher.connection_signature(pipeline.connections[c_id]) for (_, c_id) in incoming_connections] compound_hash = Hasher.compound_signature(chashes) return Hasher.compound_signature([current_hash, compound_hash])
def persistent_module_hasher(pipeline, module, chm): current_hash = Hasher.module_signature(module, chm) ref = None read_local = False for function in module.functions: if function.name == "ref": ref = PersistentRef.translate_to_python(function.params[0].strValue) if function.name == 'readLocal': read_local = \ Boolean.translate_to_python(function.params[0].strValue) if ref and not read_local and db_access.ref_exists(ref.id, ref.version): if ref.version is None: ref.version = PersistentPath.git_get_latest_version(ref.id) return Hasher.compound_signature([current_hash, str(ref.id), str(ref.version)]) return current_hash
def persistent_module_hasher(pipeline, module, chm): current_hash = Hasher.module_signature(module, chm) ref = None read_local = False for function in module.functions: if function.name == "ref": ref = PersistentRef.translate_to_python( function.params[0].strValue) if function.name == 'readLocal': read_local = \ Boolean.translate_to_python(function.params[0].strValue) if ref and not read_local and db_access.ref_exists(ref.id, ref.version): if ref.version is None: ref.version = PersistentPath.git_get_latest_version(ref.id) return Hasher.compound_signature( [current_hash, str(ref.id), str(ref.version)]) return current_hash
def group_signature(pipeline, module, chm): if module._port_specs is None: module.make_port_specs() input_conns = {} input_functions = {} for from_module, c_id in pipeline.graph.edges_to(module.id): conn = pipeline.connections[c_id] if conn.destination.name not in input_conns: input_conns[conn.destination.name] = [] input_conns[conn.destination.name].append((from_module, conn)) for function in module.functions: if function.name not in input_functions: input_functions[function.name] = [] input_functions[function.name].append(function) covered_modules = dict((k, False) for k in module._input_remap) for input_port_name, conn_list in input_conns.iteritems(): covered_modules[input_port_name] = True input_module = module._input_remap[input_port_name] upstream_sigs = [(pipeline.subpipeline_signature(m) + Hasher.connection_signature(c)) for (m, c) in conn_list] module_sig = Hasher.module_signature(input_module, chm) sig = Hasher.subpipeline_signature(module_sig, upstream_sigs) if input_port_name in input_functions: function_sig = hash_list(input_functions[input_port_name], Hasher.function_signature, chm) sig = Hasher.compound_signature([sig, function_sig]) input_module._input_port_signature = sig for input_port_name, done in covered_modules.iteritems(): if done: continue covered_modules[input_port_name] = True input_module = module._input_remap[input_port_name] if input_port_name in input_functions: module_sig = Hasher.module_signature(input_module, chm) function_sig = hash_list(input_functions[input_port_name], Hasher.function_signature, chm) sig = Hasher.compound_signature([module_sig, function_sig]) else: sig = Hasher.module_signature(input_module, chm) input_module._input_port_signature = sig module.pipeline.refresh_signatures() sig_list = [] sig_list.append(Hasher.module_signature(module, chm)) for m_id in module.pipeline.graph.sinks(): sig_list.append(module.pipeline.subpipeline_signature(m_id)) return Hasher.compound_signature(sig_list)