def testUnfinishedJobsOneFinishedJob(self, subprocessMock): """ The unfinishedJobs method should return an empty set if the specification emitted one job that is finished. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [123], }, }, ], } subprocessMock.return_value = ('JOBID ST TIME NODELIST(REASON)\n') sps = SlurmPipelineStatus(status) self.assertEqual(set(), sps.unfinishedJobs(sps.specification))
def testUnfinishedJobsOneFinishedJob(self, subprocessMock): """ The unfinishedJobs method should return an empty set if the specification emitted one job that is finished. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'startAfter': None, 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [123], }, }, ], } subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n' '123|name|COMPLETED|04:32:00|cpu-4\n') sps = SlurmPipelineStatus(status) self.assertEqual(set(), sps.unfinishedJobs())
def testUnfinishedJobsMultipleSteps(self, subprocessMock): """ The unfinishedJobs method should return the expected job ids if the specification has multiple steps. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'startAfter': None, 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [12, 34], }, }, { 'name': 'end', 'scheduledAt': 1481379659.1530972, 'script': 'end.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'yyy': [56, 78, 90], }, }, ], } subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n' '12|name|RUNNING|04:32:00|cpu-3\n' '34|name|COMPLETED|04:32:00|cpu-3\n' '56|name|RUNNING|04:32:00|cpu-4\n' '78|name|COMPLETED|04:32:00|cpu-4\n' '90|name|RUNNING|04:32:00|cpu-5\n') sps = SlurmPipelineStatus(status) self.assertEqual({12, 56, 90}, sps.unfinishedJobs())
def testUnfinishedJobsMultipleSteps(self, subprocessMock): """ The unfinishedJobs method should return the expected job ids if the specification has multiple steps. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [12, 34], }, }, { 'name': 'end', 'scheduledAt': 1481379659.1530972, 'script': 'end.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'yyy': [56, 78, 90], }, }, ], } subprocessMock.return_value = ('JOBID ST TIME NODELIST(REASON)\n' '12 R 45:33 (None)\n' '56 R 27:01 (None)\n' '90 R 23:07 (None)\n') sps = SlurmPipelineStatus(status) self.assertEqual(set([12, 56, 90]), sps.unfinishedJobs(sps.specification))