示例#1
0
    def test_graph(self):
        testBase, testTmp, testVar, testDone = createTestBase()
        try:
            directoryWrangler = jobChomper.directoryWrangler.DirectoryWrangler(
                testVar, testTmp, testDone)
            jobID = directoryWrangler.createJob()
            jobDirectory = directoryWrangler.getVar(jobID)
            stateDict = {jobChomper.runGraph.GRAPHFILEKEY: "test.graph"}
            stateDictFile = os.path.join(jobDirectory,
                                         jobChomper.runGraph.JOBSTATEFILE)
            with open(stateDictFile, 'w') as filewrite:
                filewrite.write(json.dumps(stateDict))

            graphData = "STARTNODE, A, FALSE\n"
            graphData += "A, B, TRUE\n"
            graphData += "A, C, TRUE\n"

            graphFile = os.path.join(jobDirectory, "test.graph")
            with open(graphFile, 'w') as filewrite:
                filewrite.write(graphData)

            runGraph = jobChomper.runGraph.RunGraph(directoryWrangler)
            runGraph.initFromState(jobID)

            toRun = runGraph.graphWalk(False)

        finally:
            shutil.rmtree(testBase)
示例#2
0
    def test_graph_startnode_finished_randomFail(self):
        testBase, testTmp, testVar, testDone = createTestBase()
        try:
            directoryWrangler = jobChomper.directoryWrangler.DirectoryWrangler(
                testVar, testTmp, testDone)
            jobID = directoryWrangler.createJob()
            jobDirectory = directoryWrangler.getVar(jobID)
            stateDict = jobChomper.safeFileDict.SafeFileDict({
                jobChomper.runGraph.GRAPHFILEKEY:
                "test.graph",
                jobChomper.node.JOBPROGRESSKEY: {
                    jobChomper.graph.STARTNODENAME: {
                        "status": jobChomper.node.PENDINGKEY
                    },
                    "fA": {
                        "status": jobChomper.node.PENDINGKEY
                    },
                    "fB": {
                        "status": jobChomper.node.PENDINGKEY
                    },
                    "fC": {
                        "status": jobChomper.node.PENDINGKEY
                    }
                }
            })
            stateDictFile = os.path.join(jobDirectory,
                                         jobChomper.runGraph.JOBSTATEFILE)
            stateDict.enableJournal(stateDictFile)
            stateDict.writeJournal()

            graphData = "STARTNODE, fA, FALSE\n"
            graphData += "fA, fB, TRUE\n"
            graphData += "fA, fC, TRUE\n"

            graphFile = os.path.join(jobDirectory, "test.graph")
            with open(graphFile, 'w') as filewrite:
                filewrite.write(graphData)

            runGraph = jobChomper.runGraph.RunGraph(directoryWrangler)
            runGraph.initFromState(jobID)

            toRun = runGraph.graphWalk(False)
            runInTheory = set([jobChomper.graph.STARTNODENAME])

            self.assertTrue(toRun == runInTheory)

            runGraph.graphRun(False)

            # print(runGraph.state)

            self.assertTrue('fA' in runGraph.state['bin'])
            self.assertTrue('fB' in runGraph.state['bin'])
            self.assertTrue('fC' in runGraph.state['bin'])

        finally:
            shutil.rmtree(testBase)
