Ejemplo n.º 1
0
    def test_get_fresh(self):
        ed = ExperimentDefinition()
        self.addCleanup(self._del_table, "experiment")
        ed.create_table(self._db)
        ed.store(self._db)

        ed_2 = ExperimentDefinition()
        ed_2.store(self._db)

        ed_f = ExperimentDefinition()
        ed_f.load_fresh(self._db)
        self.assertEqual(ed_f._trace_id, 1)
        ed_f_2 = ExperimentDefinition()
        ed_f_2.load_fresh(self._db)
        self.assertEqual(ed_f_2._trace_id, 2)
Ejemplo n.º 2
0
 def do_work(self, central_db_obj, sched_db_obj, trace_id=None):
     """
     Args:
     - central_db_obj: DB object configured to access the analysis database.
     - sched_db_obj: DB object configured to access the slurm database of
         an experiment worker. 
     - trace_id: If set to an experiment valid trace_id, it runs only the
         experiment identified by trace_id.
     """
     there_are_more=True
     while there_are_more:
         ed = ExperimentDefinition()
         if trace_id:
             ed.load(central_db_obj, trace_id)
             ed.mark_pre_simulating(central_db_obj)
         else:
             there_are_more = ed.load_fresh(central_db_obj)
         if there_are_more:
             print(("About to run exp({0}):{1}".format(
                             ed._trace_id, ed._name)))
             er = ExperimentRunner(ed)
             if(er.do_full_run(sched_db_obj, central_db_obj)):
                 print(("Exp({0}) Done".format(
                                              ed._trace_id)))
             else:
                 print(("Exp({0}) Error!".format(
                                              ed._trace_id)))
         if trace_id:
             break  
Ejemplo n.º 3
0
    def test_get_fresh_concurrent(self):
        ed = ExperimentDefinition()
        self.addCleanup(self._del_table, "experiment")
        ed.create_table(self._db)
        for i in range(200):
            ed.store(self._db)

        if os.path.exists("./out.file"):
            os.remove("./out.file")
        out = open("./out.file", "w")
        p = subprocess.Popen(["python", "./fresh_reader.py"], stdout=out)

        count = 0
        there_are_more = True
        ids = []

        while there_are_more:
            ed_f = ExperimentDefinition()
            there_are_more = ed_f.load_fresh(self._db)
            if there_are_more:
                ids.append(ed_f._trace_id)
        time.sleep(5)
        out.flush()
        out.close()

        out = open("./out.file", "r")
        lines = out.readlines()
        other_ids = []

        for line in lines:
            if "END2" in line:
                print("")
                text_list = line.split("END2: [")[1]
                text_list = text_list.split("]")[0]
                other_ids = [int(x) for x in text_list.split(",")]
        self.assertGreater(len(ids), 0)
        self.assertGreater(len(other_ids), 0)
        for id in ids:
            self.assertNotIn(id, other_ids)
        print(("IDs", ids, other_ids))
Ejemplo n.º 4
0
from commonLib.DBManager import DB
from orchestration.definition import ExperimentDefinition

import os

db_obj = DB(os.getenv("TEST_DB_HOST", "127.0.0.1"),
            os.getenv("TEST_DB_NAME", "test"),
            os.getenv("TEST_DB_USER", "root"), os.getenv("TEST_DB_PASS", ""))

there_are_more = True
ids = []
while there_are_more:
    ed_f = ExperimentDefinition()
    there_are_more = ed_f.load_fresh(db_obj)
    if there_are_more:
        ids.append(ed_f._trace_id)

print("END2:", ids)
print("END3")