Beispiel #1
0
    def testFinalJobsWithDependencies(self, subprocessMock):
        """
        The finalJobs method should produce the correct set of job ids emitted
        by the final step of a specification that contains a dependency.
        """
        status = {
            'force':
            False,
            'lastStep':
            None,
            'scheduledAt':
            1481379658.5455897,
            'scriptArgs': [],
            'skip': [],
            'startAfter':
            None,
            'steps': [
                {
                    'name': 'start',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'start.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'task1': [0, 1],
                        'task2': [2],
                    }
                },
                {
                    'dependencies': ['start'],
                    'name': 'end',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'end.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'task1': [3, 4, 5],
                        'task2': [7, 8],
                    }
                },
            ]
        }

        subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n'
                                       '0|name|RUNNING|04:32:00|cpu-3\n'
                                       '1|name|RUNNING|04:32:00|cpu-3\n'
                                       '2|name|RUNNING|04:32:00|cpu-3\n'
                                       '3|name|RUNNING|04:32:00|cpu-3\n'
                                       '4|name|RUNNING|04:32:00|cpu-3\n'
                                       '5|name|RUNNING|04:32:00|cpu-3\n'
                                       '6|name|RUNNING|04:32:00|cpu-3\n'
                                       '7|name|RUNNING|04:32:00|cpu-3\n'
                                       '8|name|RUNNING|04:32:00|cpu-3\n')

        sps = SlurmPipelineStatus(status)
        self.assertEqual({3, 4, 5, 7, 8}, sps.finalJobs())
Beispiel #2
0
    def testFinalJobsWithNoJobs(self, subprocessMock):
        """
        The finalJobs method should produce an empty set of job ids if the
        final step of a specification emits no jobs.
        """
        status = {
            'force':
            False,
            'lastStep':
            None,
            'scheduledAt':
            1481379658.5455897,
            'scriptArgs': [],
            'skip': [],
            'startAfter':
            None,
            'steps': [
                {
                    'name': 'start',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'start.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        # Two tasks were emitted, but without job ids.
                        'task1': [],
                        'task2': [],
                    }
                },
                {
                    'name': 'end',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'end.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {}
                },
            ]
        }

        subprocessMock.return_value = (
            'JobID|JobName|State|Elapsed|Nodelist\n')

        sps = SlurmPipelineStatus(status)
        self.assertEqual(set(), sps.finalJobs())
Beispiel #3
0
    def testFinalJobsWithDependencies(self):
        """
        The finalJobs method should produce the correct set of job ids emitted
        by the final step of a specification that contains a dependency.
        """
        status = {
            'force':
            False,
            'lastStep':
            None,
            'scheduledAt':
            1481379658.5455897,
            'scriptArgs': [],
            'skip': [],
            'steps': [
                {
                    'name': 'start',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'start.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'task1': [0, 1],
                        'task2': [2],
                    }
                },
                {
                    'dependencies': ['start'],
                    'name': 'end',
                    'scheduledAt': 1481379659.1530972,
                    'script': 'end.sh',
                    'stdout': '',
                    'taskDependencies': {},
                    'tasks': {
                        'task1': [3, 4, 5],
                        'task2': [7, 8],
                    }
                },
            ]
        }

        sps = SlurmPipelineStatus(status)
        self.assertEqual(set((3, 4, 5, 7, 8)),
                         sps.finalJobs(sps.specification))