jaseci 1.4.2.6__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 (187) 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.6.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 -118
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -77
  16. jaseci/extens/act_lib/file_handler.py +0 -190
  17. jaseci/extens/act_lib/internal.py +0 -19
  18. jaseci/extens/act_lib/jaseci.py +0 -62
  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 -192
  22. jaseci/extens/act_lib/rand.py +0 -83
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -170
  25. jaseci/extens/act_lib/std.py +0 -236
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -338
  28. jaseci/extens/act_lib/task.py +0 -14
  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 -80
  46. jaseci/extens/act_lib/vector.py +0 -158
  47. jaseci/extens/act_lib/webtool.py +0 -29
  48. jaseci/extens/act_lib/zip.py +0 -34
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -171
  51. jaseci/extens/api/alias_api.py +0 -140
  52. jaseci/extens/api/architype_api.py +0 -197
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -85
  55. jaseci/extens/api/graph_api.py +0 -168
  56. jaseci/extens/api/health_api.py +0 -21
  57. jaseci/extens/api/interface.py +0 -269
  58. jaseci/extens/api/jac_api.py +0 -172
  59. jaseci/extens/api/jsorc_api.py +0 -317
  60. jaseci/extens/api/logger_api.py +0 -90
  61. jaseci/extens/api/master_api.py +0 -134
  62. jaseci/extens/api/object_api.py +0 -102
  63. jaseci/extens/api/prometheus_api.py +0 -75
  64. jaseci/extens/api/queue_api.py +0 -141
  65. jaseci/extens/api/sentinel_api.py +0 -271
  66. jaseci/extens/api/share_api.py +0 -64
  67. jaseci/extens/api/super_api.py +0 -65
  68. jaseci/extens/api/tests/__init__.py +0 -0
  69. jaseci/extens/api/tests/test_architype_api.py +0 -66
  70. jaseci/extens/api/tests/test_global_api.py +0 -179
  71. jaseci/extens/api/tests/test_graph_api.py +0 -64
  72. jaseci/extens/api/tests/test_logger_api.py +0 -43
  73. jaseci/extens/api/tests/test_object_api.py +0 -20
  74. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  75. jaseci/extens/api/tests/test_uncommon.py +0 -107
  76. jaseci/extens/api/tests/test_user_api.py +0 -32
  77. jaseci/extens/api/tests/test_walker_api.py +0 -316
  78. jaseci/extens/api/user_api.py +0 -166
  79. jaseci/extens/api/walker_api.py +0 -299
  80. jaseci/extens/api/webhook_api.py +0 -77
  81. jaseci/extens/svc/__init__.py +0 -0
  82. jaseci/extens/svc/elastic_svc.py +0 -366
  83. jaseci/extens/svc/kube_svc.py +0 -432
  84. jaseci/extens/svc/mail_svc.py +0 -156
  85. jaseci/extens/svc/prome_svc.py +0 -378
  86. jaseci/extens/svc/redis_svc.py +0 -63
  87. jaseci/extens/svc/storage_svc.py +0 -193
  88. jaseci/extens/svc/stripe_svc.py +0 -51
  89. jaseci/extens/svc/task_svc.py +0 -155
  90. jaseci/extens/svc/tasks.py +0 -302
  91. jaseci/jac/__init__.py +0 -0
  92. jaseci/jac/interpreter/__init__.py +0 -0
  93. jaseci/jac/interpreter/architype_interp.py +0 -219
  94. jaseci/jac/interpreter/interp.py +0 -1784
  95. jaseci/jac/interpreter/sentinel_interp.py +0 -260
  96. jaseci/jac/interpreter/tests/__init__.py +0 -0
  97. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  98. jaseci/jac/interpreter/walker_interp.py +0 -249
  99. jaseci/jac/ir/__init__.py +0 -0
  100. jaseci/jac/ir/ast.py +0 -73
  101. jaseci/jac/ir/ast_builder.py +0 -249
  102. jaseci/jac/ir/jac_code.py +0 -151
  103. jaseci/jac/ir/passes/__init__.py +0 -6
  104. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  105. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  106. jaseci/jac/ir/passes/ir_pass.py +0 -29
  107. jaseci/jac/ir/passes/printer_pass.py +0 -23
  108. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  109. jaseci/jac/ir/passes/schedule.py +0 -23
  110. jaseci/jac/ir/passes/stats_pass.py +0 -16
  111. jaseci/jac/jac.g4 +0 -450
  112. jaseci/jac/jac_parse/__init__.py +0 -0
  113. jaseci/jac/jac_parse/jacLexer.py +0 -809
  114. jaseci/jac/jac_parse/jacListener.py +0 -853
  115. jaseci/jac/jac_parse/jacParser.py +0 -9192
  116. jaseci/jac/jac_set.py +0 -120
  117. jaseci/jac/jsci_vm/__init__.py +0 -0
  118. jaseci/jac/jsci_vm/disasm.py +0 -94
  119. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  120. jaseci/jac/jsci_vm/machine.py +0 -188
  121. jaseci/jac/jsci_vm/op_codes.py +0 -82
  122. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  123. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  124. jaseci/jac/machine/__init__.py +0 -0
  125. jaseci/jac/machine/jac_scope.py +0 -86
  126. jaseci/jac/machine/jac_value.py +0 -227
  127. jaseci/jac/machine/machine_state.py +0 -386
  128. jaseci/jac/tests/__init__.py +0 -0
  129. jaseci/jac/tests/book_code.py +0 -624
  130. jaseci/jac/tests/test_book.py +0 -380
  131. jaseci/jac/tests/test_lang_14.py +0 -49
  132. jaseci/jsorc/__init__.py +0 -7
  133. jaseci/jsorc/jsorc.py +0 -642
  134. jaseci/jsorc/jsorc_settings.py +0 -211
  135. jaseci/jsorc/jsorc_utils.py +0 -298
  136. jaseci/jsorc/live_actions.py +0 -365
  137. jaseci/jsorc/manifests/__init__.py +0 -0
  138. jaseci/jsorc/manifests/database.yaml +0 -109
  139. jaseci/jsorc/manifests/elastic.yaml +0 -6029
  140. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  141. jaseci/jsorc/manifests/redis.yaml +0 -64
  142. jaseci/jsorc/memory.py +0 -258
  143. jaseci/jsorc/redis.py +0 -140
  144. jaseci/jsorc/remote_actions.py +0 -158
  145. jaseci/jsorc/tests/__init__.py +0 -0
  146. jaseci/jsorc/tests/test_actions.py +0 -542
  147. jaseci/jsorc/tests/test_jsorc.py +0 -112
  148. jaseci/prim/__init__.py +0 -0
  149. jaseci/prim/ability.py +0 -94
  150. jaseci/prim/architype.py +0 -90
  151. jaseci/prim/edge.py +0 -173
  152. jaseci/prim/element.py +0 -233
  153. jaseci/prim/graph.py +0 -27
  154. jaseci/prim/master.py +0 -67
  155. jaseci/prim/node.py +0 -533
  156. jaseci/prim/obj_mixins.py +0 -238
  157. jaseci/prim/sentinel.py +0 -282
  158. jaseci/prim/super_master.py +0 -31
  159. jaseci/prim/walker.py +0 -261
  160. jaseci/svc/__init__.py +0 -0
  161. jaseci/tests/__init__.py +0 -0
  162. jaseci/tests/infer.py +0 -39
  163. jaseci/tests/jac_test_code.py +0 -1293
  164. jaseci/tests/jac_test_progs.py +0 -774
  165. jaseci/tests/test_core.py +0 -153
  166. jaseci/tests/test_jac.py +0 -824
  167. jaseci/tests/test_node.py +0 -89
  168. jaseci/tests/test_progs.py +0 -702
  169. jaseci/tests/test_stack.py +0 -220
  170. jaseci/tests/test_stripe.py +0 -225
  171. jaseci/utils/__init__.py +0 -0
  172. jaseci/utils/actions/__init__.py +0 -0
  173. jaseci/utils/actions/actions_manager.py +0 -254
  174. jaseci/utils/actions/actions_optimizer.py +0 -517
  175. jaseci/utils/actions/actions_state.py +0 -95
  176. jaseci/utils/file_handler.py +0 -171
  177. jaseci/utils/gprof2dot.py +0 -3786
  178. jaseci/utils/id_list.py +0 -169
  179. jaseci/utils/json_handler.py +0 -70
  180. jaseci/utils/log_utils.py +0 -57
  181. jaseci/utils/test_core.py +0 -62
  182. jaseci/utils/utils.py +0 -387
  183. jaseci-1.4.2.6.dist-info/LICENSE +0 -21
  184. jaseci-1.4.2.6.dist-info/METADATA +0 -39
  185. jaseci-1.4.2.6.dist-info/RECORD +0 -185
  186. jaseci-1.4.2.6.dist-info/entry_points.txt +0 -3
  187. jaseci-1.4.2.6.dist-info/top_level.txt +0 -1
