Beispiel #1
0
    def __init__(self, proceedings=None, task=None, timeStamp=None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.
        If both are given, the object is created by ignoring the last two input entries.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if (proceedings == None and (task == None and timeStamp == None)):
            raise IOError(
                "In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given."
            )
        if proceedings:
            if (not isinstance(proceedings, Proceedings)):
                raise IOError("The given input was not of type Proceedings")
            self.__proceedings = proceedings
        elif task and timeStamp:
            if ((not isinstance(task, Task))
                    or (not isinstance(timeStamp, str))):
                raise IOError(
                    "The given Task was not of correct type, or the timestamp")
            self.__proceedings = Proceedings(task, timeStamp)
        self.__ResultingFileDict = {}
    def __init__(self, proceedings = None, task = None, timeStamp = None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.
        If both are given, the object is created by ignoring the last two input entries.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if (proceedings == None and (task == None and timeStamp == None)):
            raise IOError("In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given.")
        if proceedings:
            if (not isinstance(proceedings,Proceedings)):
                raise IOError("The given input was not of type Proceedings")
            self.__proceedings = proceedings
        elif task and timeStamp:
            if ((not isinstance(task,Task)) or (not isinstance(timeStamp,str))):
                raise IOError("The given Task was not of correct type, or the timestamp")
            self.__proceedings = Proceedings(task,timeStamp)
        self.__ResultingFileDict = {}
Beispiel #3
0
    def __init__(self, proceedings=None, task=None, timeStamp=None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if proceedings:
            self.__proceedings = proceedings
        elif task and timeStamp:
            self.__proceedings = Proceedings(task, timeStamp)
        else:
            raise IOError(
                "In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given."
            )
        self.__ResultingFileDict = {}
Beispiel #4
0
    def __init__(self, proceedings = None, task = None, timeStamp = None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if proceedings:
            self.__proceedings = proceedings
        elif task and timeStamp:
            self.__proceedings = Proceedings(task,timeStamp)
        else:
            raise IOError("In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given.")
        self.__ResultingFileDict = {}
Beispiel #5
0
 def test_ProceedingsToXMLWriter(self):
     """
     Testing the correctness of the ProceedingsToXMLWriter class.
     The following test cases are covered:
     1. Calling a ProceedingsToXMLWriter with a wrong parameter
        1.a None
        1.b an integer value
     2. Calling the ProceedintsToXMLWriter with a correct parameter
     """
     wrtr = ProceedingsToXMLWriter()
     #1.a
     strRepresentation = wrtr.createXMLFromProceedings(None)
     self.assertEqual(strRepresentation, None)
     #1.b
     strRepresentation = wrtr.createXMLFromProceedings(1)
     self.assertEqual(strRepresentation, None)
     #2
     prcdngs = Proceedings(self.testTask, self.testTimeStamp)
     strRepresentation = wrtr.createXMLFromProceedings(prcdngs).toxml()
     expectedOutput = "<?xml version=\"1.0\" ?><proceedings><timestamp>201405161350</timestamp><task>PrettyTestTask</task><waiting><entry><probleminstance>PI1</probleminstance><computeralgebrasystem>cas1</computeralgebrasystem></entry><entry><probleminstance>PI1</probleminstance><computeralgebrasystem>cas2</computeralgebrasystem></entry><entry><probleminstance>PI1</probleminstance><computeralgebrasystem>cas3</computeralgebrasystem></entry><entry><probleminstance>PI1</probleminstance><computeralgebrasystem>cas4</computeralgebrasystem></entry><entry><probleminstance>PI2</probleminstance><computeralgebrasystem>cas1</computeralgebrasystem></entry><entry><probleminstance>PI2</probleminstance><computeralgebrasystem>cas2</computeralgebrasystem></entry><entry><probleminstance>PI2</probleminstance><computeralgebrasystem>cas3</computeralgebrasystem></entry><entry><probleminstance>PI2</probleminstance><computeralgebrasystem>cas4</computeralgebrasystem></entry><entry><probleminstance>PI3</probleminstance><computeralgebrasystem>cas1</computeralgebrasystem></entry><entry><probleminstance>PI3</probleminstance><computeralgebrasystem>cas2</computeralgebrasystem></entry><entry><probleminstance>PI3</probleminstance><computeralgebrasystem>cas3</computeralgebrasystem></entry><entry><probleminstance>PI3</probleminstance><computeralgebrasystem>cas4</computeralgebrasystem></entry><entry><probleminstance>PI4</probleminstance><computeralgebrasystem>cas1</computeralgebrasystem></entry><entry><probleminstance>PI4</probleminstance><computeralgebrasystem>cas2</computeralgebrasystem></entry><entry><probleminstance>PI4</probleminstance><computeralgebrasystem>cas3</computeralgebrasystem></entry><entry><probleminstance>PI4</probleminstance><computeralgebrasystem>cas4</computeralgebrasystem></entry></waiting><running/><completed/><error/></proceedings>"
     self.assertEqual(
         expectedOutput, strRepresentation,
         "Output of XML-file did not match what we wanted to have")
class ResultedTimings(object):
    """
    This is a decorator class of the Proceedings class. It provides to every entry in the
    Proceedings lists an extra entry, namely an ResultingFile-Instance, if existent.

    .. seealso:: :mod:`Proceedings <sdeval.classes.results.Proceedings>`
    .. moduleauthor:: Albert Heinle <*****@*****.**>
    """

    def __init__(self, proceedings = None, task = None, timeStamp = None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.
        If both are given, the object is created by ignoring the last two input entries.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if (proceedings == None and (task == None and timeStamp == None)):
            raise IOError("In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given.")
        if proceedings:
            if (not isinstance(proceedings,Proceedings)):
                raise IOError("The given input was not of type Proceedings")
            self.__proceedings = proceedings
        elif task and timeStamp:
            if ((not isinstance(task,Task)) or (not isinstance(timeStamp,str))):
                raise IOError("The given Task was not of correct type, or the timestamp")
            self.__proceedings = Proceedings(task,timeStamp)
        self.__ResultingFileDict = {}

    def getTask(self):
        """
        Returns the name of the task of these proceedings.

        :returns: The name of the task of this ResultedTimings instance
        :rtype:   string
        """
        return self.__proceedings.getTask()

    def getTimeStamp(self):
        """
        Returns the timestamp of the calculations that are run.

        :returns: A the time stamp of the proceedings
        :rtype:   string
        """
        return self.__proceedings.getTimeStamp()

    def getProceedings(self):
        """
        Returns the Proceedings instance we are decorating here.

        :returns: The underlying Proceedings instance
        :rtype:   Proceedings
        """
        return self.__proceedings

    # def setProceedings(self,pr):
    #     """
    #     Updates the decorated instance of Proceedings.
    #     In case when there is an entry in the ResultingFileDictionary,
    #     whose key is not in this updated Proceedings instance, a ValueError
    #     is raised. This ValueError is also raised, if the input is not an
    #     instance of Proceedings.

    #     :param pr: An instance of Proceedings
    #     :type  pr: Proceedings
    #     :
    #     """
    #     if (not type(pr)==Proceedings):
    #         raise ValueError("Input was not of type Proceedings.")
    #     for i in pr.getCOMPLETED()
    #         if (not (str(i) in self.__ResultingFileDict)):
    #             raise ValueError("Updating Proceedings impossible. Incompatible data.")
    #     for i in pr.getERROR()
    #         if (not (str(i) in self.__ResultingFileDict)):
    #             raise ValueError("Updating Proceedings impossible. Incompatible data.")
    #     self.__proceedings = pr
            

    def getResultingFileDict(self):
        """
        Returns the dictionary with the saved timings.

        :returns: The internal dictionary with the saved timings
        :rtype:   dictionary
        """
        return self.__ResultingFileDict

    def getRUNNING(self):
        """
        Returns the currently running computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x+[None], self.__proceedings.getRUNNING())

    def getWAITING(self):
        """
        Returns the currently waiting computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x+[None], self.__proceedings.getWAITING())

    def getCOMPLETED(self):
        """
        Returns the completed computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None] if str(x) not in self.__ResultingFileDict
               else x + [self.__ResultingFileDict[str(x)]],self.__proceedings.getCOMPLETED())

    def getERROR(self):
        """
        Returns the computations that were causing an error.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None] if str(x) not in self.__ResultingFileDict
               else x+ [self.__ResultingFileDict[str(x)]],self.__proceedings.getERROR())

    def setRUNNING(self, tuple):
        """
        Adds a tuple to the list of currently running computations. It is assumed that the tuple is
        contained in the WAITING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        self.__proceedings.setRUNNING(tuple[:2])

    def setCOMPLETED(self,tuple,timings):
        """
        Adds a tuple to the list of completed computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param   tuple: A tuple of the form (problem instance, computer algebra system)
        :type    tuple: list
        :param timings: The resulted times from the computations
        :type  timings: dict
        """
        self.__proceedings.setCOMPLETED(tuple[:2])
        self.__ResultingFileDict[str(tuple[:2])] = timings

    def setERROR(self, tuple, timings):
        """
        Adds a tuple to the list of erroneous computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        if tuple[:2] in self.__proceedings.getRUNNING():
            self.__proceedings.setERROR(tuple[:2])
            self.__ResultingFileDict[str(tuple[:2])] = timings
Beispiel #7
0
class ResultedTimings(object):
    """
    This is a decorator class of the Proceedings class. It provides to every entry in the
    Proceedings lists an extra entry, namely an ResultingFile-Instance, if existent.

    .. seealso:: :mod:`Proceedings <sdeval.classes.results.Proceedings>`
    .. moduleauthor:: Albert Heinle <*****@*****.**>
    """

    def __init__(self, proceedings = None, task = None, timeStamp = None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if proceedings:
            self.__proceedings = proceedings
        elif task and timeStamp:
            self.__proceedings = Proceedings(task,timeStamp)
        else:
            raise IOError("In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given.")
        self.__ResultingFileDict = {}

    def getTask(self):
        """
        Returns the name of the task of these proceedings.

        :returns: The name of the task of this ResultedTimings instance
        :rtype:   string
        """
        return self.__proceedings.getTask()

    def getTimeStamp(self):
        """
        Returns the timestamp of the calculations that are run.

        :returns: A the time stamp of the proceedings
        :rtype:   string
        """
        return self.__proceedings.getTimeStamp()

    def getProceedings(self):
        """
        Returns the Proceedings instance we are decorating here.

        :returns: The underlying Proceedings instance
        :rtype:   Proceedings
        """
        return self.__proceedings

    def getResultingFileDict(self):
        """
        Returns the dictionary with the saved timings.

        :returns: The internal dictionary with the saved timings
        :rtype:   dictionary
        """
        return self.__ResultingFileDict

    def getRUNNING(self):
        """
        Returns the currently running computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x+[None], self.__proceedings.getRUNNING())

    def getWAITING(self):
        """
        Returns the currently waiting computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x+[None], self.__proceedings.getWAITING())

    def getCOMPLETED(self):
        """
        Returns the completed computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None] if str(x) not in self.__ResultingFileDict
               else x + [self.__ResultingFileDict[str(x)]],self.__proceedings.getCOMPLETED())

    def getERROR(self):
        """
        Returns the computations that were causing an error.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None] if str(x) not in self.__ResultingFileDict
               else x+ [self.__ResultingFileDict[str(x)]],self.__proceedings.getERROR())

    def setRUNNING(self, tuple):
        """
        Adds a tuple to the list of currently running computations. It is assumed that the tuple is
        contained in the WAITING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        self.__proceedings.setRUNNING(tuple[:2])

    def setCOMPLETED(self,tuple,timings):
        """
        Adds a tuple to the list of completed computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param   tuple: A tuple of the form (problem instance, computer algebra system)
        :type    tuple: list
        :param timings: The resulted times from the computations
        :type  timings: dict
        """
        self.__proceedings.setCOMPLETED(tuple[:2])
        self.__ResultingFileDict[str(tuple[:2])] = timings
Beispiel #8
0
class ResultedTimings(object):
    """
    This is a decorator class of the Proceedings class. It provides to every entry in the
    Proceedings lists an extra entry, namely an ResultingFile-Instance, if existent.

    .. seealso:: :mod:`Proceedings <sdeval.classes.results.Proceedings>`
    .. moduleauthor:: Albert Heinle <*****@*****.**>
    """
    def __init__(self, proceedings=None, task=None, timeStamp=None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.
        If both are given, the object is created by ignoring the last two input entries.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if (proceedings == None and (task == None and timeStamp == None)):
            raise IOError(
                "In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given."
            )
        if proceedings:
            if (not isinstance(proceedings, Proceedings)):
                raise IOError("The given input was not of type Proceedings")
            self.__proceedings = proceedings
        elif task and timeStamp:
            if ((not isinstance(task, Task))
                    or (not isinstance(timeStamp, str))):
                raise IOError(
                    "The given Task was not of correct type, or the timestamp")
            self.__proceedings = Proceedings(task, timeStamp)
        self.__ResultingFileDict = {}

    def getTask(self):
        """
        Returns the name of the task of these proceedings.

        :returns: The name of the task of this ResultedTimings instance
        :rtype:   string
        """
        return self.__proceedings.getTask()

    def getTimeStamp(self):
        """
        Returns the timestamp of the calculations that are run.

        :returns: A the time stamp of the proceedings
        :rtype:   string
        """
        return self.__proceedings.getTimeStamp()

    def getProceedings(self):
        """
        Returns the Proceedings instance we are decorating here.

        :returns: The underlying Proceedings instance
        :rtype:   Proceedings
        """
        return self.__proceedings

    # def setProceedings(self,pr):
    #     """
    #     Updates the decorated instance of Proceedings.
    #     In case when there is an entry in the ResultingFileDictionary,
    #     whose key is not in this updated Proceedings instance, a ValueError
    #     is raised. This ValueError is also raised, if the input is not an
    #     instance of Proceedings.

    #     :param pr: An instance of Proceedings
    #     :type  pr: Proceedings
    #     :
    #     """
    #     if (not type(pr)==Proceedings):
    #         raise ValueError("Input was not of type Proceedings.")
    #     for i in pr.getCOMPLETED()
    #         if (not (str(i) in self.__ResultingFileDict)):
    #             raise ValueError("Updating Proceedings impossible. Incompatible data.")
    #     for i in pr.getERROR()
    #         if (not (str(i) in self.__ResultingFileDict)):
    #             raise ValueError("Updating Proceedings impossible. Incompatible data.")
    #     self.__proceedings = pr

    def getResultingFileDict(self):
        """
        Returns the dictionary with the saved timings.

        :returns: The internal dictionary with the saved timings
        :rtype:   dictionary
        """
        return self.__ResultingFileDict

    def getRUNNING(self):
        """
        Returns the currently running computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None], self.__proceedings.getRUNNING())

    def getWAITING(self):
        """
        Returns the currently waiting computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None], self.__proceedings.getWAITING())

    def getCOMPLETED(self):
        """
        Returns the completed computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(
            lambda x: x + [None] if str(x) not in self.__ResultingFileDict else
            x + [self.__ResultingFileDict[str(x)]],
            self.__proceedings.getCOMPLETED())

    def getERROR(self):
        """
        Returns the computations that were causing an error.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(
            lambda x: x + [None] if str(x) not in self.__ResultingFileDict else
            x + [self.__ResultingFileDict[str(x)]],
            self.__proceedings.getERROR())

    def setRUNNING(self, tuple):
        """
        Adds a tuple to the list of currently running computations. It is assumed that the tuple is
        contained in the WAITING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        self.__proceedings.setRUNNING(tuple[:2])

    def setCOMPLETED(self, tuple, timings):
        """
        Adds a tuple to the list of completed computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param   tuple: A tuple of the form (problem instance, computer algebra system)
        :type    tuple: list
        :param timings: The resulted times from the computations
        :type  timings: dict
        """
        self.__proceedings.setCOMPLETED(tuple[:2])
        self.__ResultingFileDict[str(tuple[:2])] = timings

    def setERROR(self, tuple, timings):
        """
        Adds a tuple to the list of erroneous computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        if tuple[:2] in self.__proceedings.getRUNNING():
            self.__proceedings.setERROR(tuple[:2])
            self.__ResultingFileDict[str(tuple[:2])] = timings
