本文整理汇总了Python中fireworks.core.launchpad.LaunchPad.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python LaunchPad.from_file方法的具体用法?Python LaunchPad.from_file怎么用?Python LaunchPad.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fireworks.core.launchpad.LaunchPad
的用法示例。
在下文中一共展示了LaunchPad.from_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_launch
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def do_launch(args):
if not args.launchpad_file and os.path.exists(
os.path.join(args.config_dir, 'my_launchpad.yaml')):
args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
elif not args.launchpad_file:
args.launchpad_file = LAUNCHPAD_LOC
if not args.fworker_file and os.path.exists(
os.path.join(args.config_dir, 'my_fworker.yaml')):
args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
elif not args.fworker_file:
args.fworker_file = FWORKER_LOC
if not args.queueadapter_file and os.path.exists(
os.path.join(args.config_dir, 'my_qadapter.yaml')):
args.queueadapter_file = os.path.join(args.config_dir, 'my_qadapter.yaml')
elif not args.queueadapter_file:
args.queueadapter_file = QUEUEADAPTER_LOC
launchpad = LaunchPad.from_file(
args.launchpad_file) if args.launchpad_file else LaunchPad(
strm_lvl=args.loglvl)
fworker = FWorker.from_file(
args.fworker_file) if args.fworker_file else FWorker()
queueadapter = load_object_from_file(args.queueadapter_file)
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
if args.command == 'rapidfire':
rapidfire(launchpad, fworker=fworker, qadapter=queueadapter, launch_dir=args.launch_dir,
nlaunches=args.nlaunches, njobs_queue=args.maxjobs_queue,
njobs_block=args.maxjobs_block, sleep_time=args.sleep,
reserve=args.reserve, strm_lvl=args.loglvl, timeout=args.timeout, fill_mode=args.fill_mode)
else:
launch_rocket_to_queue(launchpad, fworker, queueadapter,
args.launch_dir, args.reserve, args.loglvl, False, args.fill_mode)
示例2: do_launch
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def do_launch(args):
if not args.launchpad_file and os.path.exists(
os.path.join(args.config_dir, 'my_launchpad.yaml')):
args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
if not args.fworker_file and os.path.exists(
os.path.join(args.config_dir, 'my_fworker.yaml')):
args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
if not args.queueadapter_file and os.path.exists(
os.path.join(args.config_dir, 'my_qadapter.yaml')):
args.queueadapter_file = os.path.join(args.config_dir,
'my_qadapter.yaml')
launchpad = LaunchPad.from_file(
args.launchpad_file) if args.launchpad_file else LaunchPad(
strm_lvl=args.loglvl)
fworker = FWorker.from_file(
args.fworker_file) if args.fworker_file else FWorker()
queueadapter = load_object_from_file(args.queueadapter_file)
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
if args.command == 'rapidfire':
rapidfire(launchpad, fworker, queueadapter, args.launch_dir,
args.nlaunches, args.maxjobs_queue,
args.maxjobs_block, args.sleep, args.reserve, args.loglvl)
else:
launch_rocket_to_queue(launchpad, fworker, queueadapter,
args.launch_dir, args.reserve, args.loglvl, False)
示例3: rlaunch
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def rlaunch():
m_description = 'This program launches one or more Rockets. A Rocket grabs a job from the central database and ' \
'runs it. The "single-shot" option launches a single Rocket, ' \
'whereas the "rapidfire" option loops until all FireWorks are completed.'
parser = ArgumentParser(description=m_description)
subparsers = parser.add_subparsers(help='command', dest='command')
single_parser = subparsers.add_parser('singleshot', help='launch a single Rocket')
rapid_parser = subparsers.add_parser('rapidfire',
help='launch multiple Rockets (loop until all FireWorks complete)')
single_parser.add_argument('-f', '--fw_id', help='specific fw_id to run', default=None, type=int)
single_parser.add_argument('--offline', help='run in offline mode (FW.json required)', action='store_true')
rapid_parser.add_argument('--nlaunches', help='num_launches (int or "infinite"; default 0 is all jobs in DB)', default=0)
rapid_parser.add_argument('--sleep', help='sleep time between loops (secs)', default=None, type=int)
parser.add_argument('-l', '--launchpad_file', help='path to launchpad file', default=LAUNCHPAD_LOC)
parser.add_argument('-w', '--fworker_file', help='path to fworker file', default=FWORKER_LOC)
parser.add_argument('-c', '--config_dir', help='path to a directory containing the config file (used if -l, -w unspecified)',
default=CONFIG_FILE_DIR)
parser.add_argument('--loglvl', help='level to print log messages', default='INFO')
parser.add_argument('-s', '--silencer', help='shortcut to mute log messages', action='store_true')
args = parser.parse_args()
signal.signal(signal.SIGINT, handle_interrupt) # graceful exist on ^C
if not args.launchpad_file and os.path.exists(os.path.join(args.config_dir, 'my_launchpad.yaml')):
args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
if not args.fworker_file and os.path.exists(os.path.join(args.config_dir, 'my_fworker.yaml')):
args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
if args.command == 'singleshot' and args.offline:
launchpad = None
else:
launchpad = LaunchPad.from_file(args.launchpad_file) if args.launchpad_file else LaunchPad(strm_lvl=args.loglvl)
if args.fworker_file:
fworker = FWorker.from_file(args.fworker_file)
else:
fworker = FWorker()
# prime addr lookups
_log = get_fw_logger("rlaunch", stream_level="INFO")
_log.info("Hostname/IP lookup (this will take a few seconds)")
get_my_host()
get_my_ip()
if args.command == 'rapidfire':
rapidfire(launchpad, fworker, None, args.nlaunches, -1, args.sleep, args.loglvl)
else:
launch_rocket(launchpad, fworker, args.fw_id, args.loglvl)
示例4: auto_load
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def auto_load(cls):
sma = SubmissionMongoAdapter.auto_load()
l_dir = FWConfig().CONFIG_FILE_DIR
l_file = os.path.join(l_dir, 'my_launchpad.yaml')
lp = LaunchPad.from_file(l_file)
return SubmissionProcessor(sma, lp)
示例5: setUp
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def setUp(self):
if os.path.exists(self.scratch_dir):
shutil.rmtree(self.scratch_dir)
os.makedirs(self.scratch_dir)
os.chdir(self.scratch_dir)
try:
self.lp = LaunchPad.from_file(os.path.join(db_dir, "my_launchpad.yaml"))
self.lp.reset("", require_password=False)
except:
raise unittest.SkipTest(
'Cannot connect to MongoDB! Is the database server running? '
'Are the credentials correct?')
示例6: mlaunch
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def mlaunch():
m_description = 'This program launches multiple Rockets simultaneously'
parser = ArgumentParser(description=m_description)
parser.add_argument('num_jobs', help='the number of jobs to run in parallel', type=int)
parser.add_argument('--nlaunches', help='number of FireWorks to run in series per parallel job (int or "infinite"; default 0 is all jobs in DB)', default=0)
parser.add_argument('--sleep', help='sleep time between loops in infinite launch mode (secs)', default=None, type=int)
parser.add_argument('--timeout', help='timeout (secs) after which to quit (default None)', default=None, type=int)
parser.add_argument('-l', '--launchpad_file', help='path to launchpad file',
default=LAUNCHPAD_LOC)
parser.add_argument('-w', '--fworker_file', help='path to fworker file',
default=FWORKER_LOC)
parser.add_argument('-c', '--config_dir', help='path to a directory containing the config file (used if -l, -w unspecified)',
default=CONFIG_FILE_DIR)
parser.add_argument('--loglvl', help='level to print log messages', default='INFO')
parser.add_argument('-s', '--silencer', help='shortcut to mute log messages', action='store_true')
parser.add_argument('--nodefile', help='nodefile name or environment variable name containing the node file name (for populating FWData only)', default=None, type=str)
parser.add_argument('--ppn', help='processors per node (for populating FWData only)', default=1, type=int)
args = parser.parse_args()
if not args.launchpad_file and args.config_dir and os.path.exists(os.path.join(args.config_dir, 'my_launchpad.yaml')):
args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
if not args.fworker_file and args.config_dir and os.path.exists(os.path.join(args.config_dir, 'my_fworker.yaml')):
args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
launchpad = LaunchPad.from_file(args.launchpad_file) if args.launchpad_file else LaunchPad(strm_lvl=args.loglvl)
if args.fworker_file:
fworker = FWorker.from_file(args.fworker_file)
else:
fworker = FWorker()
total_node_list = None
if args.nodefile:
if args.nodefile in os.environ:
args.nodefile = os.environ[args.nodefile]
with open(args.nodefile, 'r') as f:
total_node_list = [line.strip() for line in f.readlines()]
launch_multiprocess(launchpad, fworker, args.loglvl, args.nlaunches, args.num_jobs,
args.sleep, total_node_list, args.ppn, timeout=args.timeout)
示例7: restart_fizzled
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def restart_fizzled():
module_dir = os.path.dirname(os.path.abspath(__file__))
lp_f = os.path.join(module_dir, 'my_launchpad.yaml')
lpdb = LaunchPad.from_file(lp_f)
for fw in lpdb.fireworks.find({"state": "FIZZLED"}, {"fw_id": 1, "spec.task_type": 1}):
fw_id = fw['fw_id']
task_type = fw['spec']['task_type']
restart_id = fw_id
if 'VASP db insertion' in task_type:
restart_id = fw_id - 1
elif 'Controller' in task_type:
restart_id = fw_id - 2
lpdb.rerun_fw(restart_id)
示例8: get_lp
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def get_lp(args):
try:
if not args.launchpad_file and os.path.exists(os.path.join(args.config_dir, DEFAULT_LPAD_YAML)):
args.launchpad_file = os.path.join(args.config_dir, DEFAULT_LPAD_YAML)
if args.launchpad_file:
return LaunchPad.from_file(args.launchpad_file)
else:
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
return LaunchPad(logdir=args.logdir, strm_lvl=args.loglvl)
except:
traceback.print_exc()
err_message = 'FireWorks was not able to connect to MongoDB. Is the server running? The database file specified was {}.'.format(args.launchpad_file)
if not args.launchpad_file:
err_message += ' Type "lpad init" if you would like to set up a file that specifies location and credentials of your Mongo database (otherwise use default localhost configuration).'
raise ValueError(err_message)
示例9: archive_deprecated_fws
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def archive_deprecated_fws():
# find all snlgroups that are deprecated, and archive all WFs that have deprecated fw_ids so we don't run them
module_dir = os.path.dirname(os.path.abspath(__file__))
snl_f = os.path.join(module_dir, 'snl.yaml')
snldb = SNLMongoAdapter.from_file(snl_f)
snlgroups = snldb.snlgroups
lp_f = os.path.join(module_dir, 'my_launchpad.yaml')
lpdb = LaunchPad.from_file(lp_f)
for g in snlgroups.find({'canonical_snl.about.remarks':'DEPRECATED'}, {'snlgroup_id': 1}):
while lpdb.fireworks.find_one({'spec.snlgroup_id': g['snlgroup_id'], 'state': {'$ne': 'ARCHIVED'}}, {'fw_id': 1}):
fw = lpdb.fireworks.find_one({'spec.snlgroup_id': g['snlgroup_id'], 'state': {'$ne': 'ARCHIVED'}}, {'fw_id': 1})
print fw['fw_id']
lpdb.archive_wf(fw['fw_id'])
print 'DONE'
示例10: get_colls
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def get_colls():
colls = namedtuple('Collections', ['snl', 'snlgroups'])
sma = SNLMongoAdapter.from_file(snl_f)
lp = LaunchPad.from_file(fw_f)
colls.snl = sma.snl
colls.snlgroups = sma.snlgroups
colls.fireworks = lp.fireworks
colls.launches = lp.launches
with open(tasks_f) as f2:
task_creds = yaml.load(f2)
mc = MongoClient(task_creds['host'], task_creds['port'])
db = mc[task_creds['database']]
db.authenticate(task_creds['admin_user'], task_creds['admin_password'])
colls.tasks = db['tasks']
return colls
示例11: launch_workflow
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def launch_workflow(
self,
launchpad_dir="",
k_product=50,
job=None,
user_incar_settings=None,
potcar_functional="PBE",
additional_handlers=[],
):
"""
Creates a list of Fireworks. Each Firework represents calculations
that will be done on a slab system of a compound in a specific
orientation. Each Firework contains a oriented unit cell relaxation job
and a WriteSlabVaspInputs which creates os. Firework(s) depending
on whether or not Termination=True. Vasp outputs from all slab and
oriented unit cell calculations will then be inserted into a database.
Args:
launchpad_dir (str path): The path to my_launchpad.yaml. Defaults to
the current working directory containing your runs
k_product: kpts[0][0]*a. Decide k density without
kpoint0, default to 50
cwd: (str path): The curent working directory. Location of where you
want your vasp outputs to be.
job (VaspJob): The command (cmd) entered into VaspJob object. Default
is specifically set for running vasp jobs on Carver at NERSC
(use aprun for Hopper or Edison).
user_incar_settings(dict): A dict specifying additional incar
settings, default to None (ediff_per_atom=False)
potcar_functional (str): default to PBE
"""
launchpad = LaunchPad.from_file(os.path.join(os.environ["HOME"], launchpad_dir, "my_launchpad.yaml"))
if self.reset:
launchpad.reset("", require_password=False)
# Scratch directory reffered to by custodian.
# May be different on non-Nersc systems.
if not job:
job = VaspJob(["mpirun", "-n", "64", "vasp"], auto_npar=False, copy_magmom=True)
handlers = [
VaspErrorHandler(),
NonConvergingErrorHandler(),
UnconvergedErrorHandler(),
PotimErrorHandler(),
PositiveEnergyErrorHandler(),
FrozenJobErrorHandler(timeout=3600),
]
if additional_handlers:
handlers.extend(additional_handlers)
cust_params = {
"custodian_params": {"scratch_dir": os.path.join("/global/scratch2/sd/", os.environ["USER"])},
"jobs": job.double_relaxation_run(job.vasp_cmd, auto_npar=False),
"handlers": handlers,
"max_errors": 100,
} # will return a list of jobs
# instead of just being one job
fws = []
for key in self.miller_dict.keys():
# Enumerate through all compounds in the dictionary,
# the key is the compositional formula of the compound
print key
for miller_index in self.miller_dict[key]:
# Enumerates through all miller indices we
# want to create slabs of that compound from
print str(miller_index)
max_norm = max(miller_index) if self.max_normal_search else None
# Whether or not we want to use the
# max_normal_search algorithm from surface.py
print "true or false max norm is ", max_norm, self.max_normal_search
slab = SlabGenerator(
self.unit_cells_dict[key][0], miller_index, self.ssize, self.vsize, max_normal_search=max_norm
)
oriented_uc = slab.oriented_unit_cell
if self.fail_safe and len(oriented_uc) > 199:
break
# This method only creates the oriented unit cell, the
# slabs are created in the WriteSlabVaspInputs task.
# WriteSlabVaspInputs will create the slabs from
# the contcar of the oriented unit cell calculation
handler = []
tasks = []
folderbulk = "/%s_%s_k%s_s%sv%s_%s%s%s" % (
oriented_uc.composition.reduced_formula,
"bulk",
k_product,
self.ssize,
self.vsize,
str(miller_index[0]),
str(miller_index[1]),
str(miller_index[2]),
#.........这里部分代码省略.........
示例12: mlaunch
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def mlaunch():
m_description = 'This program launches multiple Rockets simultaneously'
parser = ArgumentParser(description=m_description)
parser.add_argument('num_jobs', help='the number of jobs to run in parallel', type=int)
parser.add_argument('--nlaunches', help='number of FireWorks to run in series per parallel job '
'(int or "infinite"; default 0 is all jobs in DB)', default=0)
parser.add_argument('--sleep', help='sleep time between loops in infinite launch mode (secs)',
default=None, type=int)
parser.add_argument('--timeout', help='timeout (secs) after which to quit (default None)',
default=None, type=int)
parser.add_argument('-l', '--launchpad_file', help='path to launchpad file',
default=LAUNCHPAD_LOC)
parser.add_argument('-w', '--fworker_file', help='path to fworker file',
default=FWORKER_LOC)
parser.add_argument('-c', '--config_dir', help='path to a directory containing the config file '
'(used if -l, -w unspecified)',
default=CONFIG_FILE_DIR)
parser.add_argument('--loglvl', help='level to print log messages', default='INFO')
parser.add_argument('-s', '--silencer', help='shortcut to mute log messages', action='store_true')
parser.add_argument('--nodefile', help='nodefile name or environment variable name containing '
'the node file name (for populating FWData only)',
default=None, type=str)
parser.add_argument('--ppn', help='processors per node (for populating FWData only)',
default=1, type=int)
parser.add_argument('--exclude_current_node', help="Don't use the script launching node as compute node",
action="store_true")
try:
import argcomplete
argcomplete.autocomplete(parser)
# This supports bash autocompletion. To enable this, pip install
# argcomplete, activate global completion, or add
# eval "$(register-python-argcomplete mlaunch)"
# into your .bash_profile or .bashrc
except ImportError:
pass
args = parser.parse_args()
if not args.launchpad_file and args.config_dir and os.path.exists(os.path.join(args.config_dir,
'my_launchpad.yaml')):
args.launchpad_file = os.path.join(args.config_dir, 'my_launchpad.yaml')
if not args.fworker_file and args.config_dir and os.path.exists(os.path.join(args.config_dir,
'my_fworker.yaml')):
args.fworker_file = os.path.join(args.config_dir, 'my_fworker.yaml')
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
launchpad = LaunchPad.from_file(args.launchpad_file) if args.launchpad_file else LaunchPad(strm_lvl=args.loglvl)
if args.fworker_file:
fworker = FWorker.from_file(args.fworker_file)
else:
fworker = FWorker()
total_node_list = None
if args.nodefile:
if args.nodefile in os.environ:
args.nodefile = os.environ[args.nodefile]
with open(args.nodefile, 'r') as f:
total_node_list = [line.strip() for line in f.readlines()]
launch_multiprocess(launchpad, fworker, args.loglvl, args.nlaunches, args.num_jobs,
args.sleep, total_node_list, args.ppn, timeout=args.timeout,
exclude_current_node=args.exclude_current_node)
示例13: add_to_db
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
def add_to_db(self):
from fireworks.core.launchpad import LaunchPad
launchpad_file = os.path.join(os.environ['FW_CONFIG_DIR'], 'my_launchpad.yaml')
lp = LaunchPad.from_file(launchpad_file)
lp.add_wf(self.wf)
示例14: set
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
x = tdb.tasks.find_one({"fw_id": fw_id}, {"analysis": 1})
warnings = x['analysis'].get('warnings', [])
warnings.extend(x['analysis']['errors_MP']['signals'])
errors = x['analysis'].get('errors', [])
errors.extend(x['analysis']['errors_MP']['critical_signals'])
warnings = set(warnings)
errors = set(errors)
warnings = warnings.difference(errors)
return set(warnings), set(errors)
if __name__ == '__main__':
module_dir = os.path.dirname(os.path.abspath(__file__))
lp_f = os.path.join(module_dir, 'my_launchpad.yaml')
lpdb = LaunchPad.from_file(lp_f)
tasks_f = os.path.join(module_dir, 'tasks_read.yaml')
creds = {}
with open(tasks_f) as f:
creds = yaml.load(f)
connection = MongoClient(creds['host'], creds['port'])
tdb = connection[creds['db']]
tdb.authenticate(creds['username'], creds['password'])
except_dict = defaultdict(int)
fizzled_fws = []
示例15: LaunchPad
# 需要导入模块: from fireworks.core.launchpad import LaunchPad [as 别名]
# 或者: from fireworks.core.launchpad.LaunchPad import from_file [as 别名]
parser.add_argument('-w', '--fworker_file', help='path to fworker file', default=None)
parser.add_argument('--logdir', help='path to a directory for logging', default=None)
parser.add_argument('--loglvl', help='level to print log messages', default='INFO')
parser.add_argument('--silencer', help='shortcut to mute log messages', action='store_true')
args = parser.parse_args()
if not args.launchpad_file and os.path.exists('my_launchpad.yaml'):
args.launchpad_file = 'my_launchpad.yaml'
if not args.fworker_file and os.path.exists('my_fworker.yaml'):
args.fworker_file = 'my_fworker.yaml'
args.loglvl = 'CRITICAL' if args.silencer else args.loglvl
if args.launchpad_file:
launchpad = LaunchPad.from_file(args.launchpad_file)
else:
launchpad = LaunchPad(logdir=args.logdir, strm_lvl=args.loglvl)
if args.fworker_file:
fworker = FWorker.from_file(args.fworker_file)
else:
fworker = FWorker()
if args.command == 'rapidfire':
rapidfire(launchpad, fworker, None, args.logdir, args.loglvl, args.nlaunches, args.sleep)
else:
launch_rocket(launchpad, fworker, args.logdir, args.loglvl, args.fw_id)