本文整理汇总了Python中spark.job_server_api.get_spark_api函数的典型用法代码示例。如果您正苦于以下问题:Python get_spark_api函数的具体用法?Python get_spark_api怎么用?Python get_spark_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_spark_api函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_status
def check_status(self, notebook, snippet):
api = get_spark_api(self.user)
state = api.get_batch_status(snippet['result']['handle']['id'])
return {
'status': state,
}
开发者ID:Lt-Pone,项目名称:hue,代码行数:7,代码来源:models.py
示例2: create_session
def create_session(self, lang='scala', properties=None):
if not properties:
config = DefaultConfiguration.objects.get_configuration_for_user(app='spark', user=self.user)
if config is not None:
properties = config.properties_list
else:
properties = self.get_properties()
props = dict([(p['name'], p['value']) for p in properties]) if properties is not None else {}
props['kind'] = lang
api = get_spark_api(self.user)
response = api.create_session(**props)
status = api.get_session(response['id'])
count = 0
while status['state'] == 'starting' and count < 120:
status = api.get_session(response['id'])
count += 1
time.sleep(1)
if status['state'] != 'idle':
info = '\n'.join(status['log']) if status['log'] else 'timeout'
raise QueryError(_('The Spark session could not be created in the cluster: %s') % info)
return {
'type': lang,
'id': response['id'],
'properties': properties
}
开发者ID:ShahabT,项目名称:hue,代码行数:33,代码来源:spark_shell.py
示例3: create_session
def create_session(self, lang='scala', properties=None):
properties = dict([(p['name'], p['value']) for p in properties]) if properties is not None else {}
properties['kind'] = lang
api = get_spark_api(self.user)
response = api.create_session(**properties)
status = api.get_session(response['id'])
count = 0
while status['state'] == 'starting' and count < 120:
status = api.get_session(response['id'])
count += 1
time.sleep(1)
if status['state'] != 'idle':
info = '\n'.join(status['log']) if status['log'] else 'timeout'
raise QueryError(_('The Spark session could not be created in the cluster: %s') % info)
return {
'type': lang,
'id': response['id'],
'properties': []
}
开发者ID:RunnerDu,项目名称:hue,代码行数:26,代码来源:spark_shell.py
示例4: create_session
def create_session(self, lang="scala", properties=None):
if properties is None:
settings = {
"executor_cores": 1, # Some props only in YARN mode
"executor_count": 1,
"executor_memory": "1G",
"driver_cores": 1,
"driver_memory": "1G",
}
api = get_spark_api(self.user)
print "TODO: we should use the settings %s for creating the new sessions" % settings
response = api.create_session(kind=lang)
status = api.get_session(response["id"])
count = 0
while status["state"] == "starting" and count < 120:
status = api.get_session(response["id"])
count += 1
time.sleep(1)
if status["state"] != "idle":
raise QueryError("\n".join(status["log"]))
return {"type": lang, "id": response["id"], "properties": settings}
开发者ID:renxiawang,项目名称:hue,代码行数:26,代码来源:models.py
示例5: close_statement
def close_statement(self, snippet):
api = get_spark_api(self.user)
session_id = snippet["result"]["handle"]["id"]
if session_id is not None:
api.close_batch(session_id)
return {"session": session_id, "status": 0}
else:
return {"status": -1} # skipped
开发者ID:huberycao,项目名称:hue,代码行数:9,代码来源:models.py
示例6: download
def download(self, notebook, snippet, format):
try:
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
cell = snippet['result']['handle']['id']
return spark_download(api, session['id'], cell, format)
except Exception, e:
raise PopupException(e)
开发者ID:ShahabT,项目名称:hue,代码行数:9,代码来源:spark_shell.py
示例7: close
def close(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
if session["id"] is not None:
api.close(session["id"])
return {"session": session["id"], "status": 0}
else:
return {"status": -1}
开发者ID:renxiawang,项目名称:hue,代码行数:9,代码来源:models.py
示例8: close_session
def close_session(self, session):
api = get_spark_api(self.user)
if session["id"] is not None:
try:
api.close(session["id"])
return {"session": session["id"], "status": 0}
except RestException, e:
if e.code == 404 or e.code == 500: # TODO remove the 500
raise SessionExpired(e)
开发者ID:huberycao,项目名称:hue,代码行数:10,代码来源:models.py
示例9: close_session
def close_session(self, session):
api = get_spark_api(self.user)
if session['id'] is not None:
api.close(session['id'])
return {
'session': session['id'],
'status': 0
}
else:
return {'status': -1}
开发者ID:hwl-py,项目名称:hue,代码行数:11,代码来源:models.py
示例10: close
def close(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
if session['id'] is not None:
api.close(session['id'])
return {
'session': session['id'],
'status': 'closed'
}
else:
return {'status': 'skipped'}
开发者ID:abhishek-ch,项目名称:hue,代码行数:12,代码来源:models.py
示例11: create_session
def create_session(self, lang="scala"):
api = get_spark_api(self.user)
response = api.create_session(kind=lang)
status = api.get_session(response["id"])
count = 0
while status["state"] == "starting" and count < 120:
status = api.get_session(response["id"])
count += 1
time.sleep(1)
return {"type": lang, "id": response["id"]}
开发者ID:cyc821211,项目名称:hue,代码行数:13,代码来源:models.py
示例12: fetch_result
def fetch_result(self, notebook, snippet, rows, start_over):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
cell = snippet['result']['handle']['id']
try:
response = api.fetch_data(session['id'], cell)
except Exception, e:
message = force_unicode(str(e)).lower()
if 'session not found' in message:
raise SessionExpired(e)
else:
raise e
开发者ID:ShahabT,项目名称:hue,代码行数:13,代码来源:spark_shell.py
示例13: close_session
def close_session(self, session):
api = get_spark_api(self.user)
if session['id'] is not None:
try:
api.close(session['id'])
return {
'session': session['id'],
'status': 0
}
except RestException, e:
if e.code == 404 or e.code == 500: # TODO remove the 500
raise SessionExpired(e)
开发者ID:ShahabT,项目名称:hue,代码行数:13,代码来源:spark_shell.py
示例14: check_status
def check_status(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
cell = snippet["result"]["handle"]["id"]
try:
response = api.fetch_data(session["id"], cell)
return {"status": response["state"]}
except Exception, e:
message = force_unicode(str(e)).lower()
if "session not found" in message:
raise SessionExpired(e)
else:
raise e
开发者ID:cyc821211,项目名称:hue,代码行数:14,代码来源:models.py
示例15: execute
def execute(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
try:
response = api.submit_statement(session['id'], snippet['statement'])
return {
'id': response['id'],
'has_result_set': True,
}
except Exception, e:
message = force_unicode(str(e)).lower()
if 'session not found' in message or 'connection refused' in message or 'session is in state busy' in message:
raise SessionExpired(e)
else:
raise e
开发者ID:ShahabT,项目名称:hue,代码行数:16,代码来源:spark_shell.py
示例16: check_status
def check_status(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
cell = snippet['result']['handle']['id']
try:
response = api.fetch_data(session['id'], cell)
return {
'status': response['state'],
}
except Exception, e:
message = force_unicode(str(e)).lower()
if 'session not found' in message:
raise SessionExpired(e)
else:
raise e
开发者ID:ShahabT,项目名称:hue,代码行数:16,代码来源:spark_shell.py
示例17: create_session
def create_session(self, lang='scala'):
api = get_spark_api(self.user)
response = api.create_session(kind=lang)
status = api.get_session(response['id'])
count = 0
while status['state'] == 'starting' and count < 120:
status = api.get_session(response['id'])
count += 1
time.sleep(1)
return {
'type': lang,
'id': response['id']
}
开发者ID:Lt-Pone,项目名称:hue,代码行数:16,代码来源:models.py
示例18: execute
def execute(self, notebook, snippet):
api = get_spark_api(self.user)
session = _get_snippet_session(notebook, snippet)
try:
response = api.submit_statement(session["id"], snippet["statement"])
return {"id": response["id"], "has_result_set": True}
except Exception, e:
message = force_unicode(str(e)).lower()
if (
"session not found" in message
or "connection refused" in message
or "session is in state busy" in message
):
raise SessionExpired(e)
else:
raise e
开发者ID:cyc821211,项目名称:hue,代码行数:17,代码来源:models.py
示例19: create_session
def create_session(self, lang='scala'):
api = get_spark_api(self.user)
response = api.create_session(kind=lang)
status = api.get_session(response['id'])
count = 0
while status['state'] == 'starting' and count < 120:
status = api.get_session(response['id'])
count += 1
time.sleep(1)
if status['state'] != 'idle':
raise QueryError('\n'.join(status['log']))
return {
'type': lang,
'id': response['id']
}
开发者ID:abhishek-ch,项目名称:hue,代码行数:19,代码来源:models.py
示例20: create_session
def create_session(self, lang="scala", properties=None):
properties = dict([(p["name"], p["value"]) for p in properties]) if properties is not None else {}
properties["kind"] = lang
api = get_spark_api(self.user)
response = api.create_session(**properties)
status = api.get_session(response["id"])
count = 0
while status["state"] == "starting" and count < 120:
status = api.get_session(response["id"])
count += 1
time.sleep(1)
if status["state"] != "idle":
raise QueryError("\n".join(status["log"]))
return {"type": lang, "id": response["id"], "properties": []}
开发者ID:huberycao,项目名称:hue,代码行数:21,代码来源:models.py
注:本文中的spark.job_server_api.get_spark_api函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论