Exemple #1
0
def test():

    if request.method == 'GET':
        # Call the init function from the environment.py script
        environment.init()
        # Return done as the response text for the ajax request
        # Originally for a work around of the Heroku time request limit
        # Leaving in place as a loading page
        return 'done'

    if request.method == 'POST':
        # Assign all form parameters to the environment variables from the form data
        # Adapted from : https://stackoverflow.com/questions/42154602/how-to-get-form-data-in-flask
        environment.environment_form = request.form.get('grid_type')
        environment.algorithm_form = request.form.get('algorithm')
        environment.episodes_form = request.form.get('episode')
        environment.max_steps_form = request.form.get('max_steps')
        environment.per_step_cost = request.form.get('per_step_cost')
        environment.goal_reward = request.form.get('goal_reward')
        environment.gamma_form = request.form.get('gamma')
        environment.epsilon_form = request.form.get('epsilon')
        environment.epsilon_form_decay = request.form.get('epsilon_decay')
        environment.alpha_form = request.form.get('alpha')
        environment.alpha_form_decay = request.form.get('alpha_decay')
        environment.trap_reward = request.form.get('trap_reward')
        # Show the waiting "loading page"
        return render_template('waiting.html')
def configs():
    from environment import cassandra_settings as settings
    from environment import init

    yield False  # do prepare first?

    # for sleep_time, divisor in [(0,1000000),(1,100000),(10,1000)]:
    for ignore in xrange(0, 8, 2):
        for skew in ["2"]:  # ,'1.5']:
            settings.skew = skew
            settings.ignore = ignore
            init()
            set_pars()

            # settings.replication_factor = 1
            # settings.large_replication_degree = 8
            # settings.max_items_for_large_replication_degree = 1
            # yield False

            # settings.replication_factor = 1
            # settings.large_replication_degree = 8
            # settings.max_items_for_large_replication_degree = 10
            # yield False

            # settings.replication_factor = 1
            # settings.large_replication_degree = 2
            # settings.max_items_for_large_replication_degree = 1
            # yield False

            # settings.replication_factor = 1
            # settings.large_replication_degree = 2
            # settings.max_items_for_large_replication_degree = 10
            # yield False

            settings.replication_factor = 1
            settings.large_replication_degree = 1
            settings.max_items_for_large_replication_degree = 0
            yield False

            settings.replication_factor = 2
            settings.large_replication_degree = 2
            settings.max_items_for_large_replication_degree = 0
            yield False

            settings.replication_factor = 8
            settings.large_replication_degree = 8
            settings.max_items_for_large_replication_degree = 0
            yield False
def configs():
    from environment import cassandra_settings as settings
    from environment import init

    yield False  # do prepare first?

    #for sleep_time, divisor in [(0,1000000),(1,100000),(10,1000)]:
    for ignore in xrange(0, 8, 2):
        for skew in ['2']:  #,'1.5']:
            settings.skew = skew
            settings.ignore = ignore
            init()
            set_pars()

            #settings.replication_factor = 1
            #settings.large_replication_degree = 8
            #settings.max_items_for_large_replication_degree = 1
            #yield False

            #settings.replication_factor = 1
            #settings.large_replication_degree = 8
            #settings.max_items_for_large_replication_degree = 10
            #yield False

            #settings.replication_factor = 1
            #settings.large_replication_degree = 2
            #settings.max_items_for_large_replication_degree = 1
            #yield False

            #settings.replication_factor = 1
            #settings.large_replication_degree = 2
            #settings.max_items_for_large_replication_degree = 10
            #yield False

            settings.replication_factor = 1
            settings.large_replication_degree = 1
            settings.max_items_for_large_replication_degree = 0
            yield False

            settings.replication_factor = 2
            settings.large_replication_degree = 2
            settings.max_items_for_large_replication_degree = 0
            yield False

            settings.replication_factor = 8
            settings.large_replication_degree = 8
            settings.max_items_for_large_replication_degree = 0
            yield False
Exemple #4
0
def main(screen):
    screen.resize(*GAME_SIZE)
    screen.nodelay(True)
    environment.init(screen)
    hud.init(screen)
    while True:
        draw_scene(screen)
        key = screen.getch()
        if key == ord('q'):
            break
        elif key == ord('p'):
            state['pdb'] = True
        else:
            update_state(key, state)
        state['frames'] += 1
        state['time'] += 1 / FPS
    screen.clear()
    screen.getkey()
