def config_get(key): """ get a single config variable """ env = Environment(context.name) cfg = env.secret if key not in cfg: click.echo("No var found for `{}.{}`".format(context.name, key)) return click.echo(cfg[key])
def config_unset(key): env = Environment(context.name) cfg = env.secret if click.confirm( u"Do you wish to delete config variable {}.{} with value of `{}`". format(context.name, key, cfg[key])): del cfg[key] cfg.update()
def __init__(self): #clear terminal os.system('cls') #create pygame window self.window = PygameWindow.PygameWindow(1280, 720, "Genetic Algorithm Simulator") #create instance of Enviroment self.ENV = Environment.Environment() #load example 1 self.ENV.load_example_env1() #make population self.ENV.new_population() self.window.fps = 120 #add env to window self.window.load_env(self.ENV) self.run()
def config_envdir(target_dir): env = Environment(context.name) cfg = env.secret target_dir = os.path.abspath(target_dir) if not click.confirm("found {} vars, will write to `{}/*`".format( len(cfg), target_dir)): click.echo("Exiting..") sys.exit(1) if not os.path.exists(target_dir): click.echo("{} did not exists, creating".format(target_dir)) os.mkdir(target_dir) else: if os.path.exists(target_dir) and not os.path.isdir(target_dir): click.echo( "{} exists but isn't a directory, unable to continue".format( target_dir)) sys.exit(2) config.write_envdir(cfg, target_dir)
def echo(context, skip_k8s=False, skip_ecr=False): """ get the remote (k8s and ecr) status for the current kyber app context """ app = App(context.name, context.docker, context.tag) click.echo("Project: {}".format(context.name)) click.echo("Docker: {}".format(context.docker)) if not skip_k8s: deployed_app = Environment(context.name).app click.echo("Deployed tag: {}".format( deployed_app.tag if deployed_app is not None else 'N/A')) deployable = '?' if not skip_ecr: deployable = 'y' if ecr.image_exists(app.image) else 'n' click.echo("Current tag: {} [deployable: {}]".format( context.tag, deployable)) click.echo("Kubernetes target: {} ({})".format( context.kube_ctx['cluster'], context.kube_ctx['namespace']))
def config_load(source): source = os.path.abspath(source) env = Environment(context.name) if not os.path.exists(source): click.echo( "Can't load vars from `{}` no such file or directory".format( source)) sys.exit(1) if os.path.isdir(source): loaded_vars = config.read_envdir(source) if os.path.isfile(source): loaded_vars = config.read_envfile(source) if click.confirm( "Found {} vars in `{}` do you wish to write them to {}".format( len(loaded_vars), source, env)): config.save_secret(env, loaded_vars)
def config_set(key, value): """ set a single config variable""" env = Environment(context.name) cfg = env.secret cfg[key] = value cfg.update()
def config_list(): """ list configuration in var=value (envfile) format """ env = Environment(context.name) cfg = env.secret for key in sorted(cfg.keys()): click.echo("{}={}".format(key, cfg[key]))
import pickle import numpy as np from objects import Environment def discretize(s): return tuple(round(i/10) for i in s) def load_table(file): with open(file, 'rb') as pickle_in: Q = pickle.load(pickle_in) return Q env = Environment() Q = load_table('model.pickle') NUMBER_OF_EPISODES = 1 for i in range(NUMBER_OF_EPISODES): done = False s = env.reset() s = discretize(s) while not done: action = np.argmax(Q[s]) s2, reward, done, _ = env.step(action) s2 = discretize(s2) env.render() s = s2