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


Python Build.generate_project_type方法代码示例

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


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

示例1: handle_request_for_new_build

# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import generate_project_type [as 别名]
    def handle_request_for_new_build(self, build_params):
        """
        Creates a new Build object and adds it to the request queue to be processed.

        :param build_params:
        :type build_params: dict[str, str]
        :rtype tuple [bool, dict [str, str]]
        """
        build_request = BuildRequest(build_params)
        success = False

        if build_request.is_valid():
            build = Build(build_request)
            self._all_builds_by_id[build.build_id()] = build
            build.generate_project_type()  # WIP(joey): This should be internal to the Build object.
            self._build_request_handler.handle_build_request(build)
            response = {'build_id': build.build_id()}
            success = True
        elif not build_request.is_valid_type():
            response = {'error': 'Invalid build request type.'}
        else:
            required_params = build_request.required_parameters()
            response = {'error': 'Missing required parameter. Required parameters: {}'.format(required_params)}

        return success, response  # todo: refactor to use exception instead of boolean
开发者ID:fengshao0907,项目名称:ClusterRunner,代码行数:27,代码来源:cluster_master.py

示例2: test_handle_result_reported_from_slave_when_build_is_canceled

# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import generate_project_type [as 别名]
    def test_handle_result_reported_from_slave_when_build_is_canceled(self):
        build_id = 1
        slave_url = "url"
        build = Build(BuildRequest({}))
        self.patch('app.master.build.util')
        build.generate_project_type()
        build.cancel()

        self.patch_object(build, '_handle_subjob_payload')
        self.patch_object(build, '_mark_subjob_complete')

        master = ClusterMaster()
        slave_registry = SlaveRegistry.singleton()
        BuildStore._all_builds_by_id[build_id] = build
        slave_registry._all_slaves_by_url[slave_url] = Mock()
        mock_scheduler = self.mock_scheduler_pool.get(build)

        master.handle_result_reported_from_slave(slave_url, build_id, 1)

        self.assertEqual(build._handle_subjob_payload.call_count, 1, "Canceled builds should "
                                                                     "handle payload")
        self.assertEqual(build._mark_subjob_complete.call_count, 1, "Canceled builds should mark "
                                                                    "their subjobs complete")
        self.assertTrue(mock_scheduler.execute_next_subjob_or_free_executor.called)
开发者ID:box,项目名称:ClusterRunner,代码行数:26,代码来源:test_cluster_master.py

示例3: _create_test_build

# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import generate_project_type [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))
开发者ID:fengshao0907,项目名称:ClusterRunner,代码行数:65,代码来源:test_build.py

示例4: test_generate_project_type_raises_error_if_failed_to_generate_project

# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import generate_project_type [as 别名]
    def test_generate_project_type_raises_error_if_failed_to_generate_project(self):
        build = Build(BuildRequest({}))
        self.patch('app.master.build.util.create_project_type').return_value = None

        with self.assertRaises(BuildProjectError):
            build.generate_project_type()
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:8,代码来源:test_build.py


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