Beispiel #1
0
 def load(self, jobStoreID):
     item = None
     for attempt in retry_sdb():
         with attempt:
             item = self.jobsDomain.get_attributes(jobStoreID, consistent_read=True)
     if not item:
         raise NoSuchJobException(jobStoreID)
     job = AWSJob.fromItem(item)
     if job is None:
         raise NoSuchJobException(jobStoreID)
     log.debug("Loaded job %s", jobStoreID)
     return job
Beispiel #2
0
 def _checkJobStoreId(self, jobStoreID):
     """
     Raises a NoSuchJobException if the jobStoreID does not exist.
     """
     if not self.exists(jobStoreID):
         raise NoSuchJobException("JobStoreID %s does not exist" %
                                  jobStoreID)
Beispiel #3
0
 def load(self, jobStoreID):
     # TODO: check if mentioning individual attributes is faster than using *
     for attempt in retry_sdb():
         with attempt:
             result = list(self.jobDomain.select(
                 query="select * from `{domain}` "
                       "where itemName() = '{jobStoreID}'".format(domain=self.jobDomain.name,
                                                                  jobStoreID=jobStoreID),
                 consistent_read=True))
     if len(result) != 1:
         raise NoSuchJobException(jobStoreID)
     job = AWSJob.fromItem(result[0])
     if job is None:
         raise NoSuchJobException(jobStoreID)
     log.debug("Loaded job %s", jobStoreID)
     return job
Beispiel #4
0
    def _checkJobStoreIdAssigned(self, jobStoreID):
        """
        Do nothing if the given job store ID has been assigned by
        :meth:`assignID`, and the corresponding job has not yet been
        deleted, even if the JobDescription hasn't yet been saved for the first
        time.
        
        If the ID has not been assigned, raises a NoSuchJobException.
        """

        if not self._waitForFile(self._getJobDirFromId(jobStoreID)):
            raise NoSuchJobException(jobStoreID)
Beispiel #5
0
 def _readContents(self, jobStoreID):
     """
     To be used on files representing jobs only. Which will be encrypted if possible.
     :param jobStoreID: the ID of the job
     :type jobStoreID: str
     :return: contents of the job file
     :rtype: string
     """
     job = self.bucket.get_blob(compat_bytes(jobStoreID), encryption_key=self.sseKey)
     if job is None:
         raise NoSuchJobException(jobStoreID)
     return job.download_as_string()
Beispiel #6
0
 def load(self, jobStoreID):
     try:
         jobString = self._readContents(jobStoreID)
     except NoSuchFileException:
         raise NoSuchJobException(jobStoreID)
     job = pickle.loads(jobString) 
     # It is our responsibility to make sure that the JobDescription is
     # connected to the current config on this machine, for filling in
     # defaults. The leader and worker should never see config-less
     # JobDescriptions.
     job.assignConfig(self.config)
     return job
Beispiel #7
0
 def load(self, jobStoreID):
     jobEntity = self.jobItems.get_entity(row_key=str(jobStoreID))
     if jobEntity is None:
         raise NoSuchJobException(jobStoreID)
     return AzureJob.fromEntity(jobEntity)
Beispiel #8
0
 def _checkJobStoreIdExists(self, jobStoreID):
     """
     Raises a NoSuchJobException if the job with ID jobStoreID does not exist.
     """
     if not self._waitForExists(jobStoreID, 30):
         raise NoSuchJobException(jobStoreID)
Beispiel #9
0
 def load(self, jobStoreID):
     try:
         jobString = self._readContents(jobStoreID)
     except NoSuchFileException:
         raise NoSuchJobException(jobStoreID)
     return cPickle.loads(jobString)
Beispiel #10
0
 def load(self, jobStoreID):
     try:
         jobString = self._readContents(jobStoreID)
     except NoSuchFileException:
         raise NoSuchJobException(jobStoreID)
     return pickle.loads(jobString)  # UPDATE bz2.decompress(
Beispiel #11
0
 def _check_job_store_id_exists(self, jobStoreID):
     """
     Raises a NoSuchJobException if the job with ID jobStoreID does not exist.
     """
     if not self._wait_for_exists(jobStoreID, 30):
         raise NoSuchJobException(jobStoreID)