コード例 #1
0
    def create_job(
        self,
        label,
        name,
        num_instance,
        default_task_config,
        instance_config=None,
        **extra
    ):
        """
        :param label: the label value of the job
        :param name: the name of the job
        :param respool_id: the id of the resource pool
        :param num_instance: the number of instance of the job
        :param default_task_config: the default task config of the job
        :param instance_config: instance specific task config
        :param extra: extra information of the job

        :type label: str
        :type name: str
        :type respool_id: str
        :type num_instance: int
        :type default_task_config: task.TaskConfig
        :type instance_config: dict<int, task.TaskConfig>
        :type extra: dict

        :rtypr: job.CreateResponse
        """
        request = job.CreateRequest(
            config=self.get_job_config_spec(
                label,
                name,
                num_instance,
                default_task_config,
                instance_config=instance_config,
                **extra
            )
        )

        try:
            resp = self.client.job_svc.Create(
                request,
                metadata=self.client.jobmgr_metadata,
                timeout=default_timeout,
            )
            print_okblue("Create job response : %s" % resp)
            return resp
        except Exception as e:
            print_fail("Exception calling Create job :%s" % str(e))
            raise
コード例 #2
0
    def create_job(self, instance_num, use_instance_config, sleep_time):
        default_config = self.create_pod_config(sleep_time, 'static')
        instance_config = {}
        if use_instance_config:
            for i in range(0, instance_num):
                instance_config[i] = self.create_pod_config(
                    sleep_time, 'instance %s' % i)

        request = job.CreateRequest(
            config=job.JobConfig(
                name='instance %s && sleep %s && instance config %s' %
                (instance_num, sleep_time, use_instance_config),
                labels=[
                    peloton.Label(
                        key='task_num',
                        value=str(instance_num),
                    ),
                    peloton.Label(
                        key='sleep_time',
                        value=str(sleep_time),
                    ),
                    peloton.Label(
                        key='use_instance_config',
                        value=str(use_instance_config),
                    ),
                ],
                owningTeam='compute',
                description='test job',
                instanceCount=instance_num,
                defaultConfig=default_config,
                instanceConfig=instance_config,
                # sla is required by resmgr
                sla=job.SlaConfig(
                    priority=1,
                    preemptible=False,
                ),
                respoolID=peloton.ResourcePoolID(value=self.respool_id),
            ), )

        resp = self.client.job_svc.Create(
            request,
            metadata=self.client.jobmgr_metadata,
            timeout=default_timeout,
        )
        self.job_id = resp.jobId.value
        return resp.jobId.value
コード例 #3
0
    def create(self):
        """
        creates a job based on the config
        :return: the job ID
        """
        respool_id = self.pool.ensure_exists()

        self.job_config.respoolID.value = respool_id
        request = job.CreateRequest(config=self.job_config, )
        resp = self.client.job_svc.Create(
            request,
            metadata=self.client.jobmgr_metadata,
            timeout=self.config.rpc_timeout_sec,
        )
        assert not resp.HasField('error'), resp
        assert resp.jobId.value
        self.job_id = resp.jobId.value
        log.info('created job %s', self.job_id)
コード例 #4
0
ファイル: job.py プロジェクト: zhaohc10/peloton
    def create(self):
        """
        creates a job based on the config
        :return: the job ID
        """
        respool_id = self.pool.ensure_exists()
        self.job_config.respoolID.value = respool_id

        # wait for job manager leader
        self.wait_for_jobmgr_available()
        request = job.CreateRequest(config=self.job_config)
        resp = self.client.job_svc.Create(
            request,
            metadata=self.client.jobmgr_metadata,
            timeout=self.config.rpc_timeout_sec,
        )
        assert not resp.HasField("error"), resp
        assert resp.jobId.value
        self.job_id = resp.jobId.value
        log.info("created job %s", self.job_id)