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


Python spawner.Spawner方法代码示例

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


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

示例1: submit_batch_script

# 需要导入模块: from jupyterhub import spawner [as 别名]
# 或者: from jupyterhub.spawner import Spawner [as 别名]
def submit_batch_script(self):
        subvars = self.get_req_subvars()
        # `cmd` is submitted to the batch system
        cmd = ' '.join((format_template(self.exec_prefix, **subvars),
                        format_template(self.batch_submit_cmd, **subvars)))
        # `subvars['cmd']` is what is run _inside_ the batch script,
        # put into the template.
        subvars['cmd'] = self.cmd_formatted_for_batch()
        if hasattr(self, 'user_options'):
            subvars.update(self.user_options)
        script = await self._get_batch_script(**subvars)
        self.log.info('Spawner submitting job using ' + cmd)
        self.log.info('Spawner submitted script:\n' + script)
        out = await self.run_command(cmd, input=script, env=self.get_env())
        try:
            self.log.info('Job submitted. cmd: ' + cmd + ' output: ' + out)
            self.job_id = self.parse_job_id(out)
        except:
            self.log.error('Job submission failed with exit code ' + out)
            self.job_id = ''
        return self.job_id

    # Override if your batch system needs something more elaborate to read the job status 
开发者ID:jupyterhub,项目名称:batchspawner,代码行数:25,代码来源:batchspawner.py

示例2: read_job_state

# 需要导入模块: from jupyterhub import spawner [as 别名]
# 或者: from jupyterhub.spawner import Spawner [as 别名]
def read_job_state(self):
        if self.job_id is None or len(self.job_id) == 0:
            # job not running
            self.job_status = ''
            return self.job_status
        subvars = self.get_req_subvars()
        subvars['job_id'] = self.job_id
        cmd = ' '.join((format_template(self.exec_prefix, **subvars),
                        format_template(self.batch_query_cmd, **subvars)))
        self.log.debug('Spawner querying job: ' + cmd)
        try:
            out = await self.run_command(cmd)
            self.job_status = out
        except Exception as e:
            self.log.error('Error querying job ' + self.job_id)
            self.job_status = ''
        finally:
            return self.job_status 
开发者ID:jupyterhub,项目名称:batchspawner,代码行数:20,代码来源:batchspawner.py

示例3: get_env

# 需要导入模块: from jupyterhub import spawner [as 别名]
# 或者: from jupyterhub.spawner import Spawner [as 别名]
def get_env(self):
        """Return the environment dict to use for the Spawner.

        See also: jupyterhub.Spawner.get_env
        """

        env = super(KubeSpawner, self).get_env()
        # deprecate image
        env['JUPYTER_IMAGE_SPEC'] = self.image
        env['JUPYTER_IMAGE'] = self.image

        return env 
开发者ID:jupyterhub,项目名称:kubespawner,代码行数:14,代码来源:spawner.py

示例4: state_gethost

# 需要导入模块: from jupyterhub import spawner [as 别名]
# 或者: from jupyterhub.spawner import Spawner [as 别名]
def state_gethost(self):
        assert self.state_exechost_re, "Misconfigured: define state_exechost_re"
        match = re.search(self.state_exechost_re, self.job_status)
        if not match:
            self.log.error("Spawner unable to match host addr in job status: " + self.job_status)
            return
        if not self.state_exechost_exp:
            return match.groups()[0]
        else:
            return match.expand(self.state_exechost_exp) 
开发者ID:jupyterhub,项目名称:batchspawner,代码行数:12,代码来源:batchspawner.py


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