database.py 879 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
import numpy

from collections import namedtuple

from beat.backend.python.database import View


class FooView(View):
    def setup(
10
        self, root_folder, outputs, parameters, start_index=None, end_index=None,
11 12 13
    ):
        """Initializes the database"""

14 15 16 17 18
        #  DO NOT REMOVE: this is required to setup the view internal state
        super().setup(root_folder, outputs, parameters, start_index, end_index)

        #  Add custom setup code here

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
        return True

    def index(self, root_folder, parameters):
        """Creates the data for the database indexation"""

        Entry = namedtuple("Entry", ["out"])

        return [Entry(42)]

    def get(self, output, index):
        """Returns the data for the output based on the index content"""

        obj = self.objs[index]

        if output == "out":
            return {"value": numpy.int32(obj.out)}