<commit_before>try:
    import cPickle
except ImportError:
    import pickle as cPickle
    
import os

def readJob(jobFile):
    fileHandle = open(jobFile, 'r')
    job = cPickle.load(fileHandle)
    fileHandle.close()
    return job

def getJobFileName(globalTempDir):
    return os.path.join(globalTempDir, "job.xml")

def getJobStatsFileName(globalTempDir):
    return os.path.join(globalTempDir, "stats.xml")

class Job:
    #Colours for job
    blue = 0
    black = 1
    grey = 2
    red = 3
    dead = 4
    
    @staticmethod
    def translateColourToString(colour):
        colours = { Job.blue:"blue", 
                   Job.black:"black", Job.grey:"grey", 
                   Job.red:"red", Job.dead:"dead" }
        return colours[colour]
    
    def __init__(self, command, memory, cpu, parentJobFile, config):
        self.globalTempDir = config.attrib["job_file_tree"].getTempDirectory()
        self.remainingRetryCount = int(config.attrib["retry_count"])
        self.colour = Job.grey
        self.parentJobFile = parentJobFile
        self.issuedChildCount = 0
        self.completedChildCount = 0
        self.childCommandsToIssue = []
        self.followOnCommandsToIssue = []
        self.messages = []
        self.addFollowOnCommand((command, memory, cpu))
    
    def write(self, jobFile):
        fileHandle = open(jobFile, 'w')
        cPickle.dump(self, fileHandle, cPickle.HIGHEST_PROTOCOL)
        fileHandle.close() 
    
    def getJobFileName(self):
        return getJobFileName(self.globalTempDir)
      
    def getLogFileName(self):
        return os.path.join(self.globalTempDir, "log.txt")
        
    def getGlobalTempDirName(self):
        return self.globalTempDir
        
    def getJobStatsFileName(self):
        return getJobStatsFileName(self.globalTempDir)
    
    def getRemainingRetryCount(self):
        return self.remainingRetryCount
    
    def setRemainingRetryCount(self, remainingRetryCount):
        self.remainingRetryCount = remainingRetryCount
    
    def getParentJobFile(self):
        return self.parentJobFile
    
    def getIssuedChildCount(self):<commit_msg>Switching to marshal for job pickling<commit_after>
import marshal as pickler
#import cPickle as cPickle
#import pickle as cPickle
#import json as cPickle    
import os

def readJob(jobFile):
    fileHandle = open(jobFile, 'r')
    job = convertJsonJobToJob(pickler.load(fileHandle))
    fileHandle.close()
    return job

def getJobFileName(globalTempDir):
    return os.path.join(globalTempDir, "job.xml")

def getJobStatsFileName(globalTempDir):
    return os.path.join(globalTempDir, "stats.xml")

def convertToJobToJson(job):
    jsonJob = [ job.globalTempDir,
                job.remainingRetryCount,
                job.colour,
                job.parentJobFile,
                job.issuedChildCount,
                job.completedChildCount,
                job.childCommandsToIssue,
                job.followOnCommandsToIssue,
                job.messages ]
    return jsonJob

def convertJsonJobToJob(jsonJob):
    job = Job("", 0, 0, None, "", 0)
    job.globalTempDir = jsonJob[0] 
    job.remainingRetryCount = jsonJob[1] 
    job.colour = jsonJob[2] 
    job.parentJobFile = jsonJob[3] 
    job.issuedChildCount = jsonJob[4] 
    job.completedChildCount = jsonJob[5] 
    job.childCommandsToIssue = jsonJob[6] 
    job.followOnCommandsToIssue = jsonJob[7] 
    job.messages = jsonJob[8] 
    return job

class Job:
    #Colours for job
    blue = 0
    black = 1
    grey = 2
    red = 3
    dead = 4
    
    @staticmethod
    def translateColourToString(colour):
        colours = { Job.blue:"blue", 
                   Job.black:"black", Job.grey:"grey", 
                   Job.red:"red", Job.dead:"dead" }
        return colours[colour]
    
    def __init__(self, command, memory, cpu, parentJobFile, globalTempDir, retryCount):
        self.globalTempDir = globalTempDir
        self.remainingRetryCount = retryCount
        self.colour = Job.grey
        self.parentJobFile = parentJobFile
        self.issuedChildCount = 0
        self.completedChildCount = 0
        self.childCommandsToIssue = []
        self.followOnCommandsToIssue = []
        self.messages = []
        self.addFollowOnCommand((command, memory, cpu))
    
    def write(self, jobFile):
        fileHandle = open(jobFile, 'w')
        pickler.dump(convertToJobToJson(self), fileHandle)
        fileHandle.close() 
    
    def getJobFileName(self):
        return getJobFileName(self.globalTempDir)
      
    def getLogFileName(self):
        return os.path.join(self.globalTempDir, "log.txt")
        
    def getGlobalTempDirName(self):
        return self.globalTempDir
        
    def getJobStatsFileName(self):
        return getJobStatsFileName(self.globalTempDir)
    
    def getRemainingRetryCount(self):
        return self.remainingRetryCount
    
    def setRemainingRetryCount(self, remainingRetryCount):
        self.remainingRetryCount = remainingRetryCount
    
    def getParentJobFile(self):
        return self.parentJobFile
    
    def getIssuedChildCount(self):
{'fraction_non_alphanumeric': 0.09130009775171065, 'fraction_numerical': 0.005083088954056696, 'mean_word_length': 2.5776223776223777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5576034', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1530, 'n_words': 302}