本文整理汇总了Python中spark.models.get_api函数的典型用法代码示例。如果您正苦于以下问题:Python get_api函数的具体用法?Python get_api怎么用?Python get_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_api函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close_notebook
def close_notebook(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
response['status'] = 0
for snippet in notebook['snippets']:
try:
if snippet['result']['handle']:
get_api(request.user, snippet).close(snippet)
except QueryExpired:
pass
response['message'] = _('Notebook closed !')
return JsonResponse(response)
示例2: close_session
def close_session(request):
response = {'status': -1}
session = json.loads(request.POST.get('session', '{}'))
response['session'] = get_api(request.user, {'type': session['type']}).close_session(session=session)
response['status'] = 0
return JsonResponse(response)
示例3: create_session
def create_session(request):
response = {'status': -1}
snippet = json.loads(request.POST.get('snippet', '{}'))
response['session'] = get_api(request.user, snippet).create_session(lang=snippet['type'])
response['status'] = 0
return JsonResponse(response)
示例4: check_status
def check_status(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
response['query_status'] = get_api(request.user, snippet).check_status(notebook, snippet)
response['status'] = 0
return JsonResponse(response)
示例5: execute
def execute(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
response['handle'] = get_api(request.user, snippet).execute(notebook, snippet)
response['status'] = 0
return JsonResponse(response)
示例6: cancel_statement
def cancel_statement(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
response['result'] = get_api(request.user, snippet).cancel(notebook, snippet)
response['status'] = 0
return JsonResponse(response)
示例7: fetch_result_metadata
def fetch_result_metadata(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
response['result'] = get_api(request.user, snippet).fetch_result_metadata(notebook, snippet)
response['status'] = 0
return JsonResponse(response)
示例8: close_notebook
def close_notebook(request):
response = {'status': -1, 'result': []}
notebook = json.loads(request.POST.get('notebook', '{}'))
for session in notebook['sessions']:
try:
response['result'].append(get_api(request.user, session).close_session(session))
except QueryExpired:
pass
except Exception, e:
LOG.exception('Error closing session %s' % e.message)
示例9: fetch_result_data
def fetch_result_data(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
rows = json.loads(request.POST.get('rows', 100))
start_over = json.loads(request.POST.get('startOver', False))
response['result'] = get_api(request.user, snippet).fetch_result(notebook, snippet, rows, start_over)
response['status'] = 0
return JsonResponse(response)
示例10: close_statement
def close_statement(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
try:
response['result'] = get_api(request.user, snippet).close(snippet)
except QueryExpired:
pass
response['status'] = 0
return JsonResponse(response)
示例11: close_statement
def close_statement(request):
response = {'status': -1}
# Passed by check_document_access_permission but unused by APIs
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
try:
response['result'] = get_api(request.user, snippet).close_statement(snippet)
except QueryExpired:
pass
response['status'] = 0
response['message'] = _('Statement closed !')
return JsonResponse(response)
示例12: get_logs
def get_logs(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
db = get_api(request.user, snippet)
response['logs'] = db.get_log(snippet)
response['progress'] = db._progress(snippet, response['logs']) if snippet['status'] != 'available' else 100
response['job_urls'] = [{
'name': job,
'url': reverse('jobbrowser.views.single_job', kwargs={'job': job})
} for job in db._get_jobs(response['logs'])]
response['status'] = 0
return JsonResponse(response)
示例13: create_session
def create_session(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
session = [session for session in notebook['sessions'] if snippet['type'] == session['type']]
if any(session) and 'properties' in session[0]:
properties = session[0]['properties']
else:
properties = None
response['session'] = get_api(request.user, snippet).create_session(lang=snippet['type'], properties=properties)
response['status'] = 0
return JsonResponse(response)
示例14: create_session
def create_session(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
session = json.loads(request.POST.get('session', '{}'))
properties = session.get('properties', [])
# If not properties look for previously used notebook session
if not properties:
old_session = [_session for _session in notebook['sessions'] if _session['type'] == session['type']]
if any(old_session) and 'properties' in old_session[0]:
properties = old_session[0]['properties']
response['session'] = get_api(request.user, session).create_session(lang=session['type'], properties=properties)
response['status'] = 0
return JsonResponse(response)
示例15: get_logs
def get_logs(request):
response = {'status': -1}
notebook = json.loads(request.POST.get('notebook', '{}'))
snippet = json.loads(request.POST.get('snippet', '{}'))
startFrom = request.POST.get('from')
startFrom = int(startFrom) if startFrom else None
size = request.POST.get('size')
size = int(size) if size else None
db = get_api(request.user, snippet)
response['logs'] = db.get_log(notebook, snippet, startFrom=startFrom, size=size)
response['progress'] = db._progress(snippet, response['logs']) if snippet['status'] != 'available' and snippet['status'] != 'success' else 100
response['job_urls'] = [{
'name': job,
'url': reverse('jobbrowser.views.single_job', kwargs={'job': job})
} for job in db._get_jobs(response['logs'])]
response['status'] = 0
return JsonResponse(response)