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


Python build.Build类代码示例

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


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

示例1: handle_request_for_new_build

    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,代码行数:25,代码来源:cluster_master.py

示例2: handle_request_for_new_build

    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
            self._request_queue.put(build)
            analytics.record_event(analytics.BUILD_REQUEST_QUEUED, build_id=build.build_id())
            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
开发者ID:drobertduke,项目名称:ClusterRunner,代码行数:27,代码来源:cluster_master.py

示例3: test_validate_update_params_for_cancelling_build

    def test_validate_update_params_for_cancelling_build(self):
        build = Build(BuildRequest({}))

        success, response = build.validate_update_params({'status': 'canceled'})

        self.assertTrue(success, "Correct status update should report success")
        self.assertEqual({}, response, "Error response should be empty")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:7,代码来源:test_build.py

示例4: test_allocate_slave_increments_by_per_slave_when_max_not_inf_and_less_than_num

 def test_allocate_slave_increments_by_per_slave_when_max_not_inf_and_less_than_num(self):
     build = Build(BuildRequest({}))
     build._max_executors_per_slave = 5
     slave = Mock()
     slave.num_executors = 10
     build.allocate_slave(slave)
     self.assertEqual(build._num_executors_allocated, 5, "Should be incremented by num executors")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:7,代码来源:test_build.py

示例5: setup

    def setup(self, build: Build, executor_start_index: int) -> bool:
        """
        Execute a setup command on the slave for the specified build. The setup process executes asynchronously on the
        slave and the slave will alert the master when setup is complete and it is ready to start working on subjobs.

        :param build: The build to set up this slave to work on
        :param executor_start_index: The index the slave should number its executors from for this build
        :return: Whether or not the call to start setup on the slave was successful
        """
        slave_project_type_params = build.build_request.build_parameters().copy()
        slave_project_type_params.update(build.project_type.slave_param_overrides())

        setup_url = self._slave_api.url('build', build.build_id(), 'setup')
        post_data = {
            'project_type_params': slave_project_type_params,
            'build_executor_start_index': executor_start_index,
        }

        self.current_build_id = build.build_id()
        try:
            self._network.post_with_digest(setup_url, post_data, Secret.get())
        except (requests.ConnectionError, requests.Timeout) as ex:
            self._logger.warning('Setup call to {} failed with {}: {}.', self, ex.__class__.__name__, str(ex))
            self.mark_dead()
            return False
        return True
开发者ID:box,项目名称:ClusterRunner,代码行数:26,代码来源:slave.py

示例6: test_validate_update_params_rejects_bad_params

    def test_validate_update_params_rejects_bad_params(self):
        build = Build(BuildRequest({}))

        success, response = build.validate_update_params({'status': 'foo'})

        self.assertFalse(success, "Bad status update reported success")
        self.assertEqual({'error': "Value (foo) is not in list of allowed values (['canceled']) for status"}, response,
                         "Error response not expected")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:8,代码来源:test_build.py

示例7: test_validate_update_params_rejects_bad_keys

    def test_validate_update_params_rejects_bad_keys(self):
        build = Build(BuildRequest({}))

        success, response = build.validate_update_params({'badkey': 'foo'})

        self.assertFalse(success, "Bad status update reported success")
        self.assertEqual({'error': "Key (badkey) is not in list of allowed keys (status)"}, response,
                         "Error response not expected")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:8,代码来源:test_build.py

示例8: test_update_state_to_canceled_sets_state_correctly

    def test_update_state_to_canceled_sets_state_correctly(self):
        build = Build(BuildRequest({}))
        build._unstarted_subjobs = Queue()

        success = build.update_state({'status': 'canceled'})

        self.assertEqual(build._status(), BuildStatus.CANCELED, "Status not set to canceled")
        self.assertTrue(success, "Update did not report success")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:8,代码来源:test_build.py