Beispiel #9
0
 def test_Proceedings(self):
     """
     This tests checks the correctness of the Proceedings class. The following tests are covered:
     1. Creation of Proceedings with None as the task (fail)
     2. Creation of Proceedings with an integer as task (fail)
     3. Creation of Proceedings with None as timestamp (fail)
     4. Creation of Proceedings with an integer as timestamp (fail)
     5. Correct initialization of the proceedings
        5.1. Test the initial set
        5.2. Test the getters
        5.3. Test setRunning with incorrect value
        5.4. Test setRunning with correct value
        5.5. Test setCompleted with incorrect value
        5.6. Test setCompleted with correct value
        5.7. Test setERROR with incorrect value
        5.8. Test setERROR with correct value.
     """
     #1.
     testPassed =1
     try:
         prcdngs = Proceedings(None, self.testTimeStamp)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with no Task")
     #2.
     try:
         prcdngs = Proceedings(1, self.testTimeStamp)
         testPassed = 0
     except:
         pass
     if (testPassed ==0):
         self.fail("Could create Proceedings with 1 as Task")
     #3.
     try:
         prcdngs = Proceedings(self.testTask, None)
         testPassed = 0
     except:
         pass
     if (testPassed==0):
         self.fail("Could create Proceedings with None as timestamp")
     #4.
     try:
         prcdngs = Proceedings(self.testTask, 1)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with 1 as timestamp")
     #5.
     prcdngs = Proceedings(self.testTask, self.testTimeStamp)
     #5.1
     self.assertEqual(len(prcdngs.getWAITING()),16,"Number of waiting processes was not correct")
     self.assertEqual(prcdngs.getRUNNING(),[],"Running processes initially wrong")
     self.assertEqual(prcdngs.getCOMPLETED(),[],"Completed processes initially wrong")
     self.assertEqual(prcdngs.getERROR(),[], "Erroneous processes initially wrong")
     #5.2
     self.assertEqual(prcdngs.getTask(), self.testTask.getName(), "Initialization with wrong task performed")
     self.assertEqual(prcdngs.getTimeStamp(), self.testTimeStamp, "Initialization with wrong timeStamp")
     #5.3
     prcdngs.setRUNNING("abc")
     self.assertEqual(len(prcdngs.getWAITING()),16,"invalid setRunning changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(),[],"invalid setRunning changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(),[],"invalid setRunning changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[], "invalid setRunning changed ERROR list.")
     #5.4
     prcdngs.setRUNNING(["PI1","cas1"])
     self.assertEqual(len(prcdngs.getWAITING()),15,"setRunning changed WAITING list wrongly.")
     self.assertEqual(prcdngs.getRUNNING(),[["PI1","cas1"]],"setRunning did not affect RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(),[],"setRunning changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[], "setRunning changed ERROR list.")
     #5.5
     prcdngs.setCOMPLETED("abc")
     self.assertEqual(len(prcdngs.getWAITING()),15,"invalid setCompleted changed WAITING list wrongly.")
     self.assertEqual(prcdngs.getRUNNING(),[["PI1","cas1"]],"invalid setCompleted changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(),[],"invalid setCompleted changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[], "invalid setCompleted changed ERROR list.")
     #5.6
     prcdngs.setCOMPLETED(["PI1","cas1"])
     self.assertEqual(len(prcdngs.getWAITING()),15,"setCompleted changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(),[],"setCompleted changed RUNNING list wrongly.")
     self.assertEqual(prcdngs.getCOMPLETED(),[["PI1","cas1"]],"setCompleted did not change COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[], "setCompleted changed ERROR list.")
     #5.7
     prcdngs.setERROR(["PI1","cas1"])
     self.assertEqual(len(prcdngs.getWAITING()),15,"invalid setERROR changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(),[],"invalid setERROR changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(),[["PI1","cas1"]],"invalid setERROR changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[], "invalid serERROR changed ERROR list.")
     #5.8
     prcdngs.setRUNNING(["PI2","cas1"])
     prcdngs.setERROR(["PI2", "cas1"])
     self.assertEqual(len(prcdngs.getWAITING()),14,"setERROR changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(),[],"setERROR changed RUNNING list wrongly.")
     self.assertEqual(prcdngs.getCOMPLETED(),[["PI1","cas1"]],"setERROR changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(),[["PI2", "cas1"]], "setERROR changed ERROR list wrongly.")
Beispiel #10
0
 def test_Proceedings(self):
     """
     This tests checks the correctness of the Proceedings class. The following tests are covered:
     1. Creation of Proceedings with None as the task (fail)
     2. Creation of Proceedings with an integer as task (fail)
     3. Creation of Proceedings with None as timestamp (fail)
     4. Creation of Proceedings with an integer as timestamp (fail)
     5. Correct initialization of the proceedings
        5.1. Test the initial set
        5.2. Test the getters
        5.3. Test setRunning with incorrect value
        5.4. Test setRunning with correct value
        5.5. Test setCompleted with incorrect value
        5.6. Test setCompleted with correct value
        5.7. Test setERROR with incorrect value
        5.8. Test setERROR with correct value.
     """
     #1.
     testPassed = 1
     try:
         prcdngs = Proceedings(None, self.testTimeStamp)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with no Task")
     #2.
     try:
         prcdngs = Proceedings(1, self.testTimeStamp)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with 1 as Task")
     #3.
     try:
         prcdngs = Proceedings(self.testTask, None)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with None as timestamp")
     #4.
     try:
         prcdngs = Proceedings(self.testTask, 1)
         testPassed = 0
     except:
         pass
     if (testPassed == 0):
         self.fail("Could create Proceedings with 1 as timestamp")
     #5.
     prcdngs = Proceedings(self.testTask, self.testTimeStamp)
     #5.1
     self.assertEqual(len(prcdngs.getWAITING()), 16,
                      "Number of waiting processes was not correct")
     self.assertEqual(prcdngs.getRUNNING(), [],
                      "Running processes initially wrong")
     self.assertEqual(prcdngs.getCOMPLETED(), [],
                      "Completed processes initially wrong")
     self.assertEqual(prcdngs.getERROR(), [],
                      "Erroneous processes initially wrong")
     #5.2
     self.assertEqual(prcdngs.getTask(), self.testTask.getName(),
                      "Initialization with wrong task performed")
     self.assertEqual(prcdngs.getTimeStamp(), self.testTimeStamp,
                      "Initialization with wrong timeStamp")
     #5.3
     prcdngs.setRUNNING("abc")
     self.assertEqual(len(prcdngs.getWAITING()), 16,
                      "invalid setRunning changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(), [],
                      "invalid setRunning changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(), [],
                      "invalid setRunning changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [],
                      "invalid setRunning changed ERROR list.")
     #5.4
     prcdngs.setRUNNING(["PI1", "cas1"])
     self.assertEqual(len(prcdngs.getWAITING()), 15,
                      "setRunning changed WAITING list wrongly.")
     self.assertEqual(prcdngs.getRUNNING(), [["PI1", "cas1"]],
                      "setRunning did not affect RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(), [],
                      "setRunning changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [],
                      "setRunning changed ERROR list.")
     #5.5
     prcdngs.setCOMPLETED("abc")
     self.assertEqual(len(prcdngs.getWAITING()), 15,
                      "invalid setCompleted changed WAITING list wrongly.")
     self.assertEqual(prcdngs.getRUNNING(), [["PI1", "cas1"]],
                      "invalid setCompleted changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(), [],
                      "invalid setCompleted changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [],
                      "invalid setCompleted changed ERROR list.")
     #5.6
     prcdngs.setCOMPLETED(["PI1", "cas1"])
     self.assertEqual(len(prcdngs.getWAITING()), 15,
                      "setCompleted changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(), [],
                      "setCompleted changed RUNNING list wrongly.")
     self.assertEqual(prcdngs.getCOMPLETED(), [["PI1", "cas1"]],
                      "setCompleted did not change COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [],
                      "setCompleted changed ERROR list.")
     #5.7
     prcdngs.setERROR(["PI1", "cas1"])
     self.assertEqual(len(prcdngs.getWAITING()), 15,
                      "invalid setERROR changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(), [],
                      "invalid setERROR changed RUNNING list.")
     self.assertEqual(prcdngs.getCOMPLETED(), [["PI1", "cas1"]],
                      "invalid setERROR changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [],
                      "invalid serERROR changed ERROR list.")
     #5.8
     prcdngs.setRUNNING(["PI2", "cas1"])
     prcdngs.setERROR(["PI2", "cas1"])
     self.assertEqual(len(prcdngs.getWAITING()), 14,
                      "setERROR changed WAITING list.")
     self.assertEqual(prcdngs.getRUNNING(), [],
                      "setERROR changed RUNNING list wrongly.")
     self.assertEqual(prcdngs.getCOMPLETED(), [["PI1", "cas1"]],
                      "setERROR changed COMPLETED list.")
     self.assertEqual(prcdngs.getERROR(), [["PI2", "cas1"]],
                      "setERROR changed ERROR list wrongly.")
Beispiel #11
0
    def test_ProceedingsToHTMLWriter(self):
        """
        Testing the correctness of the ProceedingsToHTMLWriter class.
        The following test cases are covered:
        1. Calling a ProceedingsToHTMLWriter with a wrong parameter
           1.a None
           1.b an integer value
        2. Calling the ProceedingsToHTMLWriter with a correct parameter
        """
        wrtr = ProceedingsToHTMLWriter()
        #1.a
        strRepresentation = wrtr.createHTMLFromProceedings(None)
        self.assertEqual(strRepresentation, None)
        #1.b
        strRepresentation = wrtr.createHTMLFromProceedings(1)
        self.assertEqual(strRepresentation, None)
        #2
        prcdngs = Proceedings(self.testTask, self.testTimeStamp)
        expectedOutput = "<html>\n\
<head>\n\
\t<title>PrettyTestTask run at 201405161350</title>\n\
\t<link rel=\"stylesheet\" type=\"text/css\" href=\"proceedings_css.css\">\n\
</head>\n\
<body>\n\
<h1> Task: PrettyTestTask </h1>\n\
<h2> Run at time: 201405161350 </h2>\n\
<br><br>\n\
<table id=\"mainTable\">\n\
\t<tr>\n\
\t\t<td id=\"piAndCAS\"> Problem Instance/Computer Algebra System</td>\n\
\t\t<td id=\"casName\">cas4</td>\n\
\t\t<td id=\"casName\">cas1</td>\n\
\t\t<td id=\"casName\">cas3</td>\n\
\t\t<td id=\"casName\">cas2</td>\n\
\t</tr>\n\
\t<tr>\n\
\t\t<td id=\"piName\">PI1</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t</tr>\n\
\t<tr>\n\
\t\t<td id=\"piName\">PI2</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t</tr>\n\
\t<tr>\n\
\t\t<td id=\"piName\">PI3</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t</tr>\n\
\t<tr>\n\
\t\t<td id=\"piName\">PI4</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t\t<td id=\"waitingCalc\">WAITING</td>\n\
\t</tr>\n\
</table>\n\
</body>\n\
</html>"

        self.assertEqual(wrtr.createHTMLFromProceedings(prcdngs),
                         expectedOutput, "HTML representation was wrong")
    def build(self, xmlRaw, task):
        """
        Returns an instance of Proceedings, given an xml-string and an instance of the associated task.
        The given string is assumed to have the following form::

          <proceedings>
            <timestamp>
              "The timestamp"
            </timestamp>
            <task>
              "the name of the executed task"
            </task>
            <running>
              <entry>
                <probleminstance>
                  "A problem instance"
                </probleminstance>
                <computeralgebrasystem>
                  "A computer algebra system"
                </computeralgebrasystem>
              </entry>
            </running>
            <waiting>
              "same as running"
            </waiting>
            <completed>
              "same as running"
            </completed>
            <error>
              "same as running"
            </error>
          </proceedings>

        An IOError is raised if the XML instance was not valid.
        
        :param    xmlRaw: The xml-representation of the proceedings.
        :type     xmlRaw: string
        :param    task: The task associated to the given proceedings instance.
        :type     task: Task
        :returns: An instance of the Proceedings class
        :rtype:   Proceedings
        """
        try:
            xmlTree = dom.parseString(xmlRaw)
        except:
            raise IOError("Could not parse the given string as XML-Instance")
        try:
            timeStamp = str((xmlTree.getElementsByTagName("timestamp")[0]
                             ).firstChild.data).strip()
        except:
            raise IOError("Given XML instance did not have a timestamp entry")
        result = Proceedings(task, timeStamp)
        try:
            completedCalculations = xmlTree.getElementsByTagName(
                "completed")[0]
            erroneousCalculations = xmlTree.getElementsByTagName("error")[0]
        except:
            raise IOError(
                "Could not find entries for completed resp. erroneous computations"
            )
        #First dealing with all the completed calculations
        tempEntry = completedCalculations.firstChild
        while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
            tempEntry = tempEntry.nextSibling
        while tempEntry != None:
            try:
                cas = str(
                    (tempEntry.getElementsByTagName("computeralgebrasystem")[0]
                     ).firstChild.data).strip()
                pi = str((tempEntry.getElementsByTagName("probleminstance")[0]
                          ).firstChild.data).strip()
            except:
                raise IOError(
                    "The entries in the list of completed calculations are not valid"
                )
            result.setRUNNING([pi, cas])
            result.setCOMPLETED([pi, cas])
            tempEntry = tempEntry.nextSibling
            while (tempEntry != None
                   and tempEntry.nodeType == dom.Node.TEXT_NODE):
                tempEntry = tempEntry.nextSibling
        #Now dealing with the erroneous calculations
        tempEntry = erroneousCalculations.firstChild
        while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
            tempEntry = tempEntry.nextSibling
        while tempEntry != None:
            try:
                cas = str(
                    (tempEntry.getElementsByTagName("computeralgebrasystem")[0]
                     ).firstChild.data).strip()
                pi = str((tempEntry.getElementsByTagName("probleminstance")[0]
                          ).firstChild.data).strip()
            except:
                raise IOError(
                    "The entries in the list of erroneous computations were not valid."
                )
            result.setRUNNING([pi, cas])
            result.setERROR([pi, cas])
            tempEntry = tempEntry.nextSibling
            while (tempEntry != None
                   and tempEntry.nodeType == dom.Node.TEXT_NODE):
                tempEntry = tempEntry.nextSibling
        return result
Beispiel #13
0
class ResultedTimings(object):
    """
    This is a decorator class of the Proceedings class. It provides to every entry in the
    Proceedings lists an extra entry, namely an ResultingFile-Instance, if existent.

    .. seealso:: :mod:`Proceedings <sdeval.classes.results.Proceedings>`
    .. moduleauthor:: Albert Heinle <*****@*****.**>
    """
    def __init__(self, proceedings=None, task=None, timeStamp=None):
        """
        This is the constructor of the ResultedTimings-Class. Either a proceedings instance is given and
        this will be used then, or a new Proceedings instance is generated given the task and the timeStamp.

        :param proceedings: The proceedings instance we want to decorate
        :type  proceedings: Proceedings
        :param      task: The task we want to create the Proceedings instance of
        :type       task: Task
        :param timeStamp: The timestamp of the execution of the task
        :type  timeStamp: string
        :raise   IOError: If neither a Proceedings instance nor a task or a timeStamp is given
        """
        if proceedings:
            self.__proceedings = proceedings
        elif task and timeStamp:
            self.__proceedings = Proceedings(task, timeStamp)
        else:
            raise IOError(
                "In ResultedTimings constructor: Neither proceedings, nor a tuple of task and a timestamp are given."
            )
        self.__ResultingFileDict = {}

    def getTask(self):
        """
        Returns the name of the task of these proceedings.

        :returns: The name of the task of this ResultedTimings instance
        :rtype:   string
        """
        return self.__proceedings.getTask()

    def getTimeStamp(self):
        """
        Returns the timestamp of the calculations that are run.

        :returns: A the time stamp of the proceedings
        :rtype:   string
        """
        return self.__proceedings.getTimeStamp()

    def getProceedings(self):
        """
        Returns the Proceedings instance we are decorating here.

        :returns: The underlying Proceedings instance
        :rtype:   Proceedings
        """
        return self.__proceedings

    def getResultingFileDict(self):
        """
        Returns the dictionary with the saved timings.

        :returns: The internal dictionary with the saved timings
        :rtype:   dictionary
        """
        return self.__ResultingFileDict

    def getRUNNING(self):
        """
        Returns the currently running computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None], self.__proceedings.getRUNNING())

    def getWAITING(self):
        """
        Returns the currently waiting computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(lambda x: x + [None], self.__proceedings.getWAITING())

    def getCOMPLETED(self):
        """
        Returns the completed computations.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(
            lambda x: x + [None] if str(x) not in self.__ResultingFileDict else
            x + [self.__ResultingFileDict[str(x)]],
            self.__proceedings.getCOMPLETED())

    def getERROR(self):
        """
        Returns the computations that were causing an error.

        :returns: A list of tuples of problem instances and computer algebra systems.
        :rtype:   list
        """
        return map(
            lambda x: x + [None] if str(x) not in self.__ResultingFileDict else
            x + [self.__ResultingFileDict[str(x)]],
            self.__proceedings.getERROR())

    def setRUNNING(self, tuple):
        """
        Adds a tuple to the list of currently running computations. It is assumed that the tuple is
        contained in the WAITING list, otherwise this function does nothing.

        :param tuple: A tuple of the form (problem instance, computer algebra system)
        :type  tuple: list
        """
        self.__proceedings.setRUNNING(tuple[:2])

    def setCOMPLETED(self, tuple, timings):
        """
        Adds a tuple to the list of completed computations. It is assumed that the tuple is
        contained in the RUNNING list, otherwise this function does nothing.

        :param   tuple: A tuple of the form (problem instance, computer algebra system)
        :type    tuple: list
        :param timings: The resulted times from the computations
        :type  timings: dict
        """
        self.__proceedings.setCOMPLETED(tuple[:2])
        self.__ResultingFileDict[str(tuple[:2])] = timings
    def build(self, xmlRaw, task):
        """
        Returns an instance of Proceedings, given an xml-string and an instance of the associated task.
        The given string is assumed to have the following form::

          <proceedings>
            <timestamp>
              "The timestamp"
            </timestamp>
            <task>
              "the name of the executed task"
            </task>
            <running>
              <entry>
                <probleminstance>
                  "A problem instance"
                </probleminstance>
                <computeralgebrasystem>
                  "A computer algebra system"
                </computeralgebrasystem>
              </entry>
            </running>
            <waiting>
              "same as running"
            </waiting>
            <completed>
              "same as running"
            </completed>
            <error>
              "same as running"
            </error>
          </proceedings>

        An IOError is raised if the XML instance was not valid.
        
        :param    xmlRaw: The xml-representation of the proceedings.
        :type     xmlRaw: string
        :param    task: The task associated to the given proceedings instance.
        :type     task: Task
        :returns: An instance of the Proceedings class
        :rtype:   Proceedings
        """
        try:
            xmlTree = dom.parseString(xmlRaw)
        except:
            raise IOError("Could not parse the given string as XML-Instance")
        try:
            timeStamp = str((xmlTree.getElementsByTagName("timestamp")[0]).firstChild.data).strip()
        except:
            raise IOError("Given XML instance did not have a timestamp entry")
        result = Proceedings(task,timeStamp)
        try:
            completedCalculations = xmlTree.getElementsByTagName("completed")[0]
            erroneousCalculations   = xmlTree.getElementsByTagName("error")[0]
        except:
            raise IOError("Could not find entries for completed resp. erroneous computations")
        #First dealing with all the completed calculations
        tempEntry = completedCalculations.firstChild
        while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
            tempEntry = tempEntry.nextSibling
        while tempEntry != None:
            try:
                cas = str((tempEntry.getElementsByTagName("computeralgebrasystem")[0]).firstChild.data).strip()
                pi  = str((tempEntry.getElementsByTagName("probleminstance")[0]).firstChild.data).strip()
            except:
                raise IOError("The entries in the list of completed calculations are not valid")
            result.setRUNNING([pi,cas])
            result.setCOMPLETED([pi,cas])
            tempEntry = tempEntry.nextSibling
            while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
                tempEntry = tempEntry.nextSibling
        #Now dealing with the erroneous calculations
        tempEntry = erroneousCalculations.firstChild
        while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
            tempEntry = tempEntry.nextSibling
        while tempEntry != None:
            try:
                cas = str((tempEntry.getElementsByTagName("computeralgebrasystem")[0]).firstChild.data).strip()
                pi  = str((tempEntry.getElementsByTagName("probleminstance")[0]).firstChild.data).strip()
            except:
                raise IOError("The entries in the list of erroneous computations were not valid.")
            result.setRUNNING([pi,cas])
            result.setERROR([pi,cas])
            tempEntry = tempEntry.nextSibling
            while (tempEntry != None and tempEntry.nodeType == dom.Node.TEXT_NODE):
                tempEntry = tempEntry.nextSibling
        return result