示例#1
0
 def on_future_done(f: Future):
     self.models_running_now.pop(key)
     if f.status == 'finished':
         logger.info("Model run %s success", str(key))
         self.history.record_finished(key, f.result())
     elif f.status == 'cancelled':
         logger.info("Model run %s cancelled", str(key))
         self.history.record_cancelled(key)
     else:
         tb = f.traceback()
         error_details = traceback.format_tb(tb)
         logger.error("Model run %s failed: %s", str(key), error_details)
         self.history.record_error(key, error_details)
示例#2
0
 def create_array(self, name, shape, chunksize, dtype, timedim):
     chunks_in_each_dim = [
         shape[i] // chunksize[i] for i in range(len(shape))
     ]
     l = list(itertools.product(*[range(i) for i in chunks_in_each_dim]))
     items = []
     for m in l:
         f = Future(key=("deisa-" + name, m), inform=True, deisa=True)
         d = da.from_delayed(dask.delayed(f), shape=chunksize, dtype=dtype)
         items.append([list(m), d])
     ll = self.array_sort(items)
     arrays = da.block(ll)
     return arrays
示例#3
0
    def future(self):
        """
        Get Future instance associated with this job. The Future can be used to query status, get results, and manage the dask task.
        
        Returns:
            dask.distributed.Future: a future bound to the key associated with the Dask Job.
        """  # noqa: #E501
        if not getattr(self, '_future', None):
            if self.key and self.client:
                try:
                    future = Future(key=self.key, client=self.client)
                except Exception:
                    log.exception('Dask Future Init Error')
                    return None
            else:
                return None

            self._future = future

        return self._future
示例#4
0
 def get_future_status(self, task_key):
     return Future(key=task_key, client=self.client).status
示例#5
0
 def __hash__(self):
     return Future.__hash__(self)
示例#6
0
 def __init__(self, key, client=None, inform=True, state=None):
     Future.__init__(self, key, client, inform, state)