Remport that the pipeline will be done in X to Y days from now
authorDiane Trout <diane@caltech.edu>
Tue, 10 Nov 2009 02:06:26 +0000 (02:06 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 10 Nov 2009 02:06:26 +0000 (02:06 +0000)
instead of from when the pipeline was started.

htsworkflow/frontend/experiments/experiments.py
htsworkflow/frontend/experiments/views.py
htsworkflow/frontend/templates/experiments/started_email.html
htsworkflow/frontend/templates/experiments/started_email.txt

index 7e6c7343faec43204ef0640f99cb2d85d4ea2ef4..4d9dac15715e078e3a131fa36260e080d32edd20 100755 (executable)
@@ -256,10 +256,26 @@ def estimateFlowcellDuration(flowcell):
     sequencing_time = timedelta(0, cycles * sequencing_seconds_per_cycle)
     analysis_time = timedelta(0, cycles * pipeline_seconds_per_cycle)
     estimate_mid = sequencing_time + analysis_time
+
+    return estimate_mid
+
+def estimateFlowcellTimeRemaining(flowcell):
+    estimate_mid = estimateFlowcellDuration(flowcell)
+    
+    # offset for how long we've been running
+    running_time = datetime.now() - flowcell.run_date
+    estimate_mid -= running_time
+
+    return estimate_mid
+
+def roundToDays(estimate):
+    """
+    Given a time estimate round up and down in days
+    """
     # floor estimate_mid
-    estimate_low = timedelta(estimate_mid.days, 0)
+    estimate_low = timedelta(estimate.days, 0)
     # floor estimate_mid and add a day
-    estimate_high = timedelta(estimate_mid.days+1, 0)
+    estimate_high = timedelta(estimate.days+1, 0)
     
     return (estimate_low, estimate_high)
     
index e03c038e48f7f2e197a20ef73494670bcf717076..e2f6d884a4d63491922f88434f9e8c40cbb1972d 100755 (executable)
@@ -1,4 +1,6 @@
 # Create your views here.
+from datetime import datetime
+
 #from django.template import Context, loader
 #shortcut to the above modules
 from django.contrib.auth.decorators import user_passes_test
@@ -12,6 +14,8 @@ from django.template.loader import get_template
 from htsworkflow.frontend.experiments.models import *
 from htsworkflow.frontend.experiments.experiments import \
      estimateFlowcellDuration, \
+     estimateFlowcellTimeRemaining, \
+     roundToDays, \
      getUsersForFlowcell, \
      makeEmailLaneMap
 
@@ -64,7 +68,8 @@ def startedEmail(request, pk):
 
     email_lane = makeEmailLaneMap(fc)
     flowcell_users = getUsersForFlowcell(fc)
-    estimate_low, estimate_high = estimateFlowcellDuration(fc)
+    estimate = estimateFlowcellTimeRemaining(fc)
+    estimate_low, estimate_high = roundToDays(estimate)
     email_verify = get_template('experiments/email_preview.html')
     email_template = get_template('experiments/started_email.txt')
     sender = settings.NOTIFICATION_SENDER
@@ -87,6 +92,7 @@ def startedEmail(request, pk):
                    u'runfolder': 'blank',
                    u'finish_low': estimate_low,
                    u'finish_high': estimate_high,
+                   u'now': datetime.now(),        
                   })
 
         # build view
index d75e4f1cc9f0ca89368a5a9fdeac75790f8450b5..dcb2df0c36aae883257559ec273bb57e1a7ebf7f 100644 (file)
@@ -10,8 +10,8 @@ Lane #{{ lane.lane_number }} :
 {% endfor %}</p>
 <p>
 The data should be available at the following link when
-the pipeline finishes, probably in about
-{{ finish_low.days }} to {{ finish_high.days }} days after the flowcell is started.
+the pipeline finishes, probably in about {{ finish_low.days }} to {{ finish_high.days }} 
+days from {{ now|date:"D, M d Y" }}
 </p>
 <p>
 <a href="https://jumpgate.caltech.edu/runfolders/cellcenter/">
index 9b11a748825c4f0d4f45c0045ab4501c7c96ff36..b2212e0597d678c47c7ca182cce443ea92c07761 100644 (file)
@@ -7,9 +7,9 @@ Lane #{{ lane.lane_number }} : ({{ lane.library.id }}) {{ lane.library.library_n
      http://jumpgate.caltech.edu/library/{{ lane.library.id }}
 {% endfor %}
 
-The raw data should be available at the following link when
-the pipeline finishes, probably in about
-{{ finish_low.days }} to {{ finish_high.days }} days after the flowcell is started.
+The raw data should be available at the following link when the
+pipeline finishes, probably in about {{ finish_low.days }} to {{ finish_high.days }} 
+days from {{ now|date:"D, M d Y" }}
 
 http://jumpgate.caltech.edu/runfolders/cellcenter/