Code Duplication    Length = 25-26 lines in 2 locations

sacred/run.py 2 locations

@@ 242-267 (lines=26) @@
239
240
    def _stop_heartbeat(self):
241
        if self._heartbeat is not None:
242
            self._heartbeat.cancel()
243
        self._heartbeat = None
244
        self._emit_heartbeat()  # one final beat to flush pending changes
245
246
    def _emit_queued(self):
247
        self.status = 'QUEUED'
248
        queue_time = datetime.datetime.utcnow()
249
        self.meta_info['queue_time'] = queue_time
250
        command = join_paths(self.main_function.prefix,
251
                             self.main_function.signature.name)
252
        self.run_logger.info("Queuing-up command '%s'", command)
253
        for observer in self.observers:
254
            if hasattr(observer, 'queued_event'):
255
                _id = observer.queued_event(
256
                    ex_info=self.experiment_info,
257
                    command=command,
258
                    queue_time=queue_time,
259
                    config=self.config,
260
                    meta_info=self.meta_info,
261
                    _id=self._id
262
                )
263
                if self._id is None:
264
                    self._id = _id
265
                # do not catch any exceptions on startup:
266
                # the experiment SHOULD fail if any of the observers fails
267
268
        if self._id is None:
269
            self.run_logger.info('Queued')
270
        else:
@@ 269-293 (lines=25) @@
266
                # the experiment SHOULD fail if any of the observers fails
267
268
        if self._id is None:
269
            self.run_logger.info('Queued')
270
        else:
271
            self.run_logger.info('Queued-up run with ID "{}"'.format(self._id))
272
273
    def _emit_started(self):
274
        self.status = 'RUNNING'
275
        self.start_time = datetime.datetime.utcnow()
276
        command = join_paths(self.main_function.prefix,
277
                             self.main_function.signature.name)
278
        self.run_logger.info("Running command '%s'", command)
279
        for observer in self.observers:
280
            if hasattr(observer, 'started_event'):
281
                _id = observer.started_event(
282
                    ex_info=self.experiment_info,
283
                    command=command,
284
                    host_info=self.host_info,
285
                    start_time=self.start_time,
286
                    config=self.config,
287
                    meta_info=self.meta_info,
288
                    _id=self._id
289
                )
290
                if self._id is None:
291
                    self._id = _id
292
                # do not catch any exceptions on startup:
293
                # the experiment SHOULD fail if any of the observers fails
294
        if self._id is None:
295
            self.run_logger.info('Started')
296
        else: