MCPcopy
hub / github.com/hyperopt/hyperopt / MongoCtrl

Class MongoCtrl

hyperopt/mongoexp.py:1128–1179  ·  view source on GitHub ↗

Attributes: current_trial - current job document jobs - MongoJobs object in which current_trial resides read_only - True means don't change the db

Source from the content-addressed store, hash-verified

1126
1127
1128class MongoCtrl(Ctrl):
1129 """
1130 Attributes:
1131
1132 current_trial - current job document
1133 jobs - MongoJobs object in which current_trial resides
1134 read_only - True means don't change the db
1135
1136 """
1137
1138 def __init__(self, trials, current_trial, read_only):
1139 self.trials = trials
1140 self.current_trial = current_trial
1141 self.read_only = read_only
1142
1143 def debug(self, *args, **kwargs):
1144 # XXX: This is supposed to log to db
1145 return logger.debug(*args, **kwargs)
1146
1147 def info(self, *args, **kwargs):
1148 # XXX: This is supposed to log to db
1149 return logger.info(*args, **kwargs)
1150
1151 def warn(self, *args, **kwargs):
1152 # XXX: This is supposed to log to db
1153 return logger.warn(*args, **kwargs)
1154
1155 def error(self, *args, **kwargs):
1156 # XXX: This is supposed to log to db
1157 return logger.error(*args, **kwargs)
1158
1159 def checkpoint(self, result=None):
1160 if not self.read_only:
1161 handle = self.trials.handle
1162 handle.refresh(self.current_trial)
1163 if result is not None:
1164 return handle.update(self.current_trial, dict(result=result))
1165
1166 @property
1167 def attachments(self):
1168 """
1169 Support syntax for load: self.attachments[name]
1170 Support syntax for store: self.attachments[name] = value
1171 """
1172 return self.trials.trial_attachments(trial=self.current_trial)
1173
1174 @property
1175 def set_attachment(self):
1176 # XXX: Is there a better deprecation error?
1177 raise RuntimeError(
1178 "set_attachment deprecated. Use `self.attachments[name] = value`"
1179 )
1180
1181
1182def exec_import(cmd_module, cmd):

Callers 1

run_oneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected