import time
from django.db import transaction
+from django.utils.functional import SimpleLazyObject
from django.utils.timezone import now
from pyqcg import QCG
from pyqcg.description import JobDescription
from pyqcg.service import Registry
-from pyqcg.utils import Credential, TimePeriod
+from pyqcg.utils import Credential, TimePeriod, JobStatus, TaskStatus
logger = logging.getLogger(__name__)
# Jobs
###################################
jts = time.time()
- jobs = registry.jobs(**changed_filter)
+ jobs = registry.jobs(stats=[v for k, v in vars(JobStatus).iteritems() if not k.startswith('__')],
+ **changed_filter)
jte = time.time()
jobs_count = 0
# Tasks
###################################
tts = time.time()
- tasks = registry.tasks(**changed_filter)
+ tasks = registry.tasks(stats=[v for k, v in vars(TaskStatus).iteritems() if not k.startswith('__')],
+ **changed_filter)
tte = time.time()
- jobs_cache = {j.job_id: j for j in Job.objects.filter(owner=user)}
+ jobs_cache = SimpleLazyObject(lambda: {j.job_id: j for j in Job.objects.filter(owner=user)})
task_count = 0
for qcg_task in tasks:
params = Task.qcg_map(qcg_task, jobs_cache)
def submit_job(params, proxy):
- # print params
-
QCG.start()
desc = JobDescription(Credential(proxy))
direct_map = ('env_variables', 'executable', 'arguments', 'note', 'grant', 'hosts', 'properties', 'queue', 'procs',
- 'wall_time', 'memory', 'memory_per_slot', 'modules', 'native', 'notify', 'preprocess', 'postprocess',
- 'persistent')
+ 'wall_time', 'memory', 'memory_per_slot', 'modules', 'input', 'stage_in', 'native', 'notify',
+ 'preprocess', 'postprocess', 'persistent')
for name in direct_map:
if params[name]:
if params['watch_output']:
desc.set_watch_output(params['watch_output'], params['watch_output_pattern'])
# TODO script
- # TODO executable
- # TODO input
- # TODO stage_in
- # TODO stage_out
# TODO monitoring
# for prop in direct_map + ('application', 'nodes', 'env_variables', 'reservation', 'watch_output'):
# print desc.xml_description
- # job = desc.submit()
+ job = desc.submit()
- # return job.job_id
+ return job.job_id