Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@web_authenticated_users_only(redirect=False)
async def ui_cancel_batch(request, userdata):
batch_id = int(request.match_info['batch_id'])
user = userdata['username']
await _cancel_batch(request.app, batch_id, user)
session = await aiohttp_session.get_session(request)
set_message(session, f'Batch {batch_id} cancelled.', 'info')
location = request.app.router['batches'].url_for()
raise web.HTTPFound(location=location)
@web_authenticated_users_only()
async def ui_batch(request, userdata):
batch_id = int(request.match_info['batch_id'])
user = userdata['username']
page_context = {
'batch': await _get_batch(batch_id, user, include_jobs=True)
}
return await render_template('batch', request, userdata, 'batch.html', page_context)
@web_authenticated_users_only(redirect=False)
async def get_auth(request, userdata):
return await _get_auth(request, userdata)
@web_authenticated_users_only(redirect=False)
async def ui_cancel_batch(request, userdata):
batch_id = int(request.match_info['batch_id'])
user = userdata['username']
await _cancel_batch(batch_id, user)
session = await aiohttp_session.get_session(request)
set_message(session, 'Batch {batch_id} cancelled.', 'info')
location = request.app.router['batches'].url_for()
raise web.HTTPFound(location=location)
@web_authenticated_users_only(redirect=False)
async def post_notebook(request, userdata):
return await _post_notebook('notebook', request, userdata)
@web_authenticated_users_only(redirect=False)
async def wait_websocket(request, userdata): # pylint: disable=unused-argument
k8s = request.app['k8s_client']
session = await aiohttp_session.get_session(request)
notebook = session.get('notebook')
if not notebook:
return web.HTTPNotFound()
ws = web.WebSocketResponse()
await ws.prepare(request)
pod_name = notebook['pod_name']
if notebook['pod_ip']:
ready_url = deploy_config.external_url('notebook2', f'/instance-ready/{notebook["pod_uuid"]}')
attempts = 0
while attempts < 10:
@web_authenticated_users_only()
async def notebook_page(request, userdata):
k8s = request.app['k8s_client']
notebook = await get_live_notebook(k8s, userdata)
session = await aiohttp_session.get_session(request)
if notebook:
session['notebook'] = notebook
else:
if 'notebook' in session:
del session['notebook']
context = base_context(deploy_config, userdata, 'notebook2')
context['notebook'] = notebook
return context
@web_authenticated_users_only()
async def ui_batch(request, userdata):
app = request.app
batch_id = int(request.match_info['batch_id'])
user = userdata['username']
batch = await _get_batch(app, batch_id, user)
jobs, last_job_id = await _query_batch_jobs(request, batch_id)
for job in jobs:
job['exit_code'] = Job.exit_code(job)
job['duration'] = humanize_timedelta_msecs(Job.total_duration_msecs(job))
batch['jobs'] = jobs
page_context = {
'batch': batch,
'q': request.query.get('q'),