username = username_from_dn(qcg_job.user_dn)
if user is not None:
if user.username != username:
- raise ValueError('Username does not match!')
+ raise ValueError('Username does not match ({} vs. {})!'.format(repr(user.username), repr(username)))
attrs['owner'] = user
else:
attrs['owner'] = User.objects.get(username=username)
return attrs
- @classmethod
- def from_qcg(cls, qcg_job):
- job = cls(**cls.qcg_map(qcg_job))
- job._job = qcg_job
-
- return job
+ @property
+ def terminated(self):
+ return self.get_status_display() in [JobStatus.FINISHED, JobStatus.FAILED, JobStatus.CANCELED]
class Task(models.Model):
@property
def qcg_task(self):
- if self._qcg_task is None:
- self._qcg_task = QcgTask(EPRUtils.deserialize_epr(self.epr))
+ if self._task is None:
+ self._task = QcgTask(EPRUtils.deserialize_epr(self.epr))
- return self._qcg_task
+ return self._task
@staticmethod
- def qcg_map(qcg_task, jobs=None):
+ def qcg_map(qcg_task, job=None):
attrs = get_attributes(qcg_task, ('task_id', 'status_description', 'note', 'description', 'submission_time',
'start_time', 'finish_time', 'reserved_time_slot', 'purged'))
attrs['type'] = Task.TYPE_CHOICES_REVERSED[qcg_task.type]
attrs['proxy_lifetime'] = now() + qcg_task.proxy_lifetime
- if jobs is not None and qcg_task.job_id in jobs:
- attrs['job'] = jobs[qcg_task.job_id]
+ if job is not None:
+ if qcg_task.job_id != job.job_id:
+ raise ValueError('Job id does not match ({} vs. {})!'.format(repr(qcg_task.job_id), repr(job.job_id)))
+ attrs['job'] = job
else:
attrs['job'] = Job.objects.get(job_id=qcg_task.job_id)
return attrs
- @classmethod
- def from_qcg(cls, qcg_task):
- task = cls(**cls.qcg_map(qcg_task))
- task._task = qcg_task
-
- return task
-
@property
def reserved_time_slot(self):
if self.reserved_time_start or self.reserved_time_finish:
def short_host_names(self):
return {alloc.host_name.split('.', 1)[0] for alloc in self.allocations.all()}
+ @property
+ def terminated(self):
+ return self.get_status_display() in [TaskStatus.FINISHED, TaskStatus.FAILED, TaskStatus.CANCELED]
+
class Allocation(models.Model):
STATUS_CHOICES = list(enumerate(field for field in dir(AllocationType) if not field.startswith('__')))
efficiency = models.IntegerField(u"Efektywność", blank=True, null=True) # ??
comment = models.TextField(u"Komentarz", blank=True, default='')
memory_usage = models.PositiveIntegerField(u"Użycie pamięci", blank=True, null=True)
+ working_directory = models.CharField(u"Katalog roboczy", max_length=1024, blank=True, default='')
class Meta:
verbose_name = u"Alokacja"
attrs = get_attributes(qcg_allocation, ('host_name', 'status_description', 'processes_count', 'slots_count',
'processes_group_id', 'submission_time', 'estimated_start_time',
'finish_time', 'local_submission_time', 'local_start_time',
- 'local_finish_time', 'purged', 'efficiency', 'comment', 'memory_usage'))
+ 'local_finish_time', 'purged', 'efficiency', 'comment', 'memory_usage',
+ 'working_directory'))
attrs['status'] = Allocation.STATUS_CHOICES_REVERSED[qcg_allocation.status]