예제 #1
0
def _init_trial_run(batch_run, trial_flag_vals, run_dir=None):
    run = op_util.init_run(run_dir)
    _link_to_trial(batch_run, run)
    proto_run = batch_run.batch_proto
    util.copytree(proto_run.dir, run.dir)
    run.write_attr("flags", trial_flag_vals)
    run.write_attr("label", _trial_label(proto_run, trial_flag_vals))
    run.write_attr("op", _trial_op_attr(proto_run, trial_flag_vals))
    op_util.set_run_staged(run)
    return run
예제 #2
0
def _copy_source(source_path, dest_path):
    assert os.path.isabs(dest_path), dest_path
    if os.path.lexists(dest_path) or os.path.exists(dest_path):
        log.warning("%s already exists, skipping copy", dest_path)
        return
    util.ensure_dir(os.path.dirname(dest_path))
    log.debug("resolving source %s as copy %s", source_path, dest_path)
    if os.path.isdir(source_path):
        util.copytree(source_path, dest_path)
    else:
        util.copyfile(source_path, dest_path)
예제 #3
0
 def _init_trial_run(self, run_dir=None):
     assert isinstance(self.flags, dict), self.flags
     run_dir = run_dir or os.path.join(var.runs_dir(), self.run_id)
     run = runlib.Run(self.run_id, run_dir)
     if run.get("batch") != self.batch.batch_run.id:
         util.copytree(self.batch.proto_run.path, run_dir)
         for name, val in self.attrs.items():
             run.write_attr(name, val)
         run.write_attr("initialized", runlib.timestamp())
         run.write_attr("flags", self.flags)
         run.write_attr("batch", self.batch.batch_run.id)
     return run
예제 #4
0
def init_trial_run(batch_run, trial_flag_vals, run_dir=None):
    run = op_util.init_run(run_dir)
    _link_to_trial(batch_run, run)
    proto_run = batch_run.batch_proto
    assert proto_run, "proto_run not initialized for batch %s (%s)" % (
        batch_run.id,
        batch_run.dir,
    )
    util.copytree(proto_run.dir, run.dir)
    run.write_attr("flags", trial_flag_vals)
    run.write_attr("label", _trial_label(proto_run, trial_flag_vals))
    run.write_attr("op", _trial_op_attr(proto_run, trial_flag_vals))
    op_util.set_run_staged(run)
    return run
예제 #5
0
def _copy_source(source_path, dest_path, replace_existing=False):
    assert os.path.isabs(dest_path), dest_path
    if os.path.lexists(dest_path) or os.path.exists(dest_path):
        if not replace_existing:
            log.warning("%s already exists, skipping copy", dest_path)
            return
        log.debug("deleting existing source dest %s", dest_path)
        util.safe_rmtree(dest_path)
    util.ensure_dir(os.path.dirname(dest_path))
    log.debug("resolving source %s as copy %s", source_path, dest_path)
    if os.path.isdir(source_path):
        util.copytree(source_path, dest_path)
    else:
        util.copyfile(source_path, dest_path)