本文整理汇总了Python中openquake.job.Job.from_kvs方法的典型用法代码示例。如果您正苦于以下问题:Python Job.from_kvs方法的具体用法?Python Job.from_kvs怎么用?Python Job.from_kvs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openquake.job.Job
的用法示例。
在下文中一共展示了Job.from_kvs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_job_status
# 需要导入模块: from openquake.job import Job [as 别名]
# 或者: from openquake.job.Job import from_kvs [as 别名]
def check_job_status(job_id):
"""
Helper function which is intended to be run by celery task functions.
:raises JobCompletedError:
If :meth:`~openquake.job.Job.is_job_completed` returns ``True``
for ``job_id``.
"""
job = Job.from_kvs(job_id)
level = job.params.get('debug') if job and job.params else 'warn'
logs.init_logs_amqp_send(level=level, job_id=job_id)
if Job.is_job_completed(job_id):
raise JobCompletedError(job_id)
示例2: compute_uhs_task
# 需要导入模块: from openquake.job import Job [as 别名]
# 或者: from openquake.job.Job import from_kvs [as 别名]
def compute_uhs_task(job_id, realization, site, result_dir):
"""Compute Uniform Hazard Spectra for a given site of interest and 1 or
more Probability of Exceedance values. The bulk of the computation will
be done by utilizing the `UHSCalculator` class in the Java code.
UHS results (for each poe) will be written as a 1D array into temporary
HDF5 files. (The files will later be collected and 'reduced' into final
result files.)
:param int job_id:
ID of the job record in the DB/KVS.
:param realization:
Logic tree sample number (from 1 to N, where N is the
NUMBER_OF_LOGIC_TREE_SAMPLES param defined in the job config.
:param site:
The site of interest (a :class:`openquake.shapes.Site` object).
:param result_dir:
NFS result directory path. For each poe, a subfolder will be created to
contain intermediate calculation results. (Each call to this task will
generate 1 result file per poe.)
:returns:
A list of the resulting file names (1 per poe).
"""
utils_tasks.check_job_status(job_id)
the_job = Job.from_kvs(job_id)
log_msg = (
"Computing UHS for job_id=%s, site=%s, realization=%s."
" UHS results will be serialized to `%s`.")
log_msg %= (the_job.job_id, site, realization, result_dir)
LOG.info(log_msg)
uhs_results = compute_uhs(the_job, site)
return write_uhs_results(result_dir, realization, site, uhs_results)
示例3: test_can_store_and_read_jobs_from_kvs
# 需要导入模块: from openquake.job import Job [as 别名]
# 或者: from openquake.job.Job import from_kvs [as 别名]
def test_can_store_and_read_jobs_from_kvs(self):
self.job = Job.from_file(os.path.join(helpers.DATA_DIR, CONFIG_FILE))
self.generated_files.append(self.job.super_config_path)
self.assertEqual(self.job, Job.from_kvs(self.job.id))