(self)
| 44 | return rval |
| 45 | |
| 46 | def refresh(self): |
| 47 | job_map = {} |
| 48 | |
| 49 | # -- carry over state for active engines |
| 50 | for eid in self._client.ids: |
| 51 | job_map[eid] = self.job_map.pop(eid, (None, None)) |
| 52 | |
| 53 | # -- deal with lost engines, abandoned promises |
| 54 | for eid, (p, tt) in list(self.job_map.items()): |
| 55 | if self.job_error_reaction == "raise": |
| 56 | raise LostEngineError(p) |
| 57 | elif self.job_error_reaction == "log": |
| 58 | tt["error"] = "LostEngineError (%s)" % str(p) |
| 59 | tt["state"] = JOB_STATE_ERROR |
| 60 | else: |
| 61 | raise ValueError(self.job_error_reaction) |
| 62 | |
| 63 | # -- remove completed jobs from job_map |
| 64 | for eid, (p, tt) in list(job_map.items()): |
| 65 | if p is None: |
| 66 | continue |
| 67 | if p.ready(): |
| 68 | try: |
| 69 | tt["result"] = p.get() |
| 70 | tt["state"] = JOB_STATE_DONE |
| 71 | job_map[eid] = (None, None) |
| 72 | except Exception as e: |
| 73 | if self.job_error_reaction == "raise": |
| 74 | raise |
| 75 | elif self.job_error_reaction == "log": |
| 76 | tt["error"] = str(e) |
| 77 | tt["state"] = JOB_STATE_ERROR |
| 78 | else: |
| 79 | raise ValueError(self.job_error_reaction) |
| 80 | if self.save_ipy_metadata: |
| 81 | tt["ipy_metadata"] = p.metadata |
| 82 | tt["refresh_time"] = coarse_utcnow() |
| 83 | del job_map[eid] |
| 84 | |
| 85 | self.job_map = job_map |
| 86 | Trials.refresh(self) |
| 87 | |
| 88 | def fmin(self, fn, space, **kw): |
| 89 | # TODO: all underscore variables are completely unused throughout. |
no test coverage detected