-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.py
43 lines (35 loc) · 1.37 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
GAVIP Example AVIS: Simple AVI
Django models used by the AVI pipeline
@req: REQ-0006
@comp: AVI Web System
"""
import datetime
from django.db import models
from pipeline.models import AviJob, AviJobRequest
class DemoModel(AviJob):
"""
This model is used to store the parameters for the AVI pipeline.
Notice that it contains identical field names here as is the variables in
the pipeline itself.
An AviJob model must contain all fields required by the intended
pipeline class (ProcessData) in this case.
"""
# We can override the default time_to_completion function here
# This is an integer value for the time, in seconds, the job
# is expected to take
def time_to_completion(self, avi_model_name, *args, **kwargs):
jobs = AviJobRequest.objects.filter(avi_model_name=avi_model_name).filter(pipeline_state__progress=100)
if jobs:
time_tot = datetime.timedelta(0)
for job in jobs:
time_tot = time_tot + job.pipeline_state.last_activity_time - job.created
mean_time = time_tot.total_seconds()/float(len(jobs))
else:
mean_time = 0
return mean_time
query = models.CharField(max_length=1000)
outputFile = models.CharField(default="", max_length=100)
pipeline_task = "ProcessData"
def get_absolute_url(self):
return "%i/" % self.pk