def save_local_config(flags, verbose=True): loc_file = os.path.abspath( os.path.join(flags.chkpt_dir, os.path.basename(flags.config))) abs_config = os.path.abspath(flags.config) if os.path.realpath(loc_file) != os.path.realpath(abs_config): if not os.path.exists(flags.chkpt_dir): U.mkdirs(FLAGS.chkpt_dir) if verbose: print('Created checkpoint directory: {}'.format( os.path.abspath(flags.chkpt_dir))) dump_config(flags, loc_file) if verbose: print('Saving FLAGS to: {}'.format(loc_file))
def make_abs(path): return os.path.abspath(path) ''' get config ''' parser = options.get_parser() config_file = 'config/mode.conf' argv=[]# override config file here FLAGS = config.get_config(parser=parser, config_file=config_file, argv=argv) FLAGS.chkpt_dir = make_abs(FLAGS.chkpt_dir) FLAGS.data_dir = os.path.join(FLAGS.data_dir, FLAGS.item_id) pprint.pprint(FLAGS) ''' setup checkpoint directory ''' if not os.path.exists(FLAGS.chkpt_dir): U.mkdirs(FLAGS.chkpt_dir) print('Created checkpoint directory', FLAGS.chkpt_dir) config.save_local_config(FLAGS) # ''' setup logger (???) ''' # U.set_logger(FLAGS.chkpt_dir) ''' random seed ''' rand_seed = U.seed_random(FLAGS.seed) pid = FLAGS.item_id mode = FLAGS.run_mode ''' load GLOVE word embeddings ''' emb_words = None if not FLAGS.skip_emb_preload: