Retrieve flowcell date, reusing older dates if refreshing a present workflow.
493408
def get_fc_date(out_config_file):
    
    if os.path.exists(out_config_file):
        with open(out_config_file) as in_handle:
            old_config = yaml.safe_load(in_handle)
            fc_date = old_config["fc_date"]
    else:
        fc_date = datetime.datetime.now().strftime("%y%m%d")
    return fc_date
1368396
def fetch(workitem_or_fei)

      hfei = Ruote::FlowExpressionId.extract_h(workitem_or_fei)

      @context.storage.get('workitems', to_id(hfei))
    end
1282556
def clean(self):
        
        active = utils.get_active_entry(self.user)
        start_time = self.cleaned_data.get('start_time', None)
        end_time = self.cleaned_data.get('end_time', None)

        if active and active.pk != self.instance.pk:
            if (start_time and start_time > active.start_time) or \
                    (end_time and end_time > active.start_time):
                raise forms.ValidationError(
                    'The start time or end time conflict with the active '
                    'entry: {activity} on {project} starting at '
                    '{start_time}.'.format(
                        project=active.project,
                        activity=active.activity,
                        start_time=active.start_time.strftime('%H:%M:%S'),
                    ))

        month_start = utils.get_month_start(start_time)
        next_month = month_start + relativedelta(months=1)
        entries = self.instance.user.timepiece_entries.filter(
            Q(status=Entry.APPROVED) | Q(status=Entry.INVOICED),
            start_time__gte=month_start,
            end_time__lt=next_month
        )
        entry = self.instance

        if not self.acting_user.is_superuser:
            if (entries.exists() and not entry.id or entry.id and entry.status == Entry.INVOICED):
                message = 'You cannot add/edit entries after a timesheet has been ' \
                    'approved or invoiced. Please correct the start and end times.'
                raise forms.ValidationError(message)

        return self.cleaned_data
886006
def getDateReceived(self):
        
        request = self.getRequest()
        if request:
            ar_date = request.getDateReceived()
            if ar_date and self.created() > ar_date:
                return self.created()
            return ar_date
        return None
207740
def requested_intervals(self):
        
        with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
            workflow_statuses = WorkflowStatusModel.objects(workflow_id=self.workflow_id)
            if len(workflow_statuses) == 1:
                return TimeIntervals(map(lambda x: TimeInterval(x.start, x.end),
                                         workflow_statuses[0].requested_intervals))
            else:
                return TimeIntervals([])
400515
def gdate(self):
        """"""
        if self._last_updated == "gdate":
            return self._gdate
        return conv.jdn_to_gdate(self._jdn)
1099798
def _FlowObjectFromRow(self, row):
    """"""

    flow, fs, cci, pt, nr, pd, po, ps, uct, sct, nbs, nrs, ts, lut = row

    flow_obj = rdf_flow_objects.Flow.FromSerializedString(flow)
    if fs not in [None, rdf_flow_objects.Flow.FlowState.UNSET]:
      flow_obj.flow_state = fs
    if cci is not None:
      cc_cls = rdf_client.ClientCrash
      flow_obj.client_crash_info = cc_cls.FromSerializedString(cci)
    if pt is not None:
      pt_cls = rdf_flow_objects.PendingFlowTermination
      flow_obj.pending_termination = pt_cls.FromSerializedString(pt)
    if nr:
      flow_obj.next_request_to_process = nr
    if pd is not None:
      flow_obj.processing_deadline = mysql_utils.TimestampToRDFDatetime(pd)
    if po is not None:
      flow_obj.processing_on = po
    if ps is not None:
      flow_obj.processing_since = mysql_utils.TimestampToRDFDatetime(ps)
    flow_obj.cpu_time_used.user_cpu_time = db_utils.MicrosToSeconds(uct)
    flow_obj.cpu_time_used.system_cpu_time = db_utils.MicrosToSeconds(sct)
    flow_obj.network_bytes_sent = nbs
    if nrs:
      flow_obj.num_replies_sent = nrs
    flow_obj.timestamp = mysql_utils.TimestampToRDFDatetime(ts)
    flow_obj.last_update_time = mysql_utils.TimestampToRDFDatetime(lut)

    return flow_obj
758828
static function getWorkflowState($workflow_key) {
        $status = self::STATUS_COMPLETED;
        $created_after = "-20 years";
        $data = DataStore::retrieveMostCurrentWorkflowJobByAgeAndStatus($workflow_key, $status, $created_after);
        if ($data) {
            return $data["end_state"];
        } else {
            $workflow = DataStore::retrieveWorkflow($workflow_key);
            if (!$workflow) {
                throw new \Exception("Error retrieving workflow for key $workflow_key can't determine state.");
            }
            $data = $workflow->getData();
            return $data[self::CONF_INITIAL_STATE];
        }
    }
1251392
private Object getCellValue(Cell cell) {
    Object value;

    // Empty cells are null, instead of BLANK
    if (cell == null) {
      return null;
    }

    switch (cell.getCellTypeEnum()) {
      case STRING:
        value = cell.getStringCellValue();
        break;
      case NUMERIC:
        if (isCellDateFormatted(cell)) {
          try {
            // Excel dates are LocalDateTime, stored without timezone.
            // Interpret them as UTC to prevent ambiguous DST overlaps which happen in other
            // timezones.
            setUserTimeZone(LocaleUtil.TIMEZONE_UTC);
            Date dateCellValue = cell.getDateCellValue();
            value = formatUTCDateAsLocalDateTime(dateCellValue);
          } finally {
            resetUserTimeZone();
          }
        } else {
          value = cell.getNumericCellValue();
        }
        break;
      case BOOLEAN:
        value = cell.getBooleanCellValue();
        break;
      case FORMULA:
        value = getTypedFormulaValue(cell);
        break;
      default:
        value = null;
        break;
    }
    return value;
  }
