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.
- 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.6.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 -118
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -77
- jaseci/extens/act_lib/file_handler.py +0 -190
- jaseci/extens/act_lib/internal.py +0 -19
- jaseci/extens/act_lib/jaseci.py +0 -62
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -192
- jaseci/extens/act_lib/rand.py +0 -83
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -170
- jaseci/extens/act_lib/std.py +0 -236
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -338
- jaseci/extens/act_lib/task.py +0 -14
- 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 -80
- jaseci/extens/act_lib/vector.py +0 -158
- jaseci/extens/act_lib/webtool.py +0 -29
- jaseci/extens/act_lib/zip.py +0 -34
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -171
- jaseci/extens/api/alias_api.py +0 -140
- jaseci/extens/api/architype_api.py +0 -197
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -85
- jaseci/extens/api/graph_api.py +0 -168
- jaseci/extens/api/health_api.py +0 -21
- jaseci/extens/api/interface.py +0 -269
- jaseci/extens/api/jac_api.py +0 -172
- jaseci/extens/api/jsorc_api.py +0 -317
- jaseci/extens/api/logger_api.py +0 -90
- jaseci/extens/api/master_api.py +0 -134
- jaseci/extens/api/object_api.py +0 -102
- jaseci/extens/api/prometheus_api.py +0 -75
- jaseci/extens/api/queue_api.py +0 -141
- jaseci/extens/api/sentinel_api.py +0 -271
- jaseci/extens/api/share_api.py +0 -64
- jaseci/extens/api/super_api.py +0 -65
- 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 -166
- jaseci/extens/api/walker_api.py +0 -299
- jaseci/extens/api/webhook_api.py +0 -77
- 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 -219
- jaseci/jac/interpreter/interp.py +0 -1784
- jaseci/jac/interpreter/sentinel_interp.py +0 -260
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -249
- 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 -151
- 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 -120
- 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 -86
- jaseci/jac/machine/jac_value.py +0 -227
- jaseci/jac/machine/machine_state.py +0 -386
- 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 -365
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6029
- 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 -140
- jaseci/jsorc/remote_actions.py +0 -158
- 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 -94
- jaseci/prim/architype.py +0 -90
- jaseci/prim/edge.py +0 -173
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -27
- jaseci/prim/master.py +0 -67
- jaseci/prim/node.py +0 -533
- jaseci/prim/obj_mixins.py +0 -238
- jaseci/prim/sentinel.py +0 -282
- 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 -517
- 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 -169
- 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.6.dist-info/LICENSE +0 -21
- jaseci-1.4.2.6.dist-info/METADATA +0 -39
- jaseci-1.4.2.6.dist-info/RECORD +0 -185
- jaseci-1.4.2.6.dist-info/entry_points.txt +0 -3
- jaseci-1.4.2.6.dist-info/top_level.txt +0 -1
jaseci/jsorc/live_actions.py
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
General action base class with automation for hot loading
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from importlib.util import spec_from_file_location, module_from_spec
|
|
6
|
-
from jaseci.utils.utils import logger
|
|
7
|
-
from jaseci.jsorc.remote_actions import ACTIONS_SPEC_LOC
|
|
8
|
-
from jaseci.jsorc.remote_actions import serv_actions, mark_as_remote, mark_as_endpoint
|
|
9
|
-
import requests
|
|
10
|
-
import os
|
|
11
|
-
import sys
|
|
12
|
-
import inspect
|
|
13
|
-
import importlib
|
|
14
|
-
import gc
|
|
15
|
-
import re
|
|
16
|
-
|
|
17
|
-
var_args = re.compile(r"^\*[^\*]")
|
|
18
|
-
var_kwargs = re.compile(r"^\*\*[^\*]")
|
|
19
|
-
|
|
20
|
-
live_actions = {} # {"act.func": func_obj, ...}
|
|
21
|
-
live_action_modules = {} # {__module__: ["act.func1", "act.func2", ...], ...}
|
|
22
|
-
action_configs = {} # {"module_name": {}, ...}
|
|
23
|
-
|
|
24
|
-
glob_act_group = {} # {"group_name": {"act_name": action, ...}, ...}
|
|
25
|
-
glob_act_hook = None
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def jaseci_action(act_group=None, aliases=list(), allow_remote=False):
|
|
29
|
-
"""Decorator for Jaseci Action interface"""
|
|
30
|
-
caller_globals = dict(inspect.getmembers(inspect.currentframe().f_back))[
|
|
31
|
-
"f_globals"
|
|
32
|
-
]
|
|
33
|
-
if allow_remote and "serv_actions" not in caller_globals:
|
|
34
|
-
caller_globals["serv_actions"] = serv_actions
|
|
35
|
-
|
|
36
|
-
def decorator_func(func):
|
|
37
|
-
if allow_remote:
|
|
38
|
-
mark_as_remote([func, act_group, aliases, caller_globals])
|
|
39
|
-
return assimilate_action(func, act_group, aliases)
|
|
40
|
-
|
|
41
|
-
return decorator_func
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def jaseci_expose(endpoint, mount=None):
|
|
45
|
-
"""Decorator for Jaseci Action interface"""
|
|
46
|
-
caller_globals = dict(inspect.getmembers(inspect.currentframe().f_back))[
|
|
47
|
-
"f_globals"
|
|
48
|
-
]
|
|
49
|
-
if "serv_actions" not in caller_globals:
|
|
50
|
-
caller_globals["serv_actions"] = serv_actions
|
|
51
|
-
|
|
52
|
-
def decorator_func(func):
|
|
53
|
-
mark_as_endpoint([func, endpoint, mount, caller_globals])
|
|
54
|
-
return func
|
|
55
|
-
|
|
56
|
-
return decorator_func
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def assimilate_action(func, act_group=None, aliases=list()):
|
|
60
|
-
"""Helper for jaseci_action decorator"""
|
|
61
|
-
act_group = [func.__module__.split(".")[-1]] if act_group is None else act_group
|
|
62
|
-
action_name = f"{'.'.join(act_group+[func.__name__])}"
|
|
63
|
-
live_actions[action_name] = func
|
|
64
|
-
if func.__module__ != "js_remote_hook":
|
|
65
|
-
if func.__module__ in live_action_modules:
|
|
66
|
-
live_action_modules[func.__module__].append(action_name)
|
|
67
|
-
else:
|
|
68
|
-
live_action_modules[func.__module__] = [action_name]
|
|
69
|
-
for i in aliases:
|
|
70
|
-
live_actions[f"{'.'.join(act_group+[i])}"] = func
|
|
71
|
-
if func.__module__ != "js_remote_hook":
|
|
72
|
-
if func.__module__ in live_action_modules:
|
|
73
|
-
live_action_modules[func.__module__].append(
|
|
74
|
-
f"{'.'.join(act_group+[i])}"
|
|
75
|
-
)
|
|
76
|
-
else:
|
|
77
|
-
live_action_modules[func.__module__] = [f"{'.'.join(act_group+[i])}"]
|
|
78
|
-
return func
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def load_local_actions(file: str, ctx: dict = {}):
|
|
82
|
-
"""Load all jaseci actions from python file"""
|
|
83
|
-
try:
|
|
84
|
-
name = file.rstrip(".py")
|
|
85
|
-
name = ".".join(name.split("/")[-2:])
|
|
86
|
-
# Assumes parent folder of py file is a package for internal relative
|
|
87
|
-
# imports, name is package.module and package path is added to sys path
|
|
88
|
-
spec = spec_from_file_location(name, str(file))
|
|
89
|
-
if spec is None:
|
|
90
|
-
logger.error(f"Cannot hot load from action file {file}")
|
|
91
|
-
return False
|
|
92
|
-
else:
|
|
93
|
-
module_dir = os.path.dirname(os.path.dirname(os.path.realpath(file)))
|
|
94
|
-
if module_dir not in sys.path:
|
|
95
|
-
sys.path.append(module_dir)
|
|
96
|
-
mod = module_from_spec(spec)
|
|
97
|
-
spec.loader.exec_module(mod)
|
|
98
|
-
try:
|
|
99
|
-
if hasattr(mod, "setup"):
|
|
100
|
-
mod.setup(**ctx)
|
|
101
|
-
except Exception as e:
|
|
102
|
-
logger.error(
|
|
103
|
-
f"Cannot run set up for module {mod}. This could be because the module doesn't have a setup procedure for initialization, or wrong setup parameters are provided."
|
|
104
|
-
)
|
|
105
|
-
logger.error(e)
|
|
106
|
-
return True
|
|
107
|
-
except Exception as e:
|
|
108
|
-
logger.error(f"Cannot hot load local actions from {file}: {e}")
|
|
109
|
-
return False
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def load_module_actions(mod, loaded_module=None, ctx: dict = {}):
|
|
113
|
-
"""Load all jaseci actions from python module"""
|
|
114
|
-
try:
|
|
115
|
-
if mod in sys.modules:
|
|
116
|
-
del sys.modules[mod]
|
|
117
|
-
if loaded_module and loaded_module in sys.modules:
|
|
118
|
-
del sys.modules[loaded_module]
|
|
119
|
-
if mod in live_action_modules:
|
|
120
|
-
for i in live_action_modules[mod]:
|
|
121
|
-
if i in live_actions:
|
|
122
|
-
del live_actions[i]
|
|
123
|
-
if loaded_module in live_action_modules:
|
|
124
|
-
for i in live_action_modules[loaded_module]:
|
|
125
|
-
if i in live_actions:
|
|
126
|
-
del live_actions[i]
|
|
127
|
-
|
|
128
|
-
mod = importlib.import_module(mod)
|
|
129
|
-
try:
|
|
130
|
-
if hasattr(mod, "setup"):
|
|
131
|
-
mod.setup(**ctx)
|
|
132
|
-
except Exception as e:
|
|
133
|
-
logger.error(
|
|
134
|
-
f"Cannot run set up for module {mod}. This could be because the module doesn't have a setup procedure for initialization, or wrong setup parameters are provided."
|
|
135
|
-
)
|
|
136
|
-
logger.error(e)
|
|
137
|
-
if mod:
|
|
138
|
-
return True
|
|
139
|
-
except Exception as e:
|
|
140
|
-
logger.error(f"Cannot hot load module actions from {mod}: {e}")
|
|
141
|
-
|
|
142
|
-
return False
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def load_action_config(config, module_name):
|
|
146
|
-
"""
|
|
147
|
-
Load the action config of a jaseci action module
|
|
148
|
-
"""
|
|
149
|
-
|
|
150
|
-
loaded_configs = importlib.import_module(config).ACTION_CONFIGS
|
|
151
|
-
if module_name and module_name in loaded_configs:
|
|
152
|
-
action_configs[module_name] = loaded_configs[module_name]
|
|
153
|
-
return True
|
|
154
|
-
else:
|
|
155
|
-
return False
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
def unload_module(mod):
|
|
159
|
-
"""Unload actions module and all relevant function"""
|
|
160
|
-
if mod in sys.modules.keys() and mod in live_action_modules.keys():
|
|
161
|
-
for i in live_action_modules[mod]:
|
|
162
|
-
if i in live_actions:
|
|
163
|
-
del live_actions[i]
|
|
164
|
-
|
|
165
|
-
# Iterate through the objects in the module __dict__ to manually delete them
|
|
166
|
-
loaded_mod = sys.modules[mod]
|
|
167
|
-
mod_content_len = len(loaded_mod.__dict__)
|
|
168
|
-
for _ in range(mod_content_len):
|
|
169
|
-
mod_obj = loaded_mod.__dict__.pop(list(loaded_mod.__dict__.keys())[0])
|
|
170
|
-
del mod_obj
|
|
171
|
-
del loaded_mod
|
|
172
|
-
del sys.modules[mod]
|
|
173
|
-
del live_action_modules[mod]
|
|
174
|
-
gc.collect()
|
|
175
|
-
return True
|
|
176
|
-
return False
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def unload_action(name):
|
|
180
|
-
"""Unload actions module and all relevant function"""
|
|
181
|
-
if name in live_actions.keys():
|
|
182
|
-
mod = live_actions[name].__module__
|
|
183
|
-
if mod != "js_remote_hook":
|
|
184
|
-
live_action_modules[mod].remove(name)
|
|
185
|
-
if len(live_action_modules[mod]) < 1:
|
|
186
|
-
unload_module(mod)
|
|
187
|
-
del live_actions[name]
|
|
188
|
-
return True
|
|
189
|
-
return False
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def unload_actionset(name):
|
|
193
|
-
"""Unload actions module and all relevant function"""
|
|
194
|
-
act_list = []
|
|
195
|
-
orig_len = len(live_actions)
|
|
196
|
-
for i in live_actions.keys():
|
|
197
|
-
if i.startswith(name + "."):
|
|
198
|
-
act_list.append(i)
|
|
199
|
-
for i in act_list:
|
|
200
|
-
unload_action(i)
|
|
201
|
-
return len(live_actions) != orig_len
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def load_preconfig_actions(hook):
|
|
205
|
-
import json
|
|
206
|
-
|
|
207
|
-
action_preload = hook.resolve_glob("ACTION_SETS", None)
|
|
208
|
-
if action_preload:
|
|
209
|
-
try:
|
|
210
|
-
action_preload = json.loads(action_preload)
|
|
211
|
-
for i in action_preload["local"]:
|
|
212
|
-
load_local_actions(i)
|
|
213
|
-
for i in action_preload["remote"]:
|
|
214
|
-
load_remote_actions(i)
|
|
215
|
-
for i in action_preload["module"]:
|
|
216
|
-
load_module_actions(i)
|
|
217
|
-
except Exception:
|
|
218
|
-
pass
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
def get_global_actions():
|
|
222
|
-
"""
|
|
223
|
-
Loads all global action hooks for use by Jac programs
|
|
224
|
-
Attaches globals to mem_hook
|
|
225
|
-
"""
|
|
226
|
-
from jaseci.prim.ability import Ability
|
|
227
|
-
from jaseci.jsorc.memory import MemoryHook
|
|
228
|
-
|
|
229
|
-
if not glob_act_group:
|
|
230
|
-
glob_act_hook = MemoryHook()
|
|
231
|
-
for i in live_actions.keys():
|
|
232
|
-
name = i.split(".")
|
|
233
|
-
if name[0] in [
|
|
234
|
-
"std",
|
|
235
|
-
"file",
|
|
236
|
-
"net",
|
|
237
|
-
"rand",
|
|
238
|
-
"vector",
|
|
239
|
-
"request",
|
|
240
|
-
"date",
|
|
241
|
-
"jaseci",
|
|
242
|
-
"internal",
|
|
243
|
-
"zip",
|
|
244
|
-
"webtool",
|
|
245
|
-
"url",
|
|
246
|
-
"regex",
|
|
247
|
-
"maths",
|
|
248
|
-
]:
|
|
249
|
-
if name[0] not in glob_act_group:
|
|
250
|
-
glob_act_group[name[0]] = {}
|
|
251
|
-
glob_act_group[name[0]][name[1]] = Ability(
|
|
252
|
-
m_id=0,
|
|
253
|
-
h=glob_act_hook,
|
|
254
|
-
mode="public",
|
|
255
|
-
name=i,
|
|
256
|
-
kind="ability",
|
|
257
|
-
value=i,
|
|
258
|
-
persist=False,
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
# second layer copy and this will use the same Ability object
|
|
262
|
-
# deepcopy will be much expensive and will also use new Ability Objects
|
|
263
|
-
temp_glob_act_group = {}
|
|
264
|
-
for key, value in glob_act_group.items():
|
|
265
|
-
temp_glob_act_group[key] = value.copy()
|
|
266
|
-
|
|
267
|
-
return temp_glob_act_group
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
def unload_remote_actions(url):
|
|
271
|
-
"""
|
|
272
|
-
Get the list of actions from the given URL and then unload them.
|
|
273
|
-
"""
|
|
274
|
-
headers = {"content-type": "application/json"}
|
|
275
|
-
try:
|
|
276
|
-
spec = requests.get(url.rstrip("/") + ACTIONS_SPEC_LOC, headers=headers)
|
|
277
|
-
spec = spec.json()
|
|
278
|
-
for i in spec.keys():
|
|
279
|
-
unload_action(i)
|
|
280
|
-
return True
|
|
281
|
-
except Exception as e:
|
|
282
|
-
logger.error(f"Cannot unload remote action from {url}: {e}")
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
def load_remote_actions(url, ctx: dict = {}):
|
|
286
|
-
"""Load all jaseci actions from live pod"""
|
|
287
|
-
headers = {"content-type": "application/json"}
|
|
288
|
-
try:
|
|
289
|
-
spec = requests.get(url.rstrip("/") + ACTIONS_SPEC_LOC, headers=headers)
|
|
290
|
-
spec = spec.json()
|
|
291
|
-
for i in spec.keys():
|
|
292
|
-
live_actions[i] = gen_remote_func_hook(url, i, spec[i])
|
|
293
|
-
if i.endswith(".setup") and ctx:
|
|
294
|
-
try:
|
|
295
|
-
live_actions[i](**ctx)
|
|
296
|
-
except Exception as e:
|
|
297
|
-
logger.error(
|
|
298
|
-
f"Cannot run set up for remote action {i}. This could be because the module doesn't have a setup procedure for initialization, or wrong setup parameters are provided."
|
|
299
|
-
)
|
|
300
|
-
logger.error(e)
|
|
301
|
-
return True
|
|
302
|
-
|
|
303
|
-
except Exception as e:
|
|
304
|
-
logger.error(f"Cannot hot load remote actions at {url}: {e}")
|
|
305
|
-
return False
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
def gen_remote_func_hook(url, act_name, param_names):
|
|
309
|
-
"""Generater for function calls for remote action calls"""
|
|
310
|
-
|
|
311
|
-
def func(*args, **kwargs):
|
|
312
|
-
params = {}
|
|
313
|
-
_args = list(args)
|
|
314
|
-
_param_names: list = param_names.copy()
|
|
315
|
-
|
|
316
|
-
args_len = len(args)
|
|
317
|
-
for idx, name in enumerate(param_names):
|
|
318
|
-
if idx >= args_len or not _args:
|
|
319
|
-
break
|
|
320
|
-
_param_names.remove(name)
|
|
321
|
-
if var_args.match(name):
|
|
322
|
-
if _args:
|
|
323
|
-
params[name] = _args
|
|
324
|
-
break
|
|
325
|
-
else:
|
|
326
|
-
params[name] = _args.pop(0)
|
|
327
|
-
|
|
328
|
-
for name in _param_names:
|
|
329
|
-
if var_args.match(name):
|
|
330
|
-
if _args:
|
|
331
|
-
params[name] = _args
|
|
332
|
-
elif var_kwargs.match(name):
|
|
333
|
-
if kwargs:
|
|
334
|
-
params[name] = kwargs
|
|
335
|
-
break
|
|
336
|
-
elif name in kwargs:
|
|
337
|
-
params[name] = kwargs.pop(name)
|
|
338
|
-
|
|
339
|
-
# Remove any None-valued parameters to use the default value of the action def
|
|
340
|
-
params = dict([(k, v) for k, v in params.items() if v is not None])
|
|
341
|
-
act_url = f"{url.rstrip('/')}/{act_name.split('.')[-1]}"
|
|
342
|
-
res = requests.post(
|
|
343
|
-
act_url, headers={"content-type": "application/json"}, json=params
|
|
344
|
-
)
|
|
345
|
-
return res.json()
|
|
346
|
-
|
|
347
|
-
func.__module__ = "js_remote_hook"
|
|
348
|
-
|
|
349
|
-
return func
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
def call_action(action_name: str, ctx: dict = {}) -> None:
|
|
353
|
-
"""
|
|
354
|
-
Call an action by name
|
|
355
|
-
"""
|
|
356
|
-
try:
|
|
357
|
-
action_name = action_name.strip()
|
|
358
|
-
if action_name in live_actions.keys():
|
|
359
|
-
res = live_actions[action_name](**ctx)
|
|
360
|
-
return res, True
|
|
361
|
-
else:
|
|
362
|
-
raise Exception(f"Action {action_name} not found")
|
|
363
|
-
except Exception as e:
|
|
364
|
-
logger.error(f"Error calling action {action_name}: {e}")
|
|
365
|
-
return None, False
|
|
File without changes
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
apiVersion: v1
|
|
2
|
-
kind: Service
|
|
3
|
-
metadata:
|
|
4
|
-
creationTimestamp: null
|
|
5
|
-
name: jaseci-db
|
|
6
|
-
namespace: database
|
|
7
|
-
spec:
|
|
8
|
-
internalTrafficPolicy: Cluster
|
|
9
|
-
ports:
|
|
10
|
-
- port: 5432
|
|
11
|
-
protocol: TCP
|
|
12
|
-
targetPort: 5432
|
|
13
|
-
selector:
|
|
14
|
-
pod: jaseci-db
|
|
15
|
-
sessionAffinity: None
|
|
16
|
-
type: ClusterIP
|
|
17
|
-
status:
|
|
18
|
-
loadBalancer: {}
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
apiVersion: v1
|
|
22
|
-
kind: Secret
|
|
23
|
-
metadata:
|
|
24
|
-
creationTimestamp: null
|
|
25
|
-
name: jaseci-db-credentials
|
|
26
|
-
namespace: database
|
|
27
|
-
data:
|
|
28
|
-
password: bGlmZWxvZ2lmeWphc2VjaQ==
|
|
29
|
-
user: cG9zdGdyZXM=
|
|
30
|
-
type: Opaque
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
apiVersion: v1
|
|
34
|
-
kind: PersistentVolumeClaim
|
|
35
|
-
metadata:
|
|
36
|
-
creationTimestamp: null
|
|
37
|
-
name: jaseci-db-pvc
|
|
38
|
-
namespace: database
|
|
39
|
-
spec:
|
|
40
|
-
accessModes:
|
|
41
|
-
- ReadWriteOnce
|
|
42
|
-
resources:
|
|
43
|
-
requests:
|
|
44
|
-
storage: 10Gi
|
|
45
|
-
volumeMode: Filesystem
|
|
46
|
-
status:
|
|
47
|
-
phase: Pending
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
apiVersion: apps/v1
|
|
52
|
-
kind: Deployment
|
|
53
|
-
metadata:
|
|
54
|
-
creationTimestamp: null
|
|
55
|
-
name: jaseci-db
|
|
56
|
-
namespace: database
|
|
57
|
-
spec:
|
|
58
|
-
progressDeadlineSeconds: 600
|
|
59
|
-
replicas: 1
|
|
60
|
-
revisionHistoryLimit: 10
|
|
61
|
-
selector:
|
|
62
|
-
matchLabels:
|
|
63
|
-
pod: jaseci-db
|
|
64
|
-
strategy:
|
|
65
|
-
rollingUpdate:
|
|
66
|
-
maxSurge: 25%
|
|
67
|
-
maxUnavailable: 25%
|
|
68
|
-
type: RollingUpdate
|
|
69
|
-
template:
|
|
70
|
-
metadata:
|
|
71
|
-
creationTimestamp: null
|
|
72
|
-
labels:
|
|
73
|
-
pod: jaseci-db
|
|
74
|
-
spec:
|
|
75
|
-
containers:
|
|
76
|
-
- env:
|
|
77
|
-
- name: POSTGRES_USER
|
|
78
|
-
valueFrom:
|
|
79
|
-
secretKeyRef:
|
|
80
|
-
key: user
|
|
81
|
-
name: jaseci-db-credentials
|
|
82
|
-
- name: POSTGRES_PASSWORD
|
|
83
|
-
valueFrom:
|
|
84
|
-
secretKeyRef:
|
|
85
|
-
key: password
|
|
86
|
-
name: jaseci-db-credentials
|
|
87
|
-
image: postgres:alpine
|
|
88
|
-
imagePullPolicy: IfNotPresent
|
|
89
|
-
name: jaseci-db
|
|
90
|
-
ports:
|
|
91
|
-
- containerPort: 5432
|
|
92
|
-
protocol: TCP
|
|
93
|
-
resources: {}
|
|
94
|
-
terminationMessagePath: /dev/termination-log
|
|
95
|
-
terminationMessagePolicy: File
|
|
96
|
-
volumeMounts:
|
|
97
|
-
- mountPath: /var/lib/postgresql/data
|
|
98
|
-
name: jaseci-db-volume
|
|
99
|
-
subPath: jaseci
|
|
100
|
-
dnsPolicy: ClusterFirst
|
|
101
|
-
restartPolicy: Always
|
|
102
|
-
schedulerName: default-scheduler
|
|
103
|
-
securityContext: {}
|
|
104
|
-
terminationGracePeriodSeconds: 30
|
|
105
|
-
volumes:
|
|
106
|
-
- name: jaseci-db-volume
|
|
107
|
-
persistentVolumeClaim:
|
|
108
|
-
claimName: jaseci-db-pvc
|
|
109
|
-
status: {}
|