{% extends "base.html" %} {% autoescape None %} {% block title %}Task {{ task['task_index'] }}, Dataset {{ dataset['dataset'] }} - IceProd{% end %} {% block page_title %}Task Details{% end %} {% block body %}
{% for k in task %}
{{ escape(k) }}
{% if k == 'dataset_id' %} {{ escape(task[k]) }} {% elif k == 'job_id' %} {{ escape(task[k]) }} {% elif k == 'depends' %} {% for t in task[k] %} {{ escape(t) }}   {% end %} {% else %} {{ task[k] }} {% end %}
{% end %} {% if (current_user) %}
{% end %}
{% if task_stats %}

task stats

{{ '
'.join(escape(json_encode(task_stats, indent=2).replace('\r','')).replace(' ',' ').split('\n')) }}
{% end %}
{% if 'stdlog' in logs %}
stdlog {% for i,log in enumerate(logs['stdlog'][1:10]) %} {{ i+2 }} {% end %} {% if len(logs['stdlog']) > 10 %} (+ {{ len(logs['stdlog'])-10 }} more) {% end %} {% if not (('stdout' in logs and logs['stdout'][0]['data']) or ('stderr' in logs and logs['stderr'][0]['data'])) %}
{{ '
'.join(map(escape,logs['stdlog'][0]['data'].replace('\r','').split('\n')[-20:])) }}
{% end %}
{% end %} {% if 'stdout' in logs %}
stdout {% for i,log in enumerate(logs['stdout'][1:10]) %} {{ i+2 }} {% end %} {% if len(logs['stdout']) > 10 %} (+ {{ len(logs['stdout'])-10 }} more) {% end %}
{{ '
'.join(map(escape,logs['stdout'][0]['data'].replace('\r','').split('\n')[-20:])) }}
{% end %} {% if 'stderr' in logs %}
stderr {% for i,log in enumerate(logs['stderr'][1:10]) %} {{ i+2 }} {% end %} {% if len(logs['stderr']) > 10 %} (+ {{ len(logs['stderr'])-10 }} more) {% end %}
{{ '
'.join(map(escape,logs['stderr'][0]['data'].replace('\r','').split('\n')[-20:])) }}
{% end %} {% for name in logs %} {% if name not in ('stdlog', 'stdout', 'stderr') %}
{{ escape(name) }} {% for i,log in enumerate(logs[name][1:10]) %} {{ i+2 }} {% end %} {% if len(logs[name]) > 10 %} (+ {{ len(logs[name])-10 }} more) {% end %}
{{ '
'.join(map(escape,logs[name][0]['data'].replace('\r','').split('\n')[-10:])) }}
{% end %} {% end %}
{% end %} {% block body_scripts %} {% if (current_user) %} {% module SecureScript(content=f""" var rest_api = '{ rest_api }'; const passkey = "{ passkey }"; const dataset_id = "{ task['dataset_id'] if task else '' }"; const job_id = "{ task['job_id'] if task else '' }"; const task_id = "{ task['task_id'] if task else '' }"; """) %} {% module SecureScript(content=""" function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function service_worker(action) { try { const url = '/actions/task_status'; const args = { dataset_id: dataset_id, action: action, task_ids: [task_id], }; const ret = await fetch_json('POST', url, args, passkey); if ('error' in ret) { message_alert('error - '+ret['error']); return false; } const id = ret['result']; while (true) { await sleep(1000); const url = '/actions/task_status/'+id; const ret = await fetch_json('GET', url, null, passkey); if (ret['status'] == 'error') { if ('error_message' in ret) { message_alert('error - '+ret['error_message']); } else { message_alert('error - '+action+' failed'); } return false; } else if (ret['status'] == 'complete') { message('complete'); break; } else if ('payload' in ret && 'progress' in ret['payload']) { message('progress - '+ret['payload']['progress']+'%') } } } catch(err) { message_alert('error - '+err); return false; } reload(); return true; } async function task_reset() { return await service_worker('reset') } async function task_hard_reset() { return await service_worker('hard_reset') } async function task_suspend() { return await service_worker('suspend') } async function delete_task_logs() { try { const url = '/datasets/' + dataset_id + '/task/' + task_id + '/logs'; const ret = await fetch_json('DELETE', url, {}, passkey); if ('error' in ret) { message_alert('error - '+ret['error']); return false; } } catch(err) { message_alert('error - '+err); return false; } reload(); return true; } """) %} {% end %} {% end %}