当前位置: 首页>>代码示例>>Python>>正文


Python Pool.reload_nodes方法代码示例

本文整理汇总了Python中ZIBMolPy.pool.Pool.reload_nodes方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.reload_nodes方法的具体用法?Python Pool.reload_nodes怎么用?Python Pool.reload_nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZIBMolPy.pool.Pool的用法示例。


在下文中一共展示了Pool.reload_nodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from ZIBMolPy.pool import Pool [as 别名]
# 或者: from ZIBMolPy.pool.Pool import reload_nodes [as 别名]
def main():
	options = options_desc.parse_args(sys.argv)[0]
	
	#TODO put somehow into Options, e.g. min_value=1 or required=True
	if(not options.doomed_nodes):
		sys.exit("Option --doomed_nodes is required.")
		
	pool = Pool()
	old_pool_size = len(pool)
	old_alpha = pool.alpha

	doomed_nodes = NodeList()
	
	#TODO: maybe this code should go into ZIBMolPy.ui 
	for name in options.doomed_nodes.split(","):
		found = [n for n in pool if n.name == name]
		if(len(found) != 1):
			sys.exit("Coult not find node '%s'"%(name))
		doomed_nodes.append(found[0])
	
	for n in doomed_nodes:
		if(n == pool.root):
			sys.exit("Node %s is the root. Removal not allowed."%(n.name))		
		#if(len(n.children) > 0):
		#	sys.exit("Node %s has children. Removal not allowed."%(n.name)) #TODO why should we forbid this?

	if not(userinput("The selected node(s) will be removed permanently. Continue?", "bool")):
		sys.exit("Quit by user.")

	assert(len(doomed_nodes) == len(doomed_nodes.multilock()))
	for n in doomed_nodes:
		print("Removing directory: "+n.dir)
		shutil.rmtree(n.dir)

	pool.reload_nodes()
	
	#TODO: this code-block also exists in zgf_create_node
	if(len(pool.where("isa_partition")) < 2):
		pool.alpha = None
	elif(options.methodalphas == "theta"):
		pool.alpha = zgf_create_nodes.calc_alpha_theta(pool)
	elif(options.methodalphas == "user"):
		pool.alpha = userinput("Please enter a value for alpha", "float")
	else:
		raise(Exception("Method unkown: "+options.methodalphas))

	pool.history.append({'removed_nodes': [(n.name, n.state) for n in doomed_nodes], 'size':old_pool_size, 'alpha':old_alpha, 'timestamp':datetime.now()})
	pool.save()

	#TODO: deal with analysis dir and dependencies
	zgf_cleanup.main()	
开发者ID:iwasherefirst2,项目名称:ZIBMolPy,代码行数:53,代码来源:zgf_remove_nodes.py

示例2: main

# 需要导入模块: from ZIBMolPy.pool import Pool [as 别名]
# 或者: from ZIBMolPy.pool.Pool import reload_nodes [as 别名]
def main():
	options = options_desc.parse_args(sys.argv)[0]
	pool = Pool()
	
	if(options.convtest):
		for n in pool.where("state in ('converged', 'not-converged')"):
			print("\n\nRunning Gelman-Rubin on %s"%n)
			conv_check_gelman_rubin(n)
		return # exit

	auto_refines_counter = 0
	while(True):		
		pool.reload()
		pool.reload_nodes()
		for n in pool:
			n.reload()

		active_node = None
		for n in pool.where("state in ('em-mdrun-able', 'mdrun-able', 'rerun-able-converged', 'rerun-able-not-converged')"):
			if(n.lock()):
				active_node = n
				break

		if(active_node == None):
			if(auto_refines_counter < options.auto_refines):
				auto_refines_counter += 1
				print("\n\nRunning 'zgf_refine --refine-all' for the %d time..."%auto_refines_counter)
				zgf_refine.main(["--refine-all"])
				continue
			else:
				break # we're done - exit
	
		try:
			process(active_node, options)
			active_node.save()
			active_node.unlock()
		except:
			print "MDRUN FAILED"
			active_node.state = "mdrun-failed"
			active_node.save()
			active_node.unlock()
			traceback.print_exc()
			continue
开发者ID:CMD-at-ZIB,项目名称:ZIBMolPy,代码行数:45,代码来源:zgf_mdrun.py


注:本文中的ZIBMolPy.pool.Pool.reload_nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。