1 """
2 User-defined cores
3
4 XXX TODO: Revise this to have events before module replayed.
5 """
6
7
8
9
10
11
12
13 import os
14
15 from gavo import base
16 from gavo import rsc
17 from gavo import rscdef
18 from gavo import utils
19 from gavo.svcs import core
20
21
23
24
25 typeDesc = "resdir-relative path to a module; no extension is allowed"
26
27 - def feed(self, ctx, instance, modName):
33
34
36 """A wrapper around a core defined in a module.
37
38 This core lets you write your own cores in modules.
39
40 The module must define a class Core. When the custom core is
41 encountered, this class will be instanciated and will be used
42 instead of the CustomCore, so your code should probably inherit
43 core.Core.
44
45 See `Writing Custom Cores`_ for details.
46 """
47 name_ = "customCore"
48
49 _module = ModuleAttribute("module", default=base.Undefined,
50 description="Path to the module containing the core definition.")
51
52
54 """A definition of a pythonCore's functionalty.
55
56 This is a procApp complete with setup and code; you could inherit
57 between these.
58
59 coreProcs see the embedding service, the input table passed, and the
60 query metadata as service, inputTable, and queryMeta, respectively.
61
62 The core itself is available as self.
63 """
64 name_ = "coreProc"
65 requiredType = "coreProc"
66 formalArgs = "self, service, inputTable, queryMeta"
67
68 additionalNamesForProcs = {
69 "rsc": rsc
70 }
71
72
74 """A core doing computation using a piece of python.
75
76 See `Python Cores instead of Custom Cores`_ in the reference.
77 """
78 name_ = "pythonCore"
79
80 _computer = base.StructAttribute("coreProc", default=base.Undefined,
81 childFactory=CoreProc,
82 description="Code making the outputTable from the inputTable.",
83 copyable=True)
84
90
91 - def run(self, service, inputTable, queryMeta):
92 return self.coreProc.compile()(self, service, inputTable, queryMeta)
93