jaseci 1.4.2.5__py3-none-any.whl → 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of jaseci might be problematic. Click here for more details.

Files changed (186) hide show
  1. jaseci/__init__.py +3 -37
  2. jaseci-2.0.0.dist-info/METADATA +65 -0
  3. jaseci-2.0.0.dist-info/RECORD +4 -0
  4. {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
  5. jaseci/VERSION +0 -1
  6. jaseci/cli_tools/__init__.py +0 -0
  7. jaseci/cli_tools/book_tools.py +0 -457
  8. jaseci/cli_tools/jsctl.py +0 -500
  9. jaseci/cli_tools/tests/__init__.py +0 -0
  10. jaseci/cli_tools/tests/test_jsctl.py +0 -556
  11. jaseci/extens/__init__.py +0 -0
  12. jaseci/extens/act_lib/__init__.py +0 -0
  13. jaseci/extens/act_lib/date.py +0 -117
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -76
  16. jaseci/extens/act_lib/file_handler.py +0 -189
  17. jaseci/extens/act_lib/internal.py +0 -18
  18. jaseci/extens/act_lib/jaseci.py +0 -61
  19. jaseci/extens/act_lib/mail.py +0 -10
  20. jaseci/extens/act_lib/maths.py +0 -168
  21. jaseci/extens/act_lib/net.py +0 -191
  22. jaseci/extens/act_lib/rand.py +0 -82
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -169
  25. jaseci/extens/act_lib/std.py +0 -235
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -337
  28. jaseci/extens/act_lib/task.py +0 -13
  29. jaseci/extens/act_lib/tests/__init__.py +0 -0
  30. jaseci/extens/act_lib/tests/std_test_code.py +0 -37
  31. jaseci/extens/act_lib/tests/test_date.py +0 -26
  32. jaseci/extens/act_lib/tests/test_elastic.py +0 -159
  33. jaseci/extens/act_lib/tests/test_file.py +0 -116
  34. jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
  35. jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
  36. jaseci/extens/act_lib/tests/test_maths.py +0 -147
  37. jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
  38. jaseci/extens/act_lib/tests/test_regex.py +0 -61
  39. jaseci/extens/act_lib/tests/test_std.py +0 -51
  40. jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
  41. jaseci/extens/act_lib/tests/test_url.py +0 -32
  42. jaseci/extens/act_lib/tests/test_vector.py +0 -36
  43. jaseci/extens/act_lib/tests/test_webtool.py +0 -44
  44. jaseci/extens/act_lib/tests/test_zlib.py +0 -24
  45. jaseci/extens/act_lib/url.py +0 -79
  46. jaseci/extens/act_lib/vector.py +0 -157
  47. jaseci/extens/act_lib/webtool.py +0 -28
  48. jaseci/extens/act_lib/zip.py +0 -33
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -170
  51. jaseci/extens/api/alias_api.py +0 -139
  52. jaseci/extens/api/architype_api.py +0 -196
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -84
  55. jaseci/extens/api/graph_api.py +0 -167
  56. jaseci/extens/api/health_api.py +0 -20
  57. jaseci/extens/api/interface.py +0 -268
  58. jaseci/extens/api/jac_api.py +0 -171
  59. jaseci/extens/api/jsorc_api.py +0 -316
  60. jaseci/extens/api/logger_api.py +0 -89
  61. jaseci/extens/api/master_api.py +0 -133
  62. jaseci/extens/api/object_api.py +0 -101
  63. jaseci/extens/api/prometheus_api.py +0 -74
  64. jaseci/extens/api/queue_api.py +0 -140
  65. jaseci/extens/api/sentinel_api.py +0 -270
  66. jaseci/extens/api/super_api.py +0 -64
  67. jaseci/extens/api/tests/__init__.py +0 -0
  68. jaseci/extens/api/tests/test_architype_api.py +0 -66
  69. jaseci/extens/api/tests/test_global_api.py +0 -179
  70. jaseci/extens/api/tests/test_graph_api.py +0 -64
  71. jaseci/extens/api/tests/test_logger_api.py +0 -43
  72. jaseci/extens/api/tests/test_object_api.py +0 -20
  73. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  74. jaseci/extens/api/tests/test_uncommon.py +0 -107
  75. jaseci/extens/api/tests/test_user_api.py +0 -32
  76. jaseci/extens/api/tests/test_walker_api.py +0 -316
  77. jaseci/extens/api/user_api.py +0 -144
  78. jaseci/extens/api/walker_api.py +0 -298
  79. jaseci/extens/api/webhook_api.py +0 -74
  80. jaseci/extens/svc/__init__.py +0 -0
  81. jaseci/extens/svc/elastic_svc.py +0 -366
  82. jaseci/extens/svc/kube_svc.py +0 -432
  83. jaseci/extens/svc/mail_svc.py +0 -156
  84. jaseci/extens/svc/prome_svc.py +0 -378
  85. jaseci/extens/svc/redis_svc.py +0 -63
  86. jaseci/extens/svc/storage_svc.py +0 -193
  87. jaseci/extens/svc/stripe_svc.py +0 -51
  88. jaseci/extens/svc/task_svc.py +0 -155
  89. jaseci/extens/svc/tasks.py +0 -302
  90. jaseci/jac/__init__.py +0 -0
  91. jaseci/jac/interpreter/__init__.py +0 -0
  92. jaseci/jac/interpreter/architype_interp.py +0 -214
  93. jaseci/jac/interpreter/interp.py +0 -1783
  94. jaseci/jac/interpreter/sentinel_interp.py +0 -257
  95. jaseci/jac/interpreter/tests/__init__.py +0 -0
  96. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  97. jaseci/jac/interpreter/walker_interp.py +0 -248
  98. jaseci/jac/ir/__init__.py +0 -0
  99. jaseci/jac/ir/ast.py +0 -73
  100. jaseci/jac/ir/ast_builder.py +0 -249
  101. jaseci/jac/ir/jac_code.py +0 -152
  102. jaseci/jac/ir/passes/__init__.py +0 -6
  103. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  104. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  105. jaseci/jac/ir/passes/ir_pass.py +0 -29
  106. jaseci/jac/ir/passes/printer_pass.py +0 -23
  107. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  108. jaseci/jac/ir/passes/schedule.py +0 -23
  109. jaseci/jac/ir/passes/stats_pass.py +0 -16
  110. jaseci/jac/jac.g4 +0 -450
  111. jaseci/jac/jac_parse/__init__.py +0 -0
  112. jaseci/jac/jac_parse/jacLexer.py +0 -809
  113. jaseci/jac/jac_parse/jacListener.py +0 -853
  114. jaseci/jac/jac_parse/jacParser.py +0 -9192
  115. jaseci/jac/jac_set.py +0 -119
  116. jaseci/jac/jsci_vm/__init__.py +0 -0
  117. jaseci/jac/jsci_vm/disasm.py +0 -94
  118. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  119. jaseci/jac/jsci_vm/machine.py +0 -188
  120. jaseci/jac/jsci_vm/op_codes.py +0 -82
  121. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  122. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  123. jaseci/jac/machine/__init__.py +0 -0
  124. jaseci/jac/machine/jac_scope.py +0 -85
  125. jaseci/jac/machine/jac_value.py +0 -226
  126. jaseci/jac/machine/machine_state.py +0 -383
  127. jaseci/jac/tests/__init__.py +0 -0
  128. jaseci/jac/tests/book_code.py +0 -624
  129. jaseci/jac/tests/test_book.py +0 -380
  130. jaseci/jac/tests/test_lang_14.py +0 -49
  131. jaseci/jsorc/__init__.py +0 -7
  132. jaseci/jsorc/jsorc.py +0 -642
  133. jaseci/jsorc/jsorc_settings.py +0 -211
  134. jaseci/jsorc/jsorc_utils.py +0 -298
  135. jaseci/jsorc/live_actions.py +0 -364
  136. jaseci/jsorc/manifests/__init__.py +0 -0
  137. jaseci/jsorc/manifests/database.yaml +0 -109
  138. jaseci/jsorc/manifests/elastic.yaml +0 -6024
  139. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  140. jaseci/jsorc/manifests/redis.yaml +0 -64
  141. jaseci/jsorc/memory.py +0 -258
  142. jaseci/jsorc/redis.py +0 -139
  143. jaseci/jsorc/remote_actions.py +0 -157
  144. jaseci/jsorc/tests/__init__.py +0 -0
  145. jaseci/jsorc/tests/test_actions.py +0 -542
  146. jaseci/jsorc/tests/test_jsorc.py +0 -112
  147. jaseci/prim/__init__.py +0 -0
  148. jaseci/prim/ability.py +0 -93
  149. jaseci/prim/architype.py +0 -89
  150. jaseci/prim/edge.py +0 -172
  151. jaseci/prim/element.py +0 -233
  152. jaseci/prim/graph.py +0 -26
  153. jaseci/prim/master.py +0 -64
  154. jaseci/prim/node.py +0 -532
  155. jaseci/prim/obj_mixins.py +0 -235
  156. jaseci/prim/sentinel.py +0 -281
  157. jaseci/prim/super_master.py +0 -31
  158. jaseci/prim/walker.py +0 -261
  159. jaseci/svc/__init__.py +0 -0
  160. jaseci/tests/__init__.py +0 -0
  161. jaseci/tests/infer.py +0 -39
  162. jaseci/tests/jac_test_code.py +0 -1293
  163. jaseci/tests/jac_test_progs.py +0 -774
  164. jaseci/tests/test_core.py +0 -153
  165. jaseci/tests/test_jac.py +0 -824
  166. jaseci/tests/test_node.py +0 -89
  167. jaseci/tests/test_progs.py +0 -702
  168. jaseci/tests/test_stack.py +0 -220
  169. jaseci/tests/test_stripe.py +0 -225
  170. jaseci/utils/__init__.py +0 -0
  171. jaseci/utils/actions/__init__.py +0 -0
  172. jaseci/utils/actions/actions_manager.py +0 -254
  173. jaseci/utils/actions/actions_optimizer.py +0 -516
  174. jaseci/utils/actions/actions_state.py +0 -95
  175. jaseci/utils/file_handler.py +0 -171
  176. jaseci/utils/gprof2dot.py +0 -3786
  177. jaseci/utils/id_list.py +0 -168
  178. jaseci/utils/json_handler.py +0 -70
  179. jaseci/utils/log_utils.py +0 -57
  180. jaseci/utils/test_core.py +0 -62
  181. jaseci/utils/utils.py +0 -387
  182. jaseci-1.4.2.5.dist-info/LICENSE +0 -21
  183. jaseci-1.4.2.5.dist-info/METADATA +0 -39
  184. jaseci-1.4.2.5.dist-info/RECORD +0 -184
  185. jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
  186. jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
jaseci/prim/obj_mixins.py DELETED
@@ -1,235 +0,0 @@
1
- """
2
- Jaseci object mixins
3
-
4
- Various mixins to define properties of Jaseci objects
5
- """
6
- from jaseci.utils.id_list import IdList
7
- from jaseci.utils.utils import logger
8
- import uuid
9
-
10
-
11
- class Anchored:
12
- """Utility class for objects that hold anchor values"""
13
-
14
- arch_map = {}
15
-
16
- def __init__(self):
17
- self.context = {}
18
-
19
- def get_architype(self):
20
- arch = self.get_arch_from_cache() # Optimization
21
- if arch and id(arch._h) == id(self._h):
22
- return arch
23
- arch = (
24
- self._h._machine.parent().get_arch_for(self)
25
- if self._h._machine is not None
26
- and self._h._machine.parent() is not None
27
- and self._h._machine.parent().j_type == "sentinel"
28
- else None
29
- )
30
- mast = self.get_master()
31
- if arch is None and mast.active_snt() is not None:
32
- arch = mast.active_snt().get_arch_for(self)
33
- elif arch is None and self.parent() and self.parent().j_type == "sentinel":
34
- arch = self.parent().get_arch_for(self)
35
- self.cache_arch(arch)
36
- return arch
37
-
38
- def cache_arch(self, arch):
39
- Anchored.arch_map[self.kind + self.name] = arch
40
-
41
- def get_arch_from_cache(self):
42
- if (self.kind + self.name) in Anchored.arch_map:
43
- return Anchored.arch_map[self.kind + self.name]
44
- return None
45
-
46
- def flush_cache():
47
- Anchored.arch_map = {}
48
-
49
- def anchor_value(self):
50
- """Returns value of anchor context object"""
51
- arch = self.get_architype()
52
- if arch is not None:
53
- anch = arch.anchor_var
54
- if anch and anch in self.context.keys():
55
- return self.context[anch]
56
- return None
57
-
58
- def private_values(self):
59
- """Returns value of anchor context object"""
60
- arch = self.get_architype()
61
- if arch is not None:
62
- return arch.private_vars
63
- return []
64
-
65
- def set_context(self, ctx):
66
- """Assign values to context fields of object"""
67
- for i in ctx.keys():
68
- if i in self.get_architype().has_vars:
69
- self.context[i] = ctx[i]
70
- else:
71
- logger.warning(str(f"{i} not a context member of {self}"))
72
- self.save()
73
-
74
-
75
- class Sharable:
76
- """Utility class for objects that are sharable between users"""
77
-
78
- def __init__(self, m_id, mode=None, **kwargs):
79
- self.set_master(m_id)
80
- self.j_access = (
81
- mode
82
- if mode is not None
83
- else self._h.get_obj(self._m_id, self._m_id).perm_default
84
- if self._h.has_obj(self._m_id)
85
- else "private"
86
- )
87
- self.j_r_acc_ids = IdList(self)
88
- self.j_rw_acc_ids = IdList(self)
89
-
90
- @property
91
- def _m_id(self) -> str:
92
- return self.j_master
93
-
94
- def set_master(self, m_id):
95
- if not m_id:
96
- m_id = uuid.UUID(int=0).urn
97
- self.j_master = m_id
98
-
99
- def make_public(self):
100
- """Make element publically accessible"""
101
- self.j_access = "public"
102
- self.save()
103
-
104
- def make_read_only(self):
105
- """Make element publically readable"""
106
- self.j_access = "read_only"
107
- self.save()
108
-
109
- def make_private(self):
110
- """Make element private"""
111
- self.j_access = "private"
112
- self.save()
113
-
114
- def is_public(self):
115
- """Check if element is publically accessible"""
116
- return self.j_access == "public" or self.j_master == uuid.UUID(int=0).urn
117
-
118
- def is_read_only(self):
119
- """Check if element is publically readable"""
120
- return self.j_access == "read_only"
121
-
122
- def is_readable(self):
123
- """Check if element is publically readable"""
124
- return self.j_access == "read_only" or self.is_public()
125
-
126
- def is_private(self):
127
- """Check if element is private"""
128
- return self.j_access == "private"
129
-
130
- def super_check(self, caller_id):
131
- """Quick check if caller is super master"""
132
- if not hasattr(self, "_h"):
133
- return False
134
- user = self._h.get_obj(caller_id, caller_id, override=True)
135
- if user.j_type == "super_master":
136
- return True
137
- return False
138
-
139
- def check_read_access(self, caller_id, silent=False):
140
- if (
141
- caller_id == self._m_id
142
- or self.is_readable()
143
- or caller_id in self.j_r_acc_ids
144
- or caller_id in self.j_rw_acc_ids
145
- or self.super_check(caller_id)
146
- ):
147
- return True
148
- if not silent:
149
- logger.error(str(f"{caller_id} does not have permission to access {self}"))
150
- return False
151
-
152
- def check_write_access(self, caller_id, silent=False):
153
- if (
154
- caller_id == self._m_id
155
- or self.is_public()
156
- or caller_id in self.j_rw_acc_ids
157
- or self.super_check(caller_id)
158
- ):
159
- return True
160
- if not silent:
161
- logger.error(str(f"{caller_id} does not have permission to access {self}"))
162
- return False
163
-
164
- def give_access(self, m, read_only=True):
165
- """Give access to a master (user)"""
166
- if not m.is_master():
167
- logger.error(f"{m} is not master!")
168
- return False
169
- if read_only and m.jid not in self.j_r_acc_ids:
170
- self.j_r_acc_ids.add_obj(m)
171
- elif m.jid not in self.j_rw_acc_ids:
172
- self.j_rw_acc_ids.add_obj(m)
173
- return True
174
-
175
- def remove_access(self, m):
176
- """Remove access from a master (user)"""
177
- ret = False
178
- if m.jid in self.j_r_acc_ids:
179
- self.j_r_acc_ids.remove_obj(m)
180
- ret = True
181
- if m.jid in self.j_rw_acc_ids:
182
- self.j_rw_acc_ids.remove_obj(m)
183
- ret = True
184
- return ret
185
-
186
-
187
- class Hookable(Sharable):
188
- """Utility class for objects that are savable to DBs and other stores"""
189
-
190
- def __init__(self, h, persist: bool = True, parent=None, **kwargs):
191
- self._h = h # hook for storing and loading to persistent store
192
- self._persist = persist
193
- self.j_parent = parent.jid if parent else None # member of
194
- Sharable.__init__(self, **kwargs)
195
-
196
- def check_hooks_match(self, target, silent=False):
197
- """Checks whether target object hook matches self's hook"""
198
- if not self._m_id or not target._m_id:
199
- return True
200
- elif not silent and target._h != self._h:
201
- logger.critical(
202
- str(
203
- "Hook for {} does not match {}, {} != {}".format(
204
- target, self, target._h, self._h
205
- )
206
- )
207
- )
208
- return target._h == self._h
209
-
210
- def make_persistent(self):
211
- """Make element persistent"""
212
- self._persist = True
213
- self.save()
214
-
215
- def save(self):
216
- """
217
- Write self through hook to persistent storage
218
- """
219
- self._h.save_obj(self._m_id, self)
220
-
221
- def destroy(self):
222
- """
223
- Destroys self from persistent storage
224
-
225
- Note that the object will still exist in python until GC'd
226
- """
227
- self._h.destroy_obj(self._m_id, self)
228
- del self
229
-
230
- def parent(self):
231
- """
232
- Returns the objects for list of owners of this element
233
- """
234
- if self.j_parent:
235
- return self._h.get_obj(self._m_id, self.j_parent)
jaseci/prim/sentinel.py DELETED
@@ -1,281 +0,0 @@
1
- """
2
- Sentinel class for Jaseci
3
-
4
- Each sentinel has an id, name, timestamp and it's set of walkers.
5
- """
6
- from jaseci.prim.element import Element
7
- from jaseci.prim.obj_mixins import Anchored
8
- from jaseci.utils.utils import (
9
- logger,
10
- ColCodes as Cc,
11
- is_true,
12
- perf_test_start,
13
- perf_test_stop,
14
- )
15
- from jaseci.utils.id_list import IdList
16
- from jaseci.jac.ir.jac_code import JacCode, jac_ir_to_ast
17
- from jaseci.jac.interpreter.sentinel_interp import SentinelInterp
18
- from jaseci.prim.walker import Walker
19
- from jaseci.prim.architype import Architype
20
-
21
-
22
- class Sentinel(Element, JacCode, SentinelInterp):
23
- """
24
- Sentinel class for Jaseci
25
-
26
- is_active is used to signify whether sentinel is ready to run walkers, i.e,
27
- register_code succeeded
28
- """
29
-
30
- def __init__(self, *args, **kwargs):
31
- self.version = None
32
- self.arch_ids = IdList(self)
33
- self.global_vars = {}
34
- self.testcases = []
35
- Element.__init__(self, *args, **kwargs)
36
- JacCode.__init__(self, code_ir=None)
37
- SentinelInterp.__init__(self)
38
-
39
- def reset(self):
40
- """Resets state of sentinel and unregister's code"""
41
- self.version = None
42
- self.global_vars = {}
43
- self.testcases = []
44
- self.arch_ids.destroy_all()
45
- JacCode.reset(self)
46
- SentinelInterp.reset(self)
47
- Anchored.flush_cache()
48
-
49
- def refresh(self):
50
- super().refresh()
51
- self.ir_load()
52
-
53
- def register_code(self, text, dir="./", mode="default", opt_level=4):
54
- """
55
- Registers a program (set of walkers and architypes) written in Jac
56
- """
57
- self.reset()
58
- if mode == "ir":
59
- self.apply_ir(text)
60
- else:
61
- self.register(text, dir, opt_level=opt_level)
62
- if self.is_active:
63
- self.ir_load()
64
- return self.is_active
65
-
66
- def load_arch_defaults(self):
67
- self.arch_ids.add_obj(
68
- Architype(m_id=self._m_id, h=self._h, name="root", kind="node", parent=self)
69
- )
70
- self.arch_ids.add_obj(
71
- Architype(
72
- m_id=self._m_id, h=self._h, name="generic", kind="node", parent=self
73
- )
74
- )
75
- self.arch_ids.add_obj(
76
- Architype(
77
- m_id=self._m_id, h=self._h, name="generic", kind="edge", parent=self
78
- )
79
- )
80
-
81
- def ir_load(self):
82
- """
83
- Load walkers and architypes from IR
84
- """
85
- self.load_arch_defaults()
86
- self.run_start(self._jac_ast)
87
-
88
- if self.runtime_errors:
89
- logger.error(str(f"{self.name}: Runtime problem processing sentinel!"))
90
- self.is_active = False
91
- elif not self.arch_ids:
92
- logger.error(str(f"{self.name}: No walkers nor architypes created!"))
93
- self.is_active = False
94
- return self.is_active
95
-
96
- def register_architype(self, code, opt_level=4):
97
- """Adds an architype based on jac code"""
98
- tree = self.compile_jac(
99
- code, dir="./", start_rule="architype", opt_level=opt_level
100
- )
101
- if not tree:
102
- return None
103
- return self.load_architype(tree)
104
-
105
- def spawn_architype(self, name, kind=None, caller=None, is_async=None):
106
- """
107
- Spawns a new architype from registered architypes and adds to
108
- live walkers
109
- """
110
- src_arch = self.arch_ids.get_obj_by_name(name, kind=kind, silent=True)
111
- if not src_arch:
112
- logger.error(str(f"{self.name}: Unable to spawn {kind} architype {name}!"))
113
- return None
114
- src_arch.is_async = src_arch.is_async if is_async is None else is_true(is_async)
115
- if caller and caller._m_id != src_arch._m_id:
116
- new_arch = src_arch.duplicate()
117
- new_arch.set_master(caller._m_id)
118
- new_arch._jac_ast = src_arch._jac_ast
119
- if new_arch._jac_ast is None:
120
- new_arch.refresh()
121
- return new_arch
122
- else:
123
- return src_arch
124
-
125
- def run_architype(self, name, kind=None, caller=None, is_async=None):
126
- """
127
- Spawn, run, then destroy architype if m_id's are different
128
- """
129
- if caller is None:
130
- caller = self
131
- arch = self.spawn_architype(name, kind, caller, is_async)
132
- if arch is None:
133
- logger.error(
134
- str(f"{self.name}: Unable to spawn architype " f"{[name, kind]}!")
135
- )
136
- return None
137
- if arch.jid in self.arch_ids:
138
- return arch.run()
139
- else:
140
- ret = arch.run()
141
- Element.destroy(arch)
142
- return ret
143
-
144
- def get_arch_for(self, obj):
145
- """Returns the architype that matches object"""
146
- ret = self.arch_ids.get_obj_by_name(name=obj.name, kind=obj.kind)
147
- if ret is None:
148
- self.rt_subtle_error(
149
- f"Unable to find architype for {obj.name}, {obj.kind}",
150
- self._cur_jac_ast,
151
- )
152
- return ret
153
-
154
- def run_tests(self, specific=None, profiling=False, detailed=False, silent=False):
155
- """
156
- Testcase schema
157
- testcase = {
158
- "name": kid[1].token_text() if kid[1].name == "NAME" else "",
159
- "title": kid[2].token_text()
160
- if kid[1].name == "NAME"
161
- else kid[1].token_text(),
162
- "graph_ref": None,
163
- "graph_block": None,
164
- "walker_ref": None,
165
- "spawn_ctx": None,
166
- "assert_block": None,
167
- "walker_block": None,
168
- "outcome": None,
169
- }
170
- """
171
- from pprint import pformat
172
- from time import time
173
- import sys
174
- import io
175
-
176
- num_failed = 0
177
- num_tests = 0
178
- for i in self.testcases:
179
- if specific is not None and i["name"] != specific:
180
- continue
181
- num_tests += 1
182
- screen_out = [sys.stdout, sys.stderr]
183
- buff_out = [io.StringIO(), io.StringIO()]
184
- destroy_set = []
185
- title = i["title"]
186
- if i["graph_ref"]:
187
- gph = self.run_architype(i["graph_ref"], kind="graph", caller=self)
188
- else:
189
- gph = Architype(
190
- m_id=self._m_id,
191
- h=self._h,
192
- parent=self,
193
- code_ir=jac_ir_to_ast(i["graph_block"]),
194
- )
195
- destroy_set.append(gph)
196
- gph = gph.run()
197
- if i["walker_ref"]:
198
- wlk = self.run_architype(
199
- name=i["walker_ref"], kind="walker", caller=self
200
- )
201
- else:
202
- wlk = Walker(
203
- m_id=self._m_id,
204
- h=self._h,
205
- parent=self,
206
- code_ir=jac_ir_to_ast(i["walker_block"]),
207
- )
208
- destroy_set.append(wlk)
209
- wlk.prime(gph)
210
- if i["spawn_ctx"]:
211
- self.run_spawn_ctx(jac_ir_to_ast(i["spawn_ctx"]), wlk)
212
-
213
- stime = time()
214
- if profiling:
215
- pr = perf_test_start()
216
- try:
217
- if not silent:
218
- print(f"Testing {title}: ", end="")
219
- sys.stdout, sys.stderr = buff_out[0], buff_out[1]
220
- wlk.run()
221
- sys.stdout, sys.stderr = screen_out[0], screen_out[1]
222
- if i["assert_block"]:
223
- wlk._loop_ctrl = None
224
- wlk._jac_try_mode += 1
225
- wlk.scope_and_run(
226
- jac_ir_to_ast(i["assert_block"]),
227
- run_func=wlk.run_code_block,
228
- scope_name="assert_block",
229
- )
230
- wlk._jac_try_mode -= 1
231
- i["passed"] = True
232
- if not silent:
233
- print(
234
- f"[{Cc.TG}PASSED{Cc.EC} in {Cc.TY}{time()-stime:.2f}s{Cc.EC}]"
235
- )
236
- if detailed and not silent:
237
- print("REPORT: " + pformat(wlk.report))
238
- except Exception as e:
239
- sys.stdout, sys.stderr = screen_out[0], screen_out[1]
240
- i["passed"] = False
241
- num_failed += 1
242
- if not silent:
243
- print(
244
- f"[{Cc.TR}FAILED{Cc.EC} in {Cc.TY}{time()-stime:.2f}s{Cc.EC}]"
245
- )
246
- print(f"{e}")
247
- for i in destroy_set: # FIXME: destroy set not complete
248
- i.destroy()
249
- if profiling:
250
- print(perf_test_stop(pr))
251
-
252
- summary = {
253
- "tests": num_tests,
254
- "passed": num_tests - num_failed,
255
- "failed": num_failed,
256
- "success": num_tests and not num_failed,
257
- }
258
- if detailed:
259
- details = []
260
- for i in self.testcases:
261
- if specific is not None and i["name"] != specific:
262
- continue
263
- details.append(
264
- {
265
- "test": i["title"],
266
- "passed": i["passed"],
267
- "stdout": buff_out[0].getvalue(),
268
- "stderr": buff_out[1].getvalue(),
269
- }
270
- )
271
- summary["details"] = details
272
- return summary
273
-
274
- def destroy(self):
275
- """
276
- Destroys self from memory and persistent storage
277
- """
278
- Anchored.flush_cache()
279
- for i in self.arch_ids.obj_list():
280
- i.destroy()
281
- super().destroy()
@@ -1,31 +0,0 @@
1
- """
2
- Super master handler for each user of Jaseci, serves as main interface between
3
- between user and Jaseci
4
- """
5
-
6
- from jaseci.extens.api.jsorc_api import JsOrcApi
7
- from jaseci.prim.master import Master
8
- from jaseci.extens.api.logger_api import LoggerApi
9
- from jaseci.extens.api.config_api import ConfigApi
10
- from jaseci.extens.api.global_api import GlobalApi
11
- from jaseci.extens.api.super_api import SuperApi
12
- from jaseci.extens.api.actions_api import ActionsApi
13
- from jaseci.extens.api.prometheus_api import PrometheusApi
14
- from jaseci.jsorc.jsorc import JsOrc
15
-
16
-
17
- @JsOrc.context(name="super_master")
18
- class SuperMaster(
19
- Master,
20
- LoggerApi,
21
- ActionsApi,
22
- ConfigApi,
23
- GlobalApi,
24
- SuperApi,
25
- JsOrcApi,
26
- PrometheusApi,
27
- ):
28
- """Master with admin APIs"""
29
-
30
- def __init__(self, *args, **kwargs):
31
- Master.__init__(self, *args, **kwargs)