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