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.
- jaseci/__init__.py +3 -37
- jaseci-2.0.0.dist-info/METADATA +65 -0
- jaseci-2.0.0.dist-info/RECORD +4 -0
- {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
- jaseci/VERSION +0 -1
- jaseci/cli_tools/__init__.py +0 -0
- jaseci/cli_tools/book_tools.py +0 -457
- jaseci/cli_tools/jsctl.py +0 -500
- jaseci/cli_tools/tests/__init__.py +0 -0
- jaseci/cli_tools/tests/test_jsctl.py +0 -556
- jaseci/extens/__init__.py +0 -0
- jaseci/extens/act_lib/__init__.py +0 -0
- jaseci/extens/act_lib/date.py +0 -117
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -76
- jaseci/extens/act_lib/file_handler.py +0 -189
- jaseci/extens/act_lib/internal.py +0 -18
- jaseci/extens/act_lib/jaseci.py +0 -61
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -191
- jaseci/extens/act_lib/rand.py +0 -82
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -169
- jaseci/extens/act_lib/std.py +0 -235
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -337
- jaseci/extens/act_lib/task.py +0 -13
- jaseci/extens/act_lib/tests/__init__.py +0 -0
- jaseci/extens/act_lib/tests/std_test_code.py +0 -37
- jaseci/extens/act_lib/tests/test_date.py +0 -26
- jaseci/extens/act_lib/tests/test_elastic.py +0 -159
- jaseci/extens/act_lib/tests/test_file.py +0 -116
- jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
- jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
- jaseci/extens/act_lib/tests/test_maths.py +0 -147
- jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
- jaseci/extens/act_lib/tests/test_regex.py +0 -61
- jaseci/extens/act_lib/tests/test_std.py +0 -51
- jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
- jaseci/extens/act_lib/tests/test_url.py +0 -32
- jaseci/extens/act_lib/tests/test_vector.py +0 -36
- jaseci/extens/act_lib/tests/test_webtool.py +0 -44
- jaseci/extens/act_lib/tests/test_zlib.py +0 -24
- jaseci/extens/act_lib/url.py +0 -79
- jaseci/extens/act_lib/vector.py +0 -157
- jaseci/extens/act_lib/webtool.py +0 -28
- jaseci/extens/act_lib/zip.py +0 -33
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -170
- jaseci/extens/api/alias_api.py +0 -139
- jaseci/extens/api/architype_api.py +0 -196
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -84
- jaseci/extens/api/graph_api.py +0 -167
- jaseci/extens/api/health_api.py +0 -20
- jaseci/extens/api/interface.py +0 -268
- jaseci/extens/api/jac_api.py +0 -171
- jaseci/extens/api/jsorc_api.py +0 -316
- jaseci/extens/api/logger_api.py +0 -89
- jaseci/extens/api/master_api.py +0 -133
- jaseci/extens/api/object_api.py +0 -101
- jaseci/extens/api/prometheus_api.py +0 -74
- jaseci/extens/api/queue_api.py +0 -140
- jaseci/extens/api/sentinel_api.py +0 -270
- jaseci/extens/api/super_api.py +0 -64
- jaseci/extens/api/tests/__init__.py +0 -0
- jaseci/extens/api/tests/test_architype_api.py +0 -66
- jaseci/extens/api/tests/test_global_api.py +0 -179
- jaseci/extens/api/tests/test_graph_api.py +0 -64
- jaseci/extens/api/tests/test_logger_api.py +0 -43
- jaseci/extens/api/tests/test_object_api.py +0 -20
- jaseci/extens/api/tests/test_sentinel_api.py +0 -66
- jaseci/extens/api/tests/test_uncommon.py +0 -107
- jaseci/extens/api/tests/test_user_api.py +0 -32
- jaseci/extens/api/tests/test_walker_api.py +0 -316
- jaseci/extens/api/user_api.py +0 -144
- jaseci/extens/api/walker_api.py +0 -298
- jaseci/extens/api/webhook_api.py +0 -74
- jaseci/extens/svc/__init__.py +0 -0
- jaseci/extens/svc/elastic_svc.py +0 -366
- jaseci/extens/svc/kube_svc.py +0 -432
- jaseci/extens/svc/mail_svc.py +0 -156
- jaseci/extens/svc/prome_svc.py +0 -378
- jaseci/extens/svc/redis_svc.py +0 -63
- jaseci/extens/svc/storage_svc.py +0 -193
- jaseci/extens/svc/stripe_svc.py +0 -51
- jaseci/extens/svc/task_svc.py +0 -155
- jaseci/extens/svc/tasks.py +0 -302
- jaseci/jac/__init__.py +0 -0
- jaseci/jac/interpreter/__init__.py +0 -0
- jaseci/jac/interpreter/architype_interp.py +0 -214
- jaseci/jac/interpreter/interp.py +0 -1783
- jaseci/jac/interpreter/sentinel_interp.py +0 -257
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -248
- jaseci/jac/ir/__init__.py +0 -0
- jaseci/jac/ir/ast.py +0 -73
- jaseci/jac/ir/ast_builder.py +0 -249
- jaseci/jac/ir/jac_code.py +0 -152
- jaseci/jac/ir/passes/__init__.py +0 -6
- jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
- jaseci/jac/ir/passes/codegen_pass.py +0 -244
- jaseci/jac/ir/passes/ir_pass.py +0 -29
- jaseci/jac/ir/passes/printer_pass.py +0 -23
- jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
- jaseci/jac/ir/passes/schedule.py +0 -23
- jaseci/jac/ir/passes/stats_pass.py +0 -16
- jaseci/jac/jac.g4 +0 -450
- jaseci/jac/jac_parse/__init__.py +0 -0
- jaseci/jac/jac_parse/jacLexer.py +0 -809
- jaseci/jac/jac_parse/jacListener.py +0 -853
- jaseci/jac/jac_parse/jacParser.py +0 -9192
- jaseci/jac/jac_set.py +0 -119
- jaseci/jac/jsci_vm/__init__.py +0 -0
- jaseci/jac/jsci_vm/disasm.py +0 -94
- jaseci/jac/jsci_vm/inst_ptr.py +0 -31
- jaseci/jac/jsci_vm/machine.py +0 -188
- jaseci/jac/jsci_vm/op_codes.py +0 -82
- jaseci/jac/jsci_vm/tests/__init__.py +0 -0
- jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
- jaseci/jac/machine/__init__.py +0 -0
- jaseci/jac/machine/jac_scope.py +0 -85
- jaseci/jac/machine/jac_value.py +0 -226
- jaseci/jac/machine/machine_state.py +0 -383
- jaseci/jac/tests/__init__.py +0 -0
- jaseci/jac/tests/book_code.py +0 -624
- jaseci/jac/tests/test_book.py +0 -380
- jaseci/jac/tests/test_lang_14.py +0 -49
- jaseci/jsorc/__init__.py +0 -7
- jaseci/jsorc/jsorc.py +0 -642
- jaseci/jsorc/jsorc_settings.py +0 -211
- jaseci/jsorc/jsorc_utils.py +0 -298
- jaseci/jsorc/live_actions.py +0 -364
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6024
- jaseci/jsorc/manifests/prometheus.yaml +0 -1383
- jaseci/jsorc/manifests/redis.yaml +0 -64
- jaseci/jsorc/memory.py +0 -258
- jaseci/jsorc/redis.py +0 -139
- jaseci/jsorc/remote_actions.py +0 -157
- jaseci/jsorc/tests/__init__.py +0 -0
- jaseci/jsorc/tests/test_actions.py +0 -542
- jaseci/jsorc/tests/test_jsorc.py +0 -112
- jaseci/prim/__init__.py +0 -0
- jaseci/prim/ability.py +0 -93
- jaseci/prim/architype.py +0 -89
- jaseci/prim/edge.py +0 -172
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -26
- jaseci/prim/master.py +0 -64
- jaseci/prim/node.py +0 -532
- jaseci/prim/obj_mixins.py +0 -235
- jaseci/prim/sentinel.py +0 -281
- jaseci/prim/super_master.py +0 -31
- jaseci/prim/walker.py +0 -261
- jaseci/svc/__init__.py +0 -0
- jaseci/tests/__init__.py +0 -0
- jaseci/tests/infer.py +0 -39
- jaseci/tests/jac_test_code.py +0 -1293
- jaseci/tests/jac_test_progs.py +0 -774
- jaseci/tests/test_core.py +0 -153
- jaseci/tests/test_jac.py +0 -824
- jaseci/tests/test_node.py +0 -89
- jaseci/tests/test_progs.py +0 -702
- jaseci/tests/test_stack.py +0 -220
- jaseci/tests/test_stripe.py +0 -225
- jaseci/utils/__init__.py +0 -0
- jaseci/utils/actions/__init__.py +0 -0
- jaseci/utils/actions/actions_manager.py +0 -254
- jaseci/utils/actions/actions_optimizer.py +0 -516
- jaseci/utils/actions/actions_state.py +0 -95
- jaseci/utils/file_handler.py +0 -171
- jaseci/utils/gprof2dot.py +0 -3786
- jaseci/utils/id_list.py +0 -168
- jaseci/utils/json_handler.py +0 -70
- jaseci/utils/log_utils.py +0 -57
- jaseci/utils/test_core.py +0 -62
- jaseci/utils/utils.py +0 -387
- jaseci-1.4.2.5.dist-info/LICENSE +0 -21
- jaseci-1.4.2.5.dist-info/METADATA +0 -39
- jaseci-1.4.2.5.dist-info/RECORD +0 -184
- jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
- 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)
|