Exemple #5
0
def main():
    global g_paths
    global g_path

    # load the environment variables.
    environment.init()

    # initialiase the dialog package.
    dialog.init()

    # initialize the 'g_path' variable.
    g_path = "configure.frm"
    g_paths.append(g_path)

    # main loop until there is a frame or variable to display.
    while True:
        # load the information on the current frame.
        load(g_path)

        # handle the current frame: display, get the user choice etc.
        frame()
Exemple #6
0
def main():
    global g_paths
    global g_path

    # load the environment variables.
    environment.init()

    # initialiase the dialog package.
    dialog.init()

    # initialize the 'g_path' variable.
    g_path = "configure.frm"
    g_paths.append(g_path)

    # main loop until there is a frame or variable to display.
    while True:
        # load the information on the current frame.
        load(g_path)

        # handle the current frame: display, get the user choice etc.
        frame()
Exemple #7
0
'''
@Author: hua
@Date: 2019-12-18 17:22:18
@description: 
@LastEditors  : hua
@LastEditTime : 2019-12-18 17:23:51
'''
import environment
environment.init("job")
from app import sched
#开始任务
sched.start()
Exemple #8
0
'''
@Author: hua
@Date: 2018-08-30 10:52:11
@description: 
@LastEditors  : hua
@LastEditTime : 2019-12-19 10:17:46
'''
import environment
environment.init("socket")
from app import app, socketio
from flask_cors import CORS
# https://www.cnblogs.com/franknihao/p/7202253.html uwsgi配置
app = app
CORS(app, supports_credentials=True)
if __name__ == '__main__':
    app.debug = False
    socketio.run(app, host='0.0.0.0', port=501)
Exemple #9
0
"""
@Author: hua
@Date: 2018-08-30 10:52:11
@description:
@LastEditors  : hua
@LastEditTime : 2019-12-19 10:15:54
"""
import environment

environment.init("run")
from app import app
from flask_cors import CORS

# https://www.cnblogs.com/franknihao/p/7202253.html uwsgi配置
app = app
CORS(app, supports_credentials=True, resources=r'/*')
if __name__ == '__main__':
    app.debug = False
    app.run(host='0.0.0.0', port=500)
Exemple #10
0
# -*- coding: utf-8  -*-
# @Author: ty
# @File name: run.py
# @IDE: PyCharm
# @Create time: 12/21/20 5:50 PM

from flask_cors import CORS

import environment
from app import app

environment.init('run')

app = app
CORS(app, suports_credentials=True)
if __name__ == '__main__':
    app.debug = False
    app.run(host='0.0.0.1', port=5000)
Exemple #11
0
'''
@Author: hua
@Date: 2019-06-17 14:14:28
@description: 
@LastEditors  : hua
@LastEditTime : 2020-01-23 21:41:20
'''
import environment
environment.init("app")
""" from gevent import monkey
monkey.patch_all(select=True, socket=True) #这边win下会报错用http请求时 """
from app import app, socketio
from flask_cors import CORS
# https://www.cnblogs.com/franknihao/p/7202253.html uwsgi配置
app = app
CORS(app, supports_credentials=True)
if __name__ == '__main__':
    app.debug = False
    socketio.run(app, host='0.0.0.0', port=501)
    
from environment import DSTAT_SERVER
from environment import DSTAT_YCSB
from environment import YCSB_SKEW_PROPERTY

import clean

import collect

import git

import jmx

import benchmark as bench

bench.set_pars()
environment.init()

def print_time():
    print("TIME: " + str(dt.now().strftime('%Y-%m-%d %H:%M.%S')))


def execute(*args, **kargs):
    print_time()
    plain_execute(*args, **kargs)

@task
@parallel
@roles('ycsbnodes')
def monitor():
    run("tail -F {YCSB_RUN_ERR_FILE} {YCSB_LOAD_ERR_FILE}".format(**globals()))

### RUNTIME ###

## handle env init stuff

