# Path: planet/training/running.py
# class StopExperiment(Exception):
# class WorkerConflict(Exception):
# class SkipRun(Exception):
# class Experiment(object):
# class Run(object):
#   def __init__(
#       self, basedir, process_fn, start_fn=None, resume_fn=None,
#       num_runs=None, worker_name=None, ping_every=30, resume_runs=True):
#   def __iter__(self):
#   def _generate_run_numbers(self):
#   def __init__(
#       self, logdir, process_fn, start_fn, resume_fn, worker_name,
#       ping_every=30, ping_stale=60, reuse_if_exists=True):
#   def __iter__(self):
#   def _should_start(self):
#   def _should_resume(self):
#   def _claim(self):
#   def _store_done(self):
#   def _store_fail(self, message):
#   def _read_ping(self):
#   def _store_ping(self, overwrite=False):
#   def _store_ping_thread(self):
#   def _handle_exception(self, exception):
#   def _create_logger(self):


import os
import pickle
import threading
import time
import numpy as np
import tensorflow as tf
from planet.training import running
      processes[-1].start()
    for process in processes:
      process.join()
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/DONE'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/PING'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/FAIL'))
    self.assertEqual(0, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/started'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/resumed'))
    self.assertEqual(20, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/numbers'))
    self.assertEqual(100, len(filepaths))
    for filepath in filepaths:
      with tf.gfile.GFile(filepath, 'rb') as file_:
        self.assertEqual(10, len(pickle.load(file_)))


def _worker_normal(basedir, worker_name):
  experiment = running.Experiment(
      basedir, _process_fn, _start_fn, _resume_fn,
      num_runs=100, worker_name=worker_name, ping_every=1.0)
  for run in experiment:
    for score in run:
      pass


def _worker_dying(basedir, die_at_step, worker_name):

# Path: planet/training/running.py
# class StopExperiment(Exception):
# class WorkerConflict(Exception):
# class SkipRun(Exception):
# class Experiment(object):
# class Run(object):
#   def __init__(
#       self, basedir, process_fn, start_fn=None, resume_fn=None,
#       num_runs=None, worker_name=None, ping_every=30, resume_runs=True):
#   def __iter__(self):
#   def _generate_run_numbers(self):
#   def __init__(
#       self, logdir, process_fn, start_fn, resume_fn, worker_name,
#       ping_every=30, ping_stale=60, reuse_if_exists=True):
#   def __iter__(self):
#   def _should_start(self):
#   def _should_resume(self):
#   def _claim(self):
#   def _store_done(self):
#   def _store_fail(self, message):
#   def _read_ping(self):
#   def _store_ping(self, overwrite=False):
#   def _store_ping_thread(self):
#   def _handle_exception(self, exception):
#   def _create_logger(self):


# Path: planet/training/test_running.py
import os
import pickle
import threading
import time
import numpy as np
import tensorflow as tf
from planet.training import running

      processes[-1].start()
    for process in processes:
      process.join()
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/DONE'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/PING'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/FAIL'))
    self.assertEqual(0, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/started'))
    self.assertEqual(100, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/resumed'))
    self.assertEqual(20, len(filepaths))
    filepaths = tf.gfile.Glob(os.path.join(basedir, '*/numbers'))
    self.assertEqual(100, len(filepaths))
    for filepath in filepaths:
      with tf.gfile.GFile(filepath, 'rb') as file_:
        self.assertEqual(10, len(pickle.load(file_)))


def _worker_normal(basedir, worker_name):
  experiment = running.Experiment(
      basedir, _process_fn, _start_fn, _resume_fn,
      num_runs=100, worker_name=worker_name, ping_every=1.0)
  for run in experiment:
    for score in run:
      pass


def _worker_dying(basedir, die_at_step, worker_name):

  experiment = running.Experiment(