示例#3
0
    def test_graph_startnode_finished_restartPartialAndFailed(self):
        testBase, testTmp, testVar, testDone = createTestBase()
        try:
            directoryWrangler = jobChomper.directoryWrangler.DirectoryWrangler(
                testVar, testTmp, testDone)
            jobID = directoryWrangler.createJob()
            jobDirectory = directoryWrangler.getVar(jobID)
            stateDict = jobChomper.safeFileDict.SafeFileDict({
                jobChomper.runGraph.GRAPHFILEKEY:
                "test.graph",
                jobChomper.node.JOBPROGRESSKEY: {
                    jobChomper.graph.STARTNODENAME: {
                        "status": jobChomper.node.DONEKEY
                    },
                    "rA": {
                        "status": jobChomper.node.INPROGRESSKEY
                    },
                    "rB": {
                        "status": jobChomper.node.INPROGRESSKEY
                    },
                    "rC": {
                        "status": jobChomper.node.FAILEDKEY
                    }
                }
            })
            stateDictFile = os.path.join(jobDirectory,
                                         jobChomper.runGraph.JOBSTATEFILE)
            stateDict.enableJournal(stateDictFile)
            stateDict.writeJournal()

            graphData = "STARTNODE, rA, FALSE\n"
            graphData += "rA, rB, TRUE\n"
            graphData += "rA, rC, TRUE\n"

            graphFile = os.path.join(jobDirectory, "test.graph")
            with open(graphFile, 'w') as filewrite:
                filewrite.write(graphData)

            runGraph = jobChomper.runGraph.RunGraph(directoryWrangler)
            runGraph.initFromState(jobID)

            toRun = runGraph.graphWalk(False)

            runGraph.graphRun(True)

            self.assertTrue('rA' in runGraph.state['bin'])
            self.assertTrue('rB' in runGraph.state['bin'])
            self.assertTrue('rC' in runGraph.state['bin'])

        finally:
            shutil.rmtree(testBase)
示例#4
0
    def test_graph_startnode_finished_(self):
        testBase, testTmp, testVar, testDone = createTestBase()
        try:
            directoryWrangler = jobChomper.directoryWrangler.DirectoryWrangler(
                testVar, testTmp, testDone)
            jobID = directoryWrangler.createJob()
            jobDirectory = directoryWrangler.getVar(jobID)
            stateDict = {
                jobChomper.runGraph.GRAPHFILEKEY: "test.graph",
                jobChomper.node.JOBPROGRESSKEY: {
                    jobChomper.graph.STARTNODENAME: {
                        "status": jobChomper.node.DONEKEY
                    },
                    "A": {
                        "status": jobChomper.node.DONEKEY
                    },
                    "B": {
                        "status": jobChomper.node.DONEKEY
                    },
                    "C": {
                        "status": jobChomper.node.DONEKEY
                    }
                }
            }
            stateDictFile = os.path.join(jobDirectory,
                                         jobChomper.runGraph.JOBSTATEFILE)
            with open(stateDictFile, 'w') as filewrite:
                filewrite.write(json.dumps(stateDict))

            graphData = "STARTNODE, A, FALSE\n"
            graphData += "A, B, TRUE\n"
            graphData += "A, C, FALSE\n"

            graphFile = os.path.join(jobDirectory, "test.graph")
            with open(graphFile, 'w') as filewrite:
                filewrite.write(graphData)

            runGraph = jobChomper.runGraph.RunGraph(directoryWrangler)
            runGraph.initFromState(jobID)

            toRun = runGraph.graphWalk(False)
            runInTheory = set([])

            #print ("\n",toRun, runInTheory)

            self.assertTrue(toRun == runInTheory)
        finally:
            shutil.rmtree(testBase)
示例#5
0
    def test_graph_startnode_finished_simplified(self):
        testBase, testTmp, testVar, testDone = createTestBase()
        try:
            directoryWrangler = jobChomper.directoryWrangler.DirectoryWrangler(
                testVar, testTmp, testDone)
            jobID = directoryWrangler.createJob()
            runGraph = jobChomper.runGraph.RunGraph(directoryWrangler)
            runGraph.initFromGraph(os.path.join(testdir, 'rGraph.graph'),
                                   jobID)

            toRun = runGraph.graphWalk(False)
            runInTheory = set([jobChomper.graph.STARTNODENAME])

            self.assertTrue(toRun == runInTheory)

            runGraph.graphRun(False)

            self.assertTrue('rA' in runGraph.state['bin'])
            self.assertTrue('rB' in runGraph.state['bin'])
            self.assertTrue('rC' in runGraph.state['bin'])
        finally:
            shutil.rmtree(testBase)