database.py 735 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy

from collections import namedtuple

from beat.backend.python.database import View


class FooView(View):
    def setup(
        self,
        root_folder,
        outputs,
        parameters,
        force_start_index=None,
        force_end_index=None,
    ):
        """Initializes the database"""

        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)}