801892
async function isStaleDailyData (endpointInstance) {
  const account = await new AccountEndpoint(endpointInstance).schema('2019-03-26').get()
  return new Date(account.last_modified) < resetTime.getLastDailyReset()
}
938694
def get_current_ontology_date():
    """"""
    with closing(requests.get(
            'http://geneontology.org/ontology/go-basic.obo',
            stream=True)) as r:
        for i, l in enumerate(r.iter_lines(decode_unicode=True)):
            if i == 1:
                assert l.split(':')[0] == 'data-version'
                date = l.split('/')[-1]
                break

    return date
183255
function ensureTimestamps(columns, allowSyncedAt) {
  var now = Date.now();
  if (!allowSyncedAt || !columns.syncedAt) {
    columns.syncedAt = now;
  }
  if (!columns.createdAt) {
    // Take the value from the client, if present:
    columns.createdAt = columns.updatedAt;
  }
}
165194
def ReleaseProcessedFlow(self, flow_obj, cursor=None):
    """"""

    update_query = """
    UPDATE flows
    LEFT OUTER JOIN (
      SELECT client_id, flow_id, needs_processing
      FROM flow_requests
      WHERE
        client_id = %(client_id)s AND
        flow_id = %(flow_id)s AND
        request_id = %(next_request_to_process)s AND
        needs_processing
    ) AS needs_processing
    ON
      flows.client_id = needs_processing.client_id AND
      flows.flow_id = needs_processing.flow_id
    SET
      flows.flow = %(flow)s,
      flows.processing_on = NULL,
      flows.processing_since = NULL,
      flows.processing_deadline = NULL,
      flows.next_request_to_process = %(next_request_to_process)s,
      flows.flow_state = %(flow_state)s,
      flows.user_cpu_time_used_micros = %(user_cpu_time_used_micros)s,
      flows.system_cpu_time_used_micros = %(system_cpu_time_used_micros)s,
      flows.network_bytes_sent = %(network_bytes_sent)s,
      flows.num_replies_sent = %(num_replies_sent)s,
      flows.last_update = NOW(6)
    WHERE
      flows.client_id = %(client_id)s AND
      flows.flow_id = %(flow_id)s AND (
        needs_processing.needs_processing = FALSE OR
        needs_processing.needs_processing IS NULL)
    """

    clone = flow_obj.Copy()
    clone.processing_on = None
    clone.processing_since = None
    clone.processing_deadline = None
    args = {
        "client_id":
            db_utils.ClientIDToInt(flow_obj.client_id),
        "flow":
            clone.SerializeToString(),
        "flow_id":
            db_utils.FlowIDToInt(flow_obj.flow_id),
        "flow_state":
            int(clone.flow_state),
        "network_bytes_sent":
            flow_obj.network_bytes_sent,
        "next_request_to_process":
            flow_obj.next_request_to_process,
        "num_replies_sent":
            flow_obj.num_replies_sent,
        "system_cpu_time_used_micros":
            db_utils.SecondsToMicros(flow_obj.cpu_time_used.system_cpu_time),
        "user_cpu_time_used_micros":
            db_utils.SecondsToMicros(flow_obj.cpu_time_used.user_cpu_time),
    }
    rows_updated = cursor.execute(update_query, args)
    return rows_updated == 1
813248
public Date getObjectLockRetainUntilDate() {
        String dateStr = (String) metadata.get(Headers.OBJECT_LOCK_RETAIN_UNTIL_DATE);
        if (dateStr != null) {
            return DateUtils.parseISO8601Date(dateStr);
        }
        return null;
    }
367470
function updateDays(state, forceCreation) {
  const { dayCount, dayRole, locale, showCompleteWeeks, startDate } = state;
  const workingStartDate = showCompleteWeeks ?
    calendar.firstDateOfWeek(startDate, locale) :
    calendar.midnightOnDate(startDate);
  let workingDayCount;
  if (showCompleteWeeks) {
    const endDate = calendar.offsetDateByDays(startDate, dayCount - 1);
    const workingEndDate = calendar.lastDateOfWeek(endDate, locale);
    workingDayCount = calendar.daysBetweenDates(workingStartDate, workingEndDate) + 1;
  } else {
    workingDayCount = dayCount;
  }

  let days = state.days ? state.days.slice() : [];

  let date = workingStartDate;
  for (let i = 0; i < workingDayCount; i++) {
    const createNewElement = forceCreation || i >= days.length;
    const day = createNewElement ?
      template.createElement(dayRole) :
      days[i];
    day.date = new Date(date.getTime());
    day.locale = locale;
    day.style.gridColumnStart = '';
    if (createNewElement) {
      days[i] = day;
    }
    date = calendar.offsetDateByDays(date, 1);
  }

  if (workingDayCount < days.length) {
    // Trim days which are no longer needed.
    days = days.slice(0, workingDayCount);
  }

  const firstDay = days[0];
  if (firstDay && !showCompleteWeeks) {
    // Set the grid-column on the first day. This will cause all the subsequent
    // days to line up in the calendar grid.
    const dayOfWeek = calendar.daysSinceFirstDayOfWeek(firstDay.date, state.locale);
    firstDay.style.gridColumnStart = dayOfWeek + 1;
  }

  Object.freeze(days);
  return days;
}
251516
def serialize_workflow(self):
        
        self.workflow.refresh_waiting_tasks()
        return CompactWorkflowSerializer().serialize_workflow(self.workflow,
                                                              include_spec=False)
375964
def get_timestamps(cols, created_name, updated_name):
  """"""
  has_created = created_name in cols
  has_updated = updated_name in cols
  return (created_name if has_created else None, updated_name if has_updated else None)