@@ -1,254 +0,0 @@
1
- from jaseci.jsorc.jsorc import JsOrc
2
- from jaseci.extens.svc.prome_svc import PrometheusService
3
- from jaseci.jsorc.live_actions import load_action_config
4
- from .actions_optimizer import ActionsOptimizer
5
-
6
- import time
7
- import numpy as np
8
-
9
-
10
- @JsOrc.context("action_manager")
11
- class ActionManager:
12
- def __init__(self):
13
- self.benchmark = {
14
- "jsorc": {"active": False, "requests": {}},
15
- "actions_optimizer": {"active": False, "requests": {}},
16
- }
17
- self.actions_history = {"active": False, "history": []}
18
- self.actions_calls = {}
19
- self.system_states = {"active": False, "states": []}
20
- self.actions_optimizer = ActionsOptimizer(
21
- benchmark=self.benchmark["actions_optimizer"],
22
- actions_history=self.actions_history,
23
- actions_calls=self.actions_calls,
24
- )
25
-
26
- ###################################################
27
- # ACTION MANAGER #
28
- ###################################################
29
-
30
- def load_action_config(self, config, name):
31
- """
32
- Load the config for an action
33
- """
34
- return load_action_config(config, name)
35
-
36
- def load_actions(self, name, mode):
37
- """
38
- Load an action as local, module or remote.
39
- """
40
- # Using module for local
41
- mode = "module" if mode == "local" else mode
42
-
43
- if mode == "module":
44
- self.actions_optimizer.load_action_module(name)
45
- elif mode == "remote":
46
- self.actions_optimizer.load_action_remote(name)
47
-
48
- def unload_actions(self, name, mode, retire_svc):
49
- """
50
- Unload an action
51
- """
52
- # We are using module for local
53
- mode = "module" if mode == "local" else mode
54
- if mode == "auto":
55
- res = self.actions_optimizer.unload_action_auto(name)
56
- if not res[0]:
57
- return res
58
- if retire_svc:
59
- self.retire_uservice(name)
60
- return res
61
- elif mode == "module":
62
- return self.actions_optimizer.unload_action_module(name)
63
- elif mode == "remote":
64
- res = self.actions_optimizer.unload_action_remote(name)
65
- if not res[0]:
66
- return res
67
- if retire_svc:
68
- self.retire_uservice(name)
69
- return res
70
- else:
71
- return (False, f"Unrecognized action mode {mode}.")
72
-
73
- def retire_uservice(self, name):
74
- """
75
- Retire a remote microservice for the action.
76
- """
77
- self.actions_optimizer.retire_remote(name)
78
-
79
- def get_actions_status(self, name=""):
80
- """
81
- Return the status of the action
82
- """
83
- return self.actions_optimizer.get_actions_status(name)
84
-
85
- def actions_tracking_start(self):
86
- """ """
87
- self.actions_history["active"] = True
88
- self.actions_history["history"] = [{"ts": time.time()}]
89
- self.actions_calls.clear()
90
-
91
- def actions_tracking_stop(self):
92
- """ """
93
- if not self.actions_history["active"]:
94
- return []
95
-
96
- self.actions_optimizer.summarize_action_calls()
97
-
98
- return self.actions_history["history"]
99
-
100
- def benchmark_start(self):
101
- """
102
- Put JSORC under benchmark mode.
103
- """
104
- self.benchmark["jsorc"]["active"] = True
105
- self.benchmark["jsorc"]["requests"] = {}
106
- self.benchmark["jsorc"]["start_ts"] = time.time()
107
-
108
- def state_tracking_start(self):
109
- """
110
- Ask JSORC to start tracking the state of the system as observed by JSORC on every interval.
111
- """
112
- self.system_states = {"active": True, "states": []}
113
-
114
- def state_tracking_stop(self):
115
- """
116
- Stop state tracking for JSORC
117
- """
118
- ret = self.system_states
119
- self.system_states = {"active": True, "states": []}
120
- return ret
121
-
122
- def state_tracking_report(self):
123
- """
124
- Return state tracking history so far
125
- """
126
- return self.system_states
127
-
128
- def record_system_state(self):
129
- """
130
- Record system state
131
- """
132
- if self.system_states["active"]:
133
- ts = int(time.time())
134
- prom_profile = (
135
- JsOrc.svc("prome")
136
- .poke(PrometheusService)
137
- .info(
138
- namespace=self.namespace,
139
- exclude_prom=True,
140
- timestamp=ts,
141
- duration=self.backoff_interval,
142
- )
143
- )
144
- self.system_states["states"].append(
145
- {
146
- "ts": ts,
147
- "actions": self.get_actions_status(name=""),
148
- "prometheus": prom_profile,
149
- }
150
- )
151
-
152
- def benchmark_stop(self, report):
153
- """
154
- Stop benchmark mode and report result during the benchmark period
155
- """
156
- if not self.benchmark["jsorc"]["active"]:
157
- return {}
158
-
159
- res = self.benchmark_report()
160
- self.benchmark["jsorc"]["requests"] = {}
161
- self.benchmark["jsorc"]["active"] = False
162
-
163
- if report:
164
- return res
165
- else:
166
- return {}
167
-
168
- def benchmark_report(self):
169
- """
170
- Summarize benchmark results and report.
171
- """
172
- summary = {}
173
- duration = time.time() - self.benchmark["jsorc"]["start_ts"]
174
- for request, data in self.benchmark["jsorc"]["requests"].items():
175
- summary[request] = {}
176
- all_reqs = []
177
- for req_name, times in data.items():
178
- if len(times) == 0:
179
- continue
180
- all_reqs.extend(times)
181
- summary[request][req_name] = {
182
- "throughput": len(times) / duration,
183
- "average_latency": sum(times) / len(times) * 1000,
184
- "50th_latency": np.percentile(times, 50) * 1000,
185
- "90th_latency": np.percentile(times, 90) * 1000,
186
- "95th_latency": np.percentile(times, 95) * 1000,
187
- "99th_latency": np.percentile(times, 99) * 1000,
188
- }
189
- summary[request]["all"] = {
190
- "throughput": len(all_reqs) / duration,
191
- "average_latency": sum(all_reqs) / len(all_reqs) * 1000,
192
- "50th_latency": np.percentile(all_reqs, 50) * 1000,
193
- "90th_latency": np.percentile(all_reqs, 90) * 1000,
194
- "95th_latency": np.percentile(all_reqs, 95) * 1000,
195
- "99th_latency": np.percentile(all_reqs, 99) * 1000,
196
- }
197
-
198
- return summary
199
-
200
- def record_state(self):
201
- """
202
- Record the current state of the system observed by JSORC
203
- """
204
-
205
- def add_to_benchmark(self, request_type, request, request_time):
206
- """
207
- Add requests to benchmark performance tracking
208
- """
209
- for bm in self.benchmark.values():
210
- if request_type not in bm["requests"]:
211
- bm["requests"][request_type] = {"_default_": []}
212
- if request_type == "walker_run":
213
- walker_name = dict(request.data)["name"]
214
- if walker_name not in bm["requests"][request_type]:
215
- bm["requests"][request_type][walker_name] = []
216
- bm["requests"][request_type][walker_name].append(request_time)
217
- else:
218
- bm["requests"][request_type]["_default_"].append(request_time)
219
-
220
- def set_action_policy(self, policy_name, policy_params):
221
- """
222
- Set an action optimizer policy
223
- """
224
- return self.actions_optimizer.set_action_policy(policy_name, policy_params)
225
-
226
- def get_action_policy(self):
227
- """
228
- Get the current action optimization policy
229
- """
230
- return self.actions_optimizer.get_action_policy()
231
-
232
- def pre_action_call_hook(self, *args):
233
- pass
234
-
235
- def post_action_call_hook(self, *args):
236
- action_name = args[0]
237
- action_time = args[1]
238
- if action_name not in self.actions_calls:
239
- self.actions_calls[action_name] = []
240
-
241
- self.actions_calls[action_name].append(action_time)
242
-
243
- def pre_request_hook(self, *args):
244
- pass
245
-
246
- def post_request_hook(self, *args):
247
- request_type = args[0]
248
- request = args[1]
249
- request_time = args[2]
250
- if self.benchmark["jsorc"]["active"]:
251
- self.add_to_benchmark(request_type, request, request_time)
252
-
253
- def optimize(self, jsorc_interval):
254
- self.actions_optimizer.run(jsorc_interval)