示例9: test_teardown_called_on_slave_when_no_subjobs_remain

 def test_teardown_called_on_slave_when_no_subjobs_remain(self):
     build = Build(BuildRequest({}))
     slave = Slave('', 1)
     slave.teardown = MagicMock()
     slave.free_executor = MagicMock(return_value=0)
     build._unstarted_subjobs = Queue()
     build.execute_next_subjob_on_slave(slave)
     slave.teardown.assert_called_with()
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:8,代码来源:test_build.py

示例10: test_build_cannot_be_prepared_more_than_once

    def test_build_cannot_be_prepared_more_than_once(self):
        build = Build(BuildRequest({}))
        subjobs = self._create_subjobs(count=3)
        mock_project_type = self._create_mock_project_type()

        build.prepare(subjobs, mock_project_type, self._create_job_config(max_executors=self._FAKE_MAX_EXECUTORS))

        with self.assertRaises(Exception):
            build.prepare(subjobs, mock_project_type, self._create_job_config(max_executors=self._FAKE_MAX_EXECUTORS))
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:9,代码来源:test_build.py

示例11: test_build_status_returns_queued_after_build_preparation

    def test_build_status_returns_queued_after_build_preparation(self):
        subjobs = self._create_subjobs()
        mock_project_type = self._create_mock_project_type()
        build = Build(BuildRequest({}))

        build.prepare(subjobs, mock_project_type, self._create_job_config(self._FAKE_MAX_EXECUTORS))
        status = build._status()

        self.assertEqual(status, BuildStatus.QUEUED)
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:9,代码来源:test_build.py

示例12: test_build_status_returns_queued_after_build_preparation

    def test_build_status_returns_queued_after_build_preparation(self):
        subjobs = self._create_subjobs()
        mock_project_type = self._create_mock_project_type()
        build = Build(BuildRequest({}))
        build._project_type = mock_project_type

        build.prepare(subjobs, self._create_job_config())
        status = build._status()

        self.assertEqual(status, BuildStatus.QUEUED,
                         'Build status should be QUEUED after build has been prepared.')
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:11,代码来源:test_build.py

示例13: test_execute_next_subjob_with_empty_queue_cant_teardown_same_slave_twice

    def test_execute_next_subjob_with_empty_queue_cant_teardown_same_slave_twice(self):
        build = Build(BuildRequest({}))
        build._unstarted_subjobs = Queue()
        slave = Mock()
        slave.free_executor = Mock(return_value=0)
        build._slaves_allocated.append(slave)

        build.execute_next_subjob_or_teardown_slave(slave)
        build.execute_next_subjob_or_teardown_slave(slave)

        self.assertEqual(slave.teardown.call_count, 1, "Teardown should only be called once")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:11,代码来源:test_build.py

示例14: test_cancel_depletes_queue_and_sets_canceled

    def test_cancel_depletes_queue_and_sets_canceled(self):
        build = Build(BuildRequest({}))
        build._unstarted_subjobs = Queue()
        build._unstarted_subjobs.put(1)
        slave_mock = Mock()
        build._slaves_allocated = [slave_mock]

        build.cancel()

        self.assertTrue(build._is_canceled, "Build should've been canceled")
        self.assertTrue(build._unstarted_subjobs.empty(), "Build's unstarted subjobs should've been depleted")
开发者ID:dncarley,项目名称:ClusterRunner,代码行数:11,代码来源:test_build.py

示例15: test_allocate_slave_doesnt_use_more_than_max_executors

    def test_allocate_slave_doesnt_use_more_than_max_executors(self):
        subjobs = self._create_subjobs()

        mock_project_type = self._create_mock_project_type()
        fake_setup_command = 'mock command'
        mock_slave = self._create_mock_slave()

        build = Build(BuildRequest({'setup': fake_setup_command}))
        build.prepare(subjobs, mock_project_type, self._create_job_config(1))
        build.allocate_slave(mock_slave)

        self.assertEqual(build._num_allocated_executors, build._max_executors)
开发者ID:mdengler,项目名称:ClusterRunner,代码行数:12,代码来源:test_build.py


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