本文整理汇总了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
示例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
示例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
示例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)