本文整理汇总了Python中app.master.build.Build.mark_failed方法的典型用法代码示例。如果您正苦于以下问题:Python Build.mark_failed方法的具体用法?Python Build.mark_failed怎么用?Python Build.mark_failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.master.build.Build
的用法示例。
在下文中一共展示了Build.mark_failed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_test_build
# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import mark_failed [as 别名]
def _create_test_build(
self,
build_status=None,
job_config=None,
num_subjobs=3,
num_atoms_per_subjob=3,
slaves=None,
):
"""
Create a Build instance for testing purposes. The instance will be created and brought to the specified
state similarly to how it would reach that state in actual app execution. Build instances have a huge
amount of internal state with complicated interactions, so this helper method helps us write tests that
are much more consistent and closer to reality. It also helps us avoid modifying a build's private members
directly.
:type build_status: BuildStatus
:rtype: Build
"""
build = Build(BuildRequest(build_parameters={}))
if build_status is None:
return build
# QUEUED: Instantiate a mock project_type instance for the build.
mock_project_type = self._create_mock_project_type()
self.patch('app.master.build.util.create_project_type').return_value = mock_project_type
build.generate_project_type()
if build_status is BuildStatus.QUEUED:
return build
# PREPARED: Create a fake job config and subjobs and hand them off to the build.
job_config = job_config or self._create_job_config()
mock_project_type.job_config.return_value = job_config
subjobs = self._create_subjobs(count=num_subjobs, num_atoms_each=num_atoms_per_subjob, job_config=job_config)
subjob_calculator = self._create_mock_subjob_calc(subjobs)
build.prepare(subjob_calculator)
if build_status is BuildStatus.PREPARED:
return build
# BUILDING: Allocate a slave and begin subjob executions on that slave.
slaves = slaves or [self._create_mock_slave()]
scheduler = self.scheduler_pool.get(build)
for slave in slaves:
scheduler.allocate_slave(slave=slave)
scheduler.begin_subjob_executions_on_slave(slave=slave)
if build_status is BuildStatus.BUILDING:
return build
# ERROR: Mark the in-progress build as failed.
if build_status is BuildStatus.ERROR:
build.mark_failed(failure_reason='Test build was intentionally marked failed.')
return build
# CANCELED: Cancel the in-progress build.
if build_status is BuildStatus.CANCELED:
build.cancel()
return build
# FINISHED: Complete all subjobs and allow all postbuild tasks to execute.
self._finish_test_build(build)
if build_status is BuildStatus.FINISHED:
return build
raise ValueError('Unsupported value for build_status: "{}".'.format(build_status))