def setUp(self): """ Repeating above test cases but with delays to determine that delay flags reach us. Returns ------- """ self.env = simpy.Environment() config = Config(INTEGRATION) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) dm = DelayModel(0.9, "normal", DelayModel.DelayDegree.HIGH) self.planner = Planner( self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft',delay_model=dm), delay_model=dm ) self.scheduler = Scheduler( self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan() ) self.telescope = Telescope( self.env, config, self.planner, self.scheduler ) self.env.process(self.cluster.run()) self.env.process(self.buffer.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.telescope.run())
def setUp(self) -> None: """ This test scenario is going to test the edge cases like double-allocation that may happen. For example - the use of curr_allocs should result in the _process_current_schedule not double_allocation, so we will test this. Returns ------- """ self.env = simpy.Environment() config = Config(CONFIG) sched_algorithm = DynamicAlgorithmFromPlan() self.cluster = Cluster(env=self.env, config=config) self.telescope = Telescope(self.env, config, planner=None, scheduler=None) self.buffer = Buffer(self.env, self.cluster, config) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, sched_algorithm) self.observation = self.telescope.observations[0] self.machine = self.cluster.machines[0]
def setUp(self) -> None: """ Create a planner and a `simpy` environment in which to run dummy simulations for the purpose of ensuring the planner works nicely when selecting 'batch' as a static scheduling method. Returns ------- """ self.env = simpy.Environment() config = Config(CONFIG) self.model = BatchPlanning('batch') self.cluster = Cluster(self.env, config=config) self.buffer = Buffer(env=self.env, cluster=self.cluster, config=config) self.planner = Planner( self.env, PLAN_ALGORITHM, self.cluster, self.model, ) self.telescope = Telescope(self.env, config, planner=None, scheduler=None)
def setUp(self): self.env = simpy.Environment() config = Config(INTEGRATION) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) self.planner = Planner(self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft')) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan()) self.telescope = Telescope(self.env, config, self.planner, self.scheduler) self.env.process(self.cluster.run()) self.env.process(self.buffer.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.telescope.run())
def testTelescopeBasicConfig(self): telescope = Telescope(env=self.env, config=self.config, planner=None, scheduler=self.scheduler) self.assertEqual(36, telescope.total_arrays) # Pipelines are associated with individual observation self.assertTrue('emu' in telescope.pipelines)
def setUp(self) -> None: self.env = simpy.Environment() config = Config(CONFIG) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan) self.planner = Planner(self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft')) # planner = None self.telescope = Telescope(self.env, config, self.planner, self.scheduler)
class TestSchedulerIntegration(unittest.TestCase): def setUp(self): self.env = simpy.Environment() config = Config(INTEGRATION) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) self.planner = Planner(self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft')) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan()) self.telescope = Telescope(self.env, config, self.planner, self.scheduler) self.env.process(self.cluster.run()) self.env.process(self.buffer.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.telescope.run()) def test_FIFO_with_buffer(self): """ Demonstrate that the scheduler accurately schedules when we have other Actors working in tandem. Expectations: - After 1 timestep in the simualtion, we have 5 resources available of the 10 that we start with. - Returns ------- """ self.env.run(until=1) self.assertEqual(10, len(self.cluster._resources['available'])) # This takes timestep, data in the HotBuffer should be 4 self.env.run(until=2) self.assertEqual(5, len(self.cluster._resources['available'])) self.assertEqual(496, self.buffer.hot[0].current_capacity) self.env.run(until=31) self.assertEqual(5, len(self.cluster._tasks['finished'])) # self.assertEqual(500, self.buffer.hot[0].current_capacity) self.assertEqual(210, self.buffer.cold[0].current_capacity) self.env.run(until=32) # Ensure the time self.assertEqual(ScheduleStatus.ONTIME, self.scheduler.schedule_status) # 30 timesteps until we finish everything + 81 timesteps to complete # workflow plan. self.env.run(until=124) # As we have been processing the current observation, we are also # ingestting the next one. self.assertEqual(250, self.buffer.cold[0].current_capacity)
def setUp(self): self.env = simpy.Environment() sched_algorithm = DynamicAlgorithmFromPlan() config = Config(LONG_CONFIG) self.cluster = Cluster(self.env, config) planning_model = SHADOWPlanning(algorithm=PLANNING_ALGORITHM) self.planner = Planner(self.env, PLANNING_ALGORITHM, self.cluster, planning_model) self.buffer = Buffer(self.env, self.cluster, config) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, sched_algorithm) self.telescope = Telescope(self.env, config, self.planner, self.scheduler)
def setUp(self) -> None: """ Setup a cluster and a simulation environment to test ingest pipelines """ self.env = simpy.Environment() config = Config(CONFIG) self.cluster = Cluster(env=self.env, config=config) self.telescope = Telescope(self.env, config, planner=None, scheduler=None) self.observation = self.telescope.observations[0]
def setUp(self) -> None: """ Batch scheduling setup """ self.env = simpy.Environment() config = Config(CONFIG) self.cluster = Cluster(env=self.env, config=config) self.telescope = Telescope(self.env, config, planner=None, scheduler=None) self.observation = self.telescope.observations[0]
def testIngest(self): telescope = Telescope(env=self.env, config=self.config, planner=self.planner, scheduler=self.scheduler) self.assertEqual(0, telescope.telescope_use) self.env.process(telescope.run()) self.env.process(self.cluster.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.buffer.run()) self.env.run(until=2) self.assertEqual(36, telescope.telescope_use) self.assertEqual(5, len(self.cluster._resources['available'])) # After 1 timestep, data in the HotBuffer should be 2 self.assertEqual(496, self.buffer.hot[0].current_capacity) self.env.run(until=11) self.assertEqual(len([self.buffer.hot[0].observations["transfer"]]), 1) self.assertEqual(462, self.buffer.hot[0].current_capacity) self.assertEqual(248, self.buffer.cold[0].current_capacity) self.env.run(until=12) self.assertEqual(0, telescope.telescope_use) self.assertEqual(10, len(self.cluster._resources['available'])) self.assertEqual(5, len(self.cluster._tasks['finished']))
def setUp(self) -> None: """ TODO Set up tasks and cluster to attempt allocation of tasks to resources """ self.env = simpy.Environment() config = Config(CONFIG) self.cluster = Cluster(env=self.env, config=config) self.telescope = Telescope(self.env, config, planner=None, scheduler=None) self.observation = self.telescope.observations[0] self.machine = self.cluster.machines[0] self.task = Task('test_0', 0, 2, self.machine, [])
def setUp(self): self.algorithm = BatchProcessing self.env = simpy.Environment() config = Config(CONFIG) self.cluster = Cluster(self.env, config=config) self.buffer = Buffer(self.env, self.cluster, config) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan()) self.algorithm = BatchProcessing() self.model = BatchPlanning('batch') self.planner = Planner( self.env, 'heft', self.cluster, self.model, ) self.telescope = Telescope(self.env, config, self.planner, self.scheduler)
class TestSchedulerDelayHelpers(unittest.TestCase): def setUp(self): self.env = simpy.Environment() config = Config(INTEGRATION) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) self.planner = Planner(self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft'), delay_model=DelayModel(0.3, "normal")) self.scheduler = Scheduler(self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan()) self.telescope = Telescope(self.env, config, self.planner, self.scheduler) self.env.process(self.cluster.run()) self.env.process(self.buffer.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.telescope.run()) def test_propogate_delay_returns_updated_workflow(self): """
class TestDelaysInActors(unittest.TestCase): def setUp(self): """ Repeating above test cases but with delays to determine that delay flags reach us. Returns ------- """ self.env = simpy.Environment() config = Config(INTEGRATION) self.cluster = Cluster(self.env, config) self.buffer = Buffer(self.env, self.cluster, config) dm = DelayModel(0.9, "normal", DelayModel.DelayDegree.HIGH) self.planner = Planner( self.env, PLANNING_ALGORITHM, self.cluster, SHADOWPlanning('heft',delay_model=dm), delay_model=dm ) self.scheduler = Scheduler( self.env, self.buffer, self.cluster, DynamicAlgorithmFromPlan() ) self.telescope = Telescope( self.env, config, self.planner, self.scheduler ) self.env.process(self.cluster.run()) self.env.process(self.buffer.run()) self.scheduler.start() self.env.process(self.scheduler.run()) self.env.process(self.telescope.run()) def test_scheduler_delay_detection(self): """ Nothing should change until we reach the workflow plan, as we are testing TaskDelays Returns ------- """ self.env.run(until=1) # Remember - env starts at 0, we don't start until 1. self.assertEqual(10, len(self.cluster._resources['available'])) self.env.run(until=2) # After 1 timestep, data in the HotBuffer should be 4 self.assertEqual(496, self.buffer.hot[0].current_capacity) self.env.run(until=31) self.assertEqual(5, len(self.cluster._tasks['finished'])) self.assertEqual(500, self.buffer.hot[0].current_capacity) self.env.run(until=44) # We know that the schedule has been delayed - however, we don't # report this to the telescope until we know how long we are delayed # (that is, until the task has completely finished its duration). # In this instance. we know that the first task is going to be # delayed, and so wait until it's completed execution to trigger a # delay. self.assertEqual(ScheduleStatus.ONTIME, self.scheduler.schedule_status) self.env.run(until=45) self.assertTrue(ScheduleStatus.DELAYED,self.scheduler.schedule_status) self.env.run(until=124) # Assert that we still have tasks running # self.assertLess( # 0, len(self.cluster.clusters['default']['tasks']['running']) # ) self.assertNotEqual(250, self.buffer.cold[0].current_capacity) def test_telescope_delay_detection(self): """ Returns ------- """ self.env.run(until=1) # Remember - env starts at 0, we don't start until 1. self.assertEqual(10, len(self.cluster._resources['available'])) self.env.run(until=2) # After 1 timestep, data in the HotBuffer should be 4 self.assertEqual(496, self.buffer.hot[0].current_capacity) self.env.run(until=31) self.assertEqual(5, len(self.cluster._tasks['finished'])) self.assertEqual(500, self.buffer.hot[0].current_capacity) self.env.run(until=32) # Ensure the time self.assertEqual(ScheduleStatus.ONTIME, self.scheduler.schedule_status) self.env.run(until=100) self.assertEqual(ScheduleStatus.DELAYED,self.scheduler.schedule_status) self.assertTrue(self.telescope.delayed) def test_telescope_delay_greedy_decision(self): """