def insert_result(self, result):
        """
        Insert a new result in the database.

        This function also verifies that the result dictionaries saved in the
        database have the following structure (with {'a': 1} representing a
        dictionary, 'a' a key and 1 its value)::

            {
                'params': {
                            'param1': value1,
                            'param2': value2,
                            ...
                            'RngRun': value3
                           },
                'meta': {
                          'elapsed_time': value4,
                          'id': value5
                        }
            }

        Where elapsed time is a float representing the seconds the simulation
        execution took, and id is a UUID uniquely identifying the result, and
        which is used to locate the output files in the campaign_dir/data
        folder.
        """

        # This dictionary serves as a model for how the keys in the newly
        # inserted result should be structured.
        example_result = {
            'params': {k: ['...'] for k in self.get_params() + ['RngRun']},
            'meta': {k: ['...'] for k in ['elapsed_time', 'id']},
        }

        # Verify result format is correct
        if not(DatabaseManager.have_same_structure(result, example_result)):
            raise ValueError(
                '%s:\nExpected: %s\nGot: %s' % (
                    "Result dictionary does not correspond to database format",
                    pformat(example_result, depth=1),
                    pformat(result, depth=1)))

        # Insert result
        self.db.table('results').insert(result)
def insert_result ( self , result ) : example_result = { 'params' : { k : [ '...' ] for k in self . get_params ( ) + [ 'RngRun' ] } , 'meta' : { k : [ '...' ] for k in [ 'elapsed_time' , 'id' ] } , } if not ( DatabaseManager . have_same_structure ( result , example_result ) ) : raise ValueError ( '%s:\nExpected: %s\nGot: %s' % ( "Result dictionary does not correspond to database format" , pformat ( example_result , depth = 1 ) , pformat ( result , depth = 1 ) ) ) self . db . table ( 'results' ) . insert ( result )
Insert a new result in the database.

        This function also verifies that the result dictionaries saved in the
        database have the following structure (with {'a': 1} representing a
        dictionary, 'a' a key and 1 its value)::

            {
                'params': {
                            'param1': value1,
                            'param2': value2,
                            ...
                            'RngRun': value3
                           },
                'meta': {
                          'elapsed_time': value4,
                          'id': value5
                        }
            }

        Where elapsed time is a float representing the seconds the simulation
        execution took, and id is a UUID uniquely identifying the result, and
        which is used to locate the output files in the campaign_dir/data
        folder.