Esempio n. 1
0
    def __init__(self, parent=None):
        super(LoginShowWidget, self).__init__(parent)

        # create large layouts
        layout = QtGui.QVBoxLayout()

        # build warning widgets
        layout_warning = QtGui.QHBoxLayout()
        layout_warning.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
        self.label_Status = QtGui.QLabel('Root Paths Exist: True')
        self.btn_Resolve = QtGui.QPushButton('Resolve')
        self.btn_Resolve.pressed.connect(lambda: self.resolveRootPaths(path_results))
        self.btn_Resolve.setVisible(False)

        layout_warning.addWidget(self.label_Status)
        layout_warning.addWidget(self.btn_Resolve)
        layout.addLayout(layout_warning)

        # build show list
        self.list_shows = gui.HListWidget()
        self.shows = core.Environment().allShows()

        self.list_shows.addNewItems(self.shows)

        layout.addWidget(self.list_shows)

        # Build action buttons
        layout_Cmd = QtGui.QHBoxLayout()
        self.btn_Login = QtGui.QPushButton('Login')
        self.btn_Login.clicked.connect(self.parent().login)
        self.btn_AddShow = QtGui.QPushButton('Add Show')
        self.btn_AddShow.clicked.connect(self.addShow)

        layout_Cmd.addWidget(self.btn_Login)
        layout_Cmd.addWidget(self.btn_AddShow)
        layout.addLayout(layout_Cmd)

        self.setLayout(layout)

        # Temporary to enable access to core functionality
        self.tempEnv = core.Environment()
        self.tempSetup = core.Setup(self.tempEnv)

        path_results = self.tempSetup.checkRootPaths()
        self.checkPaths(path_results)
Esempio n. 2
0
    def login(self):
        show = self.central_widget.currentWidget().getCurrent()

        tmpEnv = core.Environment()
        tmpEnv.setShow(show)

        tmpSetup = core.Setup(tmpEnv)
        tmpSetup.createBaseStructure()

        del tmpSetup
        del tmpEnv

        if show is not None:
            logged_in_widget = LoggedWidget(show, parent=self)
            self.central_widget.addWidget(logged_in_widget)
            self.central_widget.setCurrentWidget(logged_in_widget)
Esempio n. 3
0
def run(args):
    start_time = time.time()

    topology = graph.get_topology(args)
    env = core.Environment(args, topology=topology)

    logger = logging.getLogger('run')

    # in this case, a configuration changes only the load of the network
    exec_policies = ['SAP', 'LB']
    loads = [
        x for x in range(args.min_load, args.max_load + 1, args.load_step)
    ]

    final_output_folder = env.output_folder + '/' + datetime.datetime.now(
        datetime.timezone.utc).strftime('%Y%m%dT%H%M%S.%fUTC')
    env.output_folder = final_output_folder

    if not os.path.isdir('./results/' + env.output_folder):
        os.makedirs('./results/' + env.output_folder)
        logger.debug(f'creating folder {env.output_folder}')

    # copy current version of files
    with open('./results/{}/0-info.txt'.format(env.output_folder),
              'wt') as file:
        width = 20
        print('Date (UTC):'.ljust(width),
              datetime.datetime.now(datetime.timezone.utc),
              file=file)
        print('Date (local):'.ljust(width), datetime.datetime.now(), file=file)
        repo = git.Repo()
        print(
            'Commit date:'.ljust(width),
            datetime.datetime.fromtimestamp(
                repo.head.object.committed_date).strftime('%Y-%m-%d %H:%M:%S'),
            file=file)
        print('Author:'.ljust(width), repo.head.object.committer, file=file)
        print('GIT hexsha:'.ljust(width), repo.head.object.hexsha, file=file)
        print('Command:'.ljust(width), ' '.join(sys.argv), file=file)
        print('Arguments:'.ljust(width), args, file=file)

    # copy current version of files
    shutil.copytree('./',
                    f'./results/{env.output_folder}/source-code/',
                    ignore=shutil.ignore_patterns('__pycache__', '*.pyc',
                                                  '*.md', 'results', 'LICENSE',
                                                  '*.ipynb'))

    manager = Manager()
    results = manager.dict()
    for policy in exec_policies:  # runs the simulations for two policies
        results[policy] = {load: manager.list() for load in loads}

    envs = []
    for policy in exec_policies:  # runs the simulations for two policies
        for load in loads:
            if policy == 'SAP':  # shortest available path
                policy_instance = policies.ShortestAvailablePath()
            elif policy == 'LB':  # load balancing
                policy_instance = policies.LoadBalancing()
            else:
                raise ValueError(
                    'Policy was not configured correctly (value set to {})'.
                    format(policy))
            env_topology = copy.deepcopy(
                topology)  # makes a deep copy of the topology object
            env_t = core.Environment(args,
                                     topology=env_topology,
                                     results=results,
                                     load=load,
                                     policy=policy_instance,
                                     seed=len(exec_policies) * load,
                                     output_folder=final_output_folder)
            envs.append(env_t)
            # code for debugging purposes -- it runs without multithreading
            # if load == 400 and policy == 'SAP':
            #     core.run_simulation(env_t)

    logger.debug(f'Starting pool of simulators with {args.threads} threads')
    # use the code above to keep updating the final plot as the simulation progresses
    with Pool(processes=args.threads) as p:
        result_pool = p.map_async(core.run_simulation, envs)
        p.close()

        done = False
        while not done:
            if result_pool.ready():
                done = True
            else:
                time.sleep(args.temporary_plot_every)
                plots.plot_final_results(env, results, start_time)

    # if you do not want periodical updates, you can use the following code
    # with Pool(processes=args.threads) as p:
    #     p.map(core.run_simulation, envs)
    #     p.close()
    #     p.join()
    #     logging.debug("Finished the threads")

    # consolidating statistics
    plots.plot_final_results(env, results, start_time)

    with open('./results/{}/final_results.h5'.format(env.output_folder),
              'wb') as file:
        realized_results = dict(results)
        for k1, v1 in results.items():
            realized_results[k1] = dict(v1)
            for k2, v2 in results[k1].items():
                realized_results[k1][k2] = list(v2)
        pickle.dump(
            {
                'args': args,  # it is always advisable to save your inputs
                'env': env,  # the base environment as well
                'results': realized_results,
                'policies': [policy for policy in exec_policies],
                'loads': loads,
                'timedelta':
                datetime.timedelta(seconds=(time.time() - start_time)),
                'datetime': datetime.datetime.fromtimestamp(time.time())
            },
            file)

    logger.debug('Finishing simulation after {}'.format(
        datetime.timedelta(seconds=(time.time() - start_time))))
