Esempio n. 1
0
def list_jobs(request, timestamp=None):
    state.update()
    if timestamp:
        since = datetime.fromisoformat(timestamp)
    else:
        since = datetime.now() - timedelta(days=7)
    return send_json({
     'timestamp': state.last_update.isoformat(),
     'jobs': [
      {
       'id': job['JobId'],
       'step': job.step,
       'language': job.language,
       'collection': job.collection,
       'slurm': job, # the dict data
       'stdout': app.url_for('show_stream', job=job, stream='stdout'),
       'stderr': app.url_for('show_stream', job=job, stream='stderr'),
       'link': app.url_for('show_job', job=job),
       'last_update': job_timestamp.isoformat()
      }
      for job, job_timestamp in state.jobs.with_timestamp()
      if job_timestamp > since \
      and hasattr(job, 'language') and hasattr(job, 'collection')
     ]
    })
Esempio n. 2
0
def show_job(request, job):
    return send_json({
        'id':
        job['JobId'],
        'slurm':
        job,
        'stdout':
        app.url_for('show_stream', job=job, stream='stdout'),
        'stderr':
        app.url_for('show_stream', job=job, stream='stderr')
    })
Esempio n. 3
0
def test_int_route(request, a):
	return send_json({'a': a, 'type': type(a).__name__})
Esempio n. 4
0
def test_route_1(request, a, b=None):
	return send_json({'a': a, 'b': b})
Esempio n. 5
0
def list_balance(request):
    # account_name = read_config_var('SBATCH_ACCOUNT')
    return send_json([{
        'account': account_name,
        'balance': slurm_balance(account_name)
    } for account_name in ['t2-cs119-cpu', 't2-cs119-gpu']])
Esempio n. 6
0
def list_quota(request):
    return send_json(list(disk_quota()))
Esempio n. 7
0
def list_collections(request):
    return send_json([{
        'name': name,
        'languages': collection.languages
    } for name, collection in read_collections().items()])