# extract baseline values
bl = None
if args.baseline:
    try:
        bl = Baseline(abspath(args.baseline))
    except:
        print('baseline file %s not found or parse error' %args.baseline)
        exit()

env.init(bl)

max_speedup_pump = 1
max_speedup_fan = 100

## handle ROS init stuff

rospy.set_param("use_sim_time", True)
rospy.init_node('Simulator', anonymous=True)

generate_publishers()
generate_subscribers()


### Sim loop (Put here for threading purposes)
doloop = True
Exemple #14
0
# actor critic init settings --------------------------------------------------
# if gpu is to be used
mode = cfg['Network']['mode']
use_cuda = torch.cuda.is_available() if mode == 'gpu' else False

# if trainig or testing goal
goal = cfg['Sim']['goal']
training = True if goal == "training" else False

# make sure, that everything is ported to the gpu if one should be used
ac.init(mode=mode, goal=goal, policy_kind=cfg['Network']['kind'])

# Environment init settings ---------------------------------------------------
# simulation goal
Environment.init(goal=goal, policy_kind=cfg['Network']['kind'])

cfg_res = cfg['Sim']['resume_state_from']  # resume filepath

resume = None  # initialize
# if resume filepath is given, resume simulation from there
if arg_res and cfg_res:
    if arg_res != cfg_res:  # cmd line arg > cfg arg
        warnings.warn(
            "resume is specified twice and doesn't match."
            "\nGiven paths:\n\t{}\n\t{}\nResuming from {} now..."
            "".format(arg_res, cfg_res, arg_res), UserWarning)
        resume = torch.load(arg_res)
    else:
        print(": Resuming simulation from checkpoint {}".format(arg_res))
        resume = torch.load(arg_res)
Exemple #15
0
"""
@Author: hua
@Date: 2018-08-30 10:52:11
@description:
@LastEditors  : hua
@LastEditTime : 2019-12-19 10:17:26
"""
import environment

environment.init("restful")
from app import app
from flask_restful import Api
from flask_cors import CORS
from app.Controllers.RestfulController import TodoList

# https://www.cnblogs.com/franknihao/p/7202253.html uwsgi配置
# https://www.jianshu.com/p/ed1f819a7b58 restful配置
api = Api(app)
api.add_resource(TodoList, '/todos')
app = app
CORS(app, supports_credentials=True)
if __name__ == '__main__':
    app.debug = False
    app.run(host='0.0.0.0', port=502)
Exemple #16
0
import environment
import model
import torch
from itertools import count
from settings import DEVICE, SCREEN_WIDTH, TARGET_UPDATE, EPOCHS

# Environment Setup
world = environment.init()
world.reset()

# Log how long our agent lasts for each iteration
durations = []

# Training
agent = model.Agent(DEVICE)

for i in range(EPOCHS):
    # Initialize environment
    world.reset()

    # Get current state
    last_screen = environment.get_screen(world, SCREEN_WIDTH, DEVICE)
    current_screen = environment.get_screen(world, SCREEN_WIDTH, DEVICE)
    state = current_screen - last_screen

    for t in count():
        # Select and perform an action
        action = agent.select_action(state)
        _, reward, done, _ = world.step(action.item())
        reward = torch.tensor([reward], device=DEVICE)
Exemple #17
0
from environment import DSTAT_SERVER
from environment import DSTAT_YCSB
from environment import YCSB_SKEW_PROPERTY

import clean

import collect

import git

import jmx

import benchmark as bench

bench.set_pars()
environment.init()


def print_time():
    print("TIME: " + str(dt.now().strftime('%Y-%m-%d %H:%M.%S')))


def execute(*args, **kargs):
    print_time()
    plain_execute(*args, **kargs)


@task
@parallel
@roles('ycsbnodes')
def monitor():
Exemple #18
0
'''
@Author: hua
@Date: 2019-06-17 14:14:29
@description: 
@LastEditors  : hua
@LastEditTime : 2020-01-07 19:53:45
'''
import environment

environment.init("admin")
from app import app
from flask_cors import CORS
# https://www.cnblogs.com/franknihao/p/7202253.html uwsgi配置
app = app
CORS(app, supports_credentials=True)
if __name__ == '__main__':
    app.debug = False
    app.run(host='0.0.0.0', port=500)