本文整理匯總了Python中core.config.cfg.EXPECTED_RESULTS_EMAIL屬性的典型用法代碼示例。如果您正苦於以下問題:Python cfg.EXPECTED_RESULTS_EMAIL屬性的具體用法?Python cfg.EXPECTED_RESULTS_EMAIL怎麽用?Python cfg.EXPECTED_RESULTS_EMAIL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類core.config.cfg
的用法示例。
在下文中一共展示了cfg.EXPECTED_RESULTS_EMAIL屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_expected_results
# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import EXPECTED_RESULTS_EMAIL [as 別名]
def check_expected_results(results, atol=0.005, rtol=0.1):
"""Check actual results against expected results stored in
cfg.EXPECTED_RESULTS. Optionally email if the match exceeds the specified
tolerance.
Expected results should take the form of a list of expectations, each
specified by four elements: [dataset, task, metric, expected value]. For
example: [['coco_2014_minival', 'box_proposal', 'AR@1000', 0.387], ...].
"""
# cfg contains a reference set of results that we want to check against
if len(cfg.EXPECTED_RESULTS) == 0:
return
for dataset, task, metric, expected_val in cfg.EXPECTED_RESULTS:
assert dataset in results, 'Dataset {} not in results'.format(dataset)
assert task in results[dataset], 'Task {} not in results'.format(task)
assert metric in results[dataset][task], \
'Metric {} not in results'.format(metric)
actual_val = results[dataset][task][metric]
err = abs(actual_val - expected_val)
tol = atol + rtol * abs(expected_val)
msg = (
'{} > {} > {} sanity check (actual vs. expected): '
'{:.3f} vs. {:.3f}, err={:.3f}, tol={:.3f}'
).format(dataset, task, metric, actual_val, expected_val, err, tol)
if err > tol:
msg = 'FAIL: ' + msg
logger.error(msg)
if cfg.EXPECTED_RESULTS_EMAIL != '':
subject = 'Detectron end-to-end test failure'
job_name = os.environ[
'DETECTRON_JOB_NAME'
] if 'DETECTRON_JOB_NAME' in os.environ else '<unknown>'
job_id = os.environ[
'WORKFLOW_RUN_ID'
] if 'WORKFLOW_RUN_ID' in os.environ else '<unknown>'
body = [
'Name:',
job_name,
'Run ID:',
job_id,
'Failure:',
msg,
'Config:',
pprint.pformat(cfg),
'Env:',
pprint.pformat(dict(os.environ)),
]
send_email(
subject, '\n\n'.join(body), cfg.EXPECTED_RESULTS_EMAIL
)
else:
msg = 'PASS: ' + msg
logger.info(msg)