MCPcopy
hub / github.com/hyperopt/hyperopt / serial_evaluate

Method serial_evaluate

hyperopt/fmin.py:168–197  ·  view source on GitHub ↗
(self, N=-1)

Source from the content-addressed store, hash-verified

166 trials.attachments["FMinIter_Domain"] = msg
167
168 def serial_evaluate(self, N=-1):
169 for trial in self.trials._dynamic_trials:
170 if trial["state"] == base.JOB_STATE_NEW:
171 trial["state"] = base.JOB_STATE_RUNNING
172 now = coarse_utcnow()
173 trial["book_time"] = now
174 trial["refresh_time"] = now
175 spec = base.spec_from_misc(trial["misc"])
176 ctrl = base.Ctrl(self.trials, current_trial=trial)
177 try:
178 result = self.domain.evaluate(spec, ctrl)
179 except Exception as e:
180 logger.error("job exception: %s" % str(e))
181 trial["state"] = base.JOB_STATE_ERROR
182 trial["misc"]["error"] = (str(type(e)), str(e))
183 trial["refresh_time"] = coarse_utcnow()
184 if not self.catch_eval_exceptions:
185 # -- JOB_STATE_ERROR means this trial
186 # will be removed from self.trials.trials
187 # by this refresh call.
188 self.trials.refresh()
189 raise
190 else:
191 trial["state"] = base.JOB_STATE_DONE
192 trial["result"] = result
193 trial["refresh_time"] = coarse_utcnow()
194 N -= 1
195 if N == 0:
196 break
197 self.trials.refresh()
198
199 @property
200 def is_cancelled(self):

Callers 2

block_until_doneMethod · 0.95
runMethod · 0.95

Calls 4

coarse_utcnowFunction · 0.85
evaluateMethod · 0.80
errorMethod · 0.80
refreshMethod · 0.45

Tested by

no test coverage detected