Esempio n. 4
0
                'env': env,  # the base environment as well
                'results': realized_results,
                'policies': [policy for policy in exec_policies],
                'loads': loads,
                'timedelta':
                datetime.timedelta(seconds=(time.time() - start_time)),
                'datetime': datetime.datetime.fromtimestamp(time.time())
            },
            file)

    logger.debug('Finishing simulation after {}'.format(
        datetime.timedelta(seconds=(time.time() - start_time))))


if __name__ == '__main__':
    env = core.Environment()

    parser = argparse.ArgumentParser()
    parser.add_argument('-tf',
                        '--topology_file',
                        default=env.topology_file,
                        help='Network topology file to be used')
    parser.add_argument(
        '-a',
        '--num_arrivals',
        type=int,
        default=env.num_arrivals,
        help='Number of arrivals per episode to be generated (default={})'.
        format(env.num_arrivals))
    parser.add_argument(
        '-k',
Esempio n. 5
0
def run(args):
    start_time = time.time()

    topology = graph.get_topology(args)
    env = core.Environment(args, topology=topology)

    logger = logging.getLogger('run')

    # in this case, a configuration changes only the load of the network
    policies = ['SP', 'LB']
    loads = [x for x in range(args.min_load, args.max_load + 1, args.load_step)]

    if not os.path.isdir('./results/' + env.output_folder):
        os.makedirs('./results/' + env.output_folder)
        logger.debug(f'creating folder {env.output_folder}')

    manager = Manager()
    results = manager.dict()
    for policy in policies: # runs the simulations for two policies
        results[policy] = {load: manager.list() for load in loads}

    envs = []
    for policy in policies: # runs the simulations for two policies
        for load in loads:
            env_topology = copy.deepcopy(topology) # makes a deep copy of the topology object
            env_t = core.Environment(args,
                                     topology=env_topology,
                                     results=results,
                                     load=load,
                                     policy=policy,
                                     seed=len(policies) * load)
            envs.append(env_t)
            # code for debugging purposes -- it runs without multithreading
            # if load == 10 and policy == 'LB':
            #     core.run_simulation(env_t)

    logger.debug(f'Starting pool of simulators with {args.threads} threads')
    # use the code above to keep updating the final plot as the simulation progresses
    with Pool(processes=args.threads) as p:
        result_pool = p.map_async(core.run_simulation, envs)
        p.close()

        done = False
        while not done:
            if result_pool.ready():
                done = True
            else:
                time.sleep(args.temporary_plot_every)
                plots.plot_final_results(env, results, start_time)

    # if you do not want periodical updates, you can use the following code
    # with Pool(processes=args.threads) as p:
    #     p.map(core.run_simulation, envs)
    #     p.close()
    #     p.join()
    #     logging.debug("Finished the threads")

    # consolidating statistics
    plots.plot_final_results(env, results, start_time)

    with open('./results/{}/results-final.h5'.format(env.output_folder), 'wb') as file:
        results = dict(results)
        for k,v in results.items():
            results[k] = dict(v);
            for k2,v2 in results[k].items():
                results[k][k2] = list(v2)
        pickle.dump(results, file)

    logger.debug('Finishing simulation after {}'.format(datetime.timedelta(seconds=(time.time() - start_time))))
import core
import mesh
import sys,time
e=core.Environment(sys.argv)

import discr
import exporter


m=mesh.Mesh_3()
m = mesh.load(m,"feelpp3d.geo",0.1)

Xh=discr.Pch_3D_P1(mesh=m)
P0h = discr.Pdh_3D_P0(mesh=m)
u=Xh.elementFromExpr("{sin(2*pi*x)*cos(pi*y)*cos(pi*z)}:x:y:z")
e = exporter.exporter(mesh=m)
e.addScalar("un", 1.)
e.addP1c("u",u);
e.addP0d("pid",discr.pid( P0h ));
e.save()
Esempio n. 7
0
    def __init__(self, show, parent=None):
        super(LoggedWidget, self).__init__(parent)

        self.show = show
        self.env = core.Environment()
        self.setup = core.Setup(self.env)
        self.env.setShow(self.show)

        self.sequences = self.env.sequences()
        self.shots = self.env.shots(self.sequences[0])

        wrapper = QtGui.QVBoxLayout()
        layout = QtGui.QHBoxLayout()

        grp_Selection = gui.GroupBox('Shot Select')
        sel_wrapper = QtGui.QVBoxLayout()

        sel_layout = QtGui.QHBoxLayout()
        sel_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)

        self.list_seq = gui.HListWidget()
        self.list_seq.addNewItems(self.sequences)
        self.list_seq.setCurrentRow(0)
        self.list_seq.itemClicked.connect(self.updateShots)
        sel_layout.addWidget(self.list_seq)

        self.list_shot = gui.HListWidget()
        self.list_shot.addNewItems(self.shots)
        self.list_shot.setCurrentRow(0)
        sel_layout.addWidget(self.list_shot)

        sel_wrapper.addLayout(sel_layout)
        self.btn_launch = QtGui.QPushButton('Launch')
        self.btn_launch.clicked.connect(self.launchFile)
        self.btn_NewFile = QtGui.QPushButton('Create New File...')
        self.btn_NewFile.clicked.connect(self.updateTags)
        sel_wrapper.addWidget(self.btn_NewFile)
        sel_wrapper.addWidget(self.btn_launch)

        grp_Selection.addLayout(sel_wrapper)

        grp_Filters = gui.GroupBox('Filters')
        filter_wrapper = QtGui.QVBoxLayout()

        self.chk_UseUsername = QtGui.QCheckBox('Username')
        filter_wrapper.addWidget(self.chk_UseUsername)

        self.filter_stages = gui.HLineItem('Stage', ['option 01', 'option 02'], inputtype='list', width=40)
        self.filter_tags = gui.HLineItem('Tag', ['option 03', 'option 04'], inputtype='list', width=40)

        self.list_filters = gui.HLineList([self.filter_stages, self.filter_tags])
        filter_wrapper.addLayout(self.list_filters)

        grp_Filters.addLayout(filter_wrapper)

        grp_Time = gui.GroupBox('File Details')
        layout_time = QtGui.QVBoxLayout()
        self.title_CurrentDate = QtGui.QLabel("Current Date/Time: ")
        self.label_CurrentDate = QtGui.QLabel('DATE GOES HERE')

        self.title_ModifyDate = QtGui.QLabel('Last Modified:')
        self.label_ModifyDate = QtGui.QLabel('DATE GOES HERE')

        layout_Cmd = QtGui.QHBoxLayout()
        layout_Cmd.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom)
        self.btn_Logout = QtGui.QPushButton('Logout')
        self.btn_Logout.clicked.connect(self.parent().logout)
        layout_Cmd.addWidget(self.btn_Logout)

        layout.addWidget(grp_Selection)

        layout_right = QtGui.QVBoxLayout()
        layout_right.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignLeft)
        layout_right.addWidget(grp_Filters)

        layout_right.addWidget(self.title_CurrentDate)
        layout_right.addWidget(self.label_CurrentDate)
        layout_time.addWidget(self.title_ModifyDate)
        layout_time.addWidget(self.label_ModifyDate)
        grp_Time.addLayout(layout_time)

        layout_right.addWidget(grp_Time)
        layout.addLayout(layout_right)

        wrapper.addLayout(gui.TitleLine(self.env.SHOW, self.env.currentUser()))
        wrapper.addLayout(layout)
        wrapper.addLayout(layout_Cmd)

        self.setLayout(wrapper)

        self.updateStages()
        self.update()
        self.updateCurrentDate()

        self.filter_stages.list.currentIndexChanged.connect(self.update)
        self.filter_tags.list.currentIndexChanged.connect(self.updateModified)
Esempio n. 8
0
import core
import mesh
import sys, time
from modelcore import *

e = core.Environment(sys.argv, opts=toolboxes_options("fluid"))

import discr
import exporter
import ts
from fluid import *

f = Fluid_P2P1G1("fluid")
f.init()
f.printAndSaveInfo()
if f.isStationary():
    f.solve()
    f.exportResults()
else:
    if not f.doRestart():
        f.exportResults(f.timeInitial())
    while not f.timeStepBase().isFinished():
        if f.worldComm().isMasterRank():
            print(
                "============================================================\n"
            )
            print("time simulation: ", f.time(), "s \n")
            print(
                "============================================================\n"
            )
        f.solve()