jaseci 1.4.2.4__py3-none-any.whl → 1.4.2.6__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/VERSION +1 -1
- jaseci/cli_tools/book_tools.py +10 -10
- jaseci/extens/act_lib/date.py +1 -0
- jaseci/extens/act_lib/file.py +1 -0
- jaseci/extens/act_lib/file_handler.py +8 -3
- jaseci/extens/act_lib/internal.py +1 -0
- jaseci/extens/act_lib/jaseci.py +1 -0
- jaseci/extens/act_lib/net.py +1 -0
- jaseci/extens/act_lib/rand.py +1 -0
- jaseci/extens/act_lib/request.py +1 -0
- jaseci/extens/act_lib/std.py +8 -3
- jaseci/extens/act_lib/storage.py +6 -0
- jaseci/extens/act_lib/stripe.py +1 -0
- jaseci/extens/act_lib/task.py +1 -0
- jaseci/extens/act_lib/tests/test_file.py +12 -27
- jaseci/extens/act_lib/url.py +1 -0
- jaseci/extens/act_lib/vector.py +1 -0
- jaseci/extens/act_lib/webtool.py +3 -4
- jaseci/extens/act_lib/zip.py +1 -0
- jaseci/extens/api/actions_api.py +1 -0
- jaseci/extens/api/alias_api.py +1 -0
- jaseci/extens/api/architype_api.py +1 -0
- jaseci/extens/api/global_api.py +1 -0
- jaseci/extens/api/graph_api.py +1 -0
- jaseci/extens/api/health_api.py +21 -0
- jaseci/extens/api/interface.py +1 -0
- jaseci/extens/api/jac_api.py +1 -0
- jaseci/extens/api/jsorc_api.py +8 -9
- jaseci/extens/api/logger_api.py +1 -0
- jaseci/extens/api/master_api.py +2 -1
- jaseci/extens/api/object_api.py +1 -0
- jaseci/extens/api/prometheus_api.py +1 -0
- jaseci/extens/api/queue_api.py +1 -0
- jaseci/extens/api/sentinel_api.py +1 -0
- jaseci/extens/api/share_api.py +64 -0
- jaseci/extens/api/super_api.py +1 -0
- jaseci/extens/api/user_api.py +22 -0
- jaseci/extens/api/walker_api.py +1 -0
- jaseci/extens/api/webhook_api.py +6 -3
- jaseci/extens/svc/elastic_svc.py +17 -17
- jaseci/extens/svc/kube_svc.py +37 -1
- jaseci/extens/svc/redis_svc.py +5 -2
- jaseci/extens/svc/storage_svc.py +75 -8
- jaseci/jac/interpreter/architype_interp.py +11 -6
- jaseci/jac/interpreter/interp.py +19 -4
- jaseci/jac/interpreter/sentinel_interp.py +5 -2
- jaseci/jac/interpreter/walker_interp.py +1 -0
- jaseci/jac/ir/jac_code.py +2 -3
- jaseci/jac/jac_set.py +1 -0
- jaseci/jac/machine/jac_scope.py +1 -0
- jaseci/jac/machine/jac_value.py +1 -0
- jaseci/jac/machine/machine_state.py +14 -3
- jaseci/jsorc/jsorc.py +28 -2
- jaseci/jsorc/jsorc_utils.py +12 -0
- jaseci/jsorc/live_actions.py +1 -0
- jaseci/jsorc/manifests/elastic.yaml +5 -0
- jaseci/jsorc/memory.py +1 -1
- jaseci/jsorc/redis.py +4 -5
- jaseci/jsorc/remote_actions.py +1 -0
- jaseci/prim/ability.py +8 -13
- jaseci/prim/architype.py +1 -0
- jaseci/prim/edge.py +1 -0
- jaseci/prim/graph.py +1 -0
- jaseci/prim/master.py +5 -0
- jaseci/prim/node.py +1 -0
- jaseci/prim/obj_mixins.py +6 -3
- jaseci/prim/sentinel.py +1 -0
- jaseci/tests/test_progs.py +1 -1
- jaseci/tests/test_stripe.py +3 -3
- jaseci/utils/actions/actions_optimizer.py +1 -0
- jaseci/utils/id_list.py +1 -0
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/METADATA +7 -4
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/RECORD +77 -75
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/WHEEL +1 -1
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/LICENSE +0 -0
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/entry_points.txt +0 -0
- {jaseci-1.4.2.4.dist-info → jaseci-1.4.2.6.dist-info}/top_level.txt +0 -0
jaseci/extens/svc/elastic_svc.py
CHANGED
|
@@ -70,23 +70,24 @@ class ElasticService(JsOrc.CommonService):
|
|
|
70
70
|
"elastic",
|
|
71
71
|
metadata.get("namespace"),
|
|
72
72
|
)
|
|
73
|
-
self.config[
|
|
74
|
-
"auth"
|
|
75
|
-
|
|
73
|
+
self.config["auth"] = (
|
|
74
|
+
f'basic {b64encode(f"elastic:{auth}".encode()).decode()}'
|
|
75
|
+
)
|
|
76
76
|
|
|
77
77
|
self.app = Elastic(self.config)
|
|
78
78
|
self.app.health("timeout=1s")
|
|
79
79
|
|
|
80
80
|
def post_run(self):
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
if multiprocessing.current_process().name == "MainProcess":
|
|
82
|
+
under_test = self.config.get("under_test", False)
|
|
83
|
+
if not under_test:
|
|
84
|
+
self.configure_elastic()
|
|
85
|
+
LOG_QUEUES["core"] = self.add_elastic_log_handler(
|
|
86
|
+
logger, self.config.get("core_log_index") or "core", under_test
|
|
87
|
+
)
|
|
88
|
+
LOG_QUEUES["app"] = self.add_elastic_log_handler(
|
|
89
|
+
app_logger, self.config.get("app_log_index") or "app", under_test
|
|
90
|
+
)
|
|
90
91
|
|
|
91
92
|
def configure_elastic(self):
|
|
92
93
|
"""
|
|
@@ -297,14 +298,13 @@ class Elastic:
|
|
|
297
298
|
# standard methods
|
|
298
299
|
def generate_from_meta(self, meta: dict, override: dict, action: str = None):
|
|
299
300
|
scope = meta["scope"].local_scope
|
|
300
|
-
interp = meta["interp"]
|
|
301
301
|
|
|
302
|
-
node = interp.current_node
|
|
303
302
|
walker = scope["visitor"]
|
|
303
|
+
node = walker.current_node
|
|
304
304
|
|
|
305
305
|
override_misc = override.get("misc")
|
|
306
306
|
override["misc"] = {
|
|
307
|
-
"report": copy(
|
|
307
|
+
"report": copy(walker.report),
|
|
308
308
|
"node": node.serialize(detailed=False),
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -313,7 +313,7 @@ class Elastic:
|
|
|
313
313
|
|
|
314
314
|
master = meta["h"].get_obj(meta["m_id"], meta["m_id"]).master_self(True)
|
|
315
315
|
|
|
316
|
-
headers =
|
|
316
|
+
headers = walker.request_context.get("headers", {})
|
|
317
317
|
if headers.get("Authorization"):
|
|
318
318
|
del headers["Authorization"]
|
|
319
319
|
|
|
@@ -326,7 +326,7 @@ class Elastic:
|
|
|
326
326
|
"node_id": node.jid,
|
|
327
327
|
"master_id": master["jid"],
|
|
328
328
|
"user": master.get("__meta__") or {"email": master["name"]},
|
|
329
|
-
"request_context":
|
|
329
|
+
"request_context": walker.request_context,
|
|
330
330
|
"data": walker.context,
|
|
331
331
|
}
|
|
332
332
|
|
jaseci/extens/svc/kube_svc.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from base64 import b64decode
|
|
2
|
-
|
|
2
|
+
from datetime import datetime
|
|
3
3
|
from kubernetes import config as kubernetes_config
|
|
4
4
|
from kubernetes.client import (
|
|
5
5
|
ApiClient,
|
|
@@ -394,3 +394,39 @@ class KubeService(JsOrc.CommonService):
|
|
|
394
394
|
placeholder_resolver(manifest, manifest)
|
|
395
395
|
|
|
396
396
|
return manifest
|
|
397
|
+
|
|
398
|
+
def has_replicas(self):
|
|
399
|
+
try:
|
|
400
|
+
return (
|
|
401
|
+
self.read(
|
|
402
|
+
"Deployment", "jaseci", self.namespace, quiet=self.quiet
|
|
403
|
+
).spec.replicas
|
|
404
|
+
> 1
|
|
405
|
+
)
|
|
406
|
+
except Exception as e:
|
|
407
|
+
self.quiet or logger.error(f"Error checking jaseci replica -- {e}")
|
|
408
|
+
|
|
409
|
+
def restart(self):
|
|
410
|
+
try:
|
|
411
|
+
return self.api.patch_namespaced_deployment(
|
|
412
|
+
name="jaseci",
|
|
413
|
+
namespace=self.namespace,
|
|
414
|
+
body={
|
|
415
|
+
"spec": {
|
|
416
|
+
"template": {
|
|
417
|
+
"metadata": {
|
|
418
|
+
"annotations": {
|
|
419
|
+
"kubectl.kubernetes.io/restartedAt": datetime.utcnow().isoformat(
|
|
420
|
+
"T"
|
|
421
|
+
)
|
|
422
|
+
+ "Z"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
)
|
|
429
|
+
except ApiException as e:
|
|
430
|
+
self.quiet or logger.error(
|
|
431
|
+
f"Error triggering jaseci rollout restart -- {e}"
|
|
432
|
+
)
|
jaseci/extens/svc/redis_svc.py
CHANGED
|
@@ -49,9 +49,12 @@ class RedisService(JsOrc.CommonService):
|
|
|
49
49
|
# CLEANER #
|
|
50
50
|
###################################################
|
|
51
51
|
|
|
52
|
-
def clear(self):
|
|
52
|
+
def clear(self, all=True):
|
|
53
53
|
if self.is_running():
|
|
54
|
-
|
|
54
|
+
if all:
|
|
55
|
+
self.app.flushall()
|
|
56
|
+
else:
|
|
57
|
+
self.app.flushdb()
|
|
55
58
|
|
|
56
59
|
# ---------------- PROXY EVENTS ----------------- #
|
|
57
60
|
|
jaseci/extens/svc/storage_svc.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
from datetime import datetime
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
2
|
|
|
3
3
|
from jaseci.jsorc.jsorc import JsOrc
|
|
4
4
|
from jaseci.utils.file_handler import FileHandler
|
|
5
5
|
|
|
6
|
-
from libcloud.storage.
|
|
6
|
+
from libcloud.storage.types import Provider, ObjectDoesNotExistError
|
|
7
|
+
from libcloud.storage.providers import get_driver as _get_driver
|
|
7
8
|
from libcloud.storage.base import StorageDriver, Object, Container
|
|
9
|
+
from libcloud.storage.drivers.azure_blobs import AzureBlobsStorageDriver
|
|
8
10
|
|
|
9
|
-
from
|
|
11
|
+
from azure.storage.blob import generate_blob_sas
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
@JsOrc.service(
|
|
@@ -33,13 +35,16 @@ class StorageService(JsOrc.CommonService):
|
|
|
33
35
|
metadata = {
|
|
34
36
|
"id": file.id,
|
|
35
37
|
"name": file.name,
|
|
36
|
-
"content_type": file.content_type,
|
|
37
38
|
"created": datetime.utcnow().isoformat(),
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
# metadata doesn't support empty value
|
|
42
|
+
if file.content_type:
|
|
43
|
+
metadata["content_type"] = file.content_type
|
|
44
|
+
|
|
40
45
|
# metadata doesn't support empty value
|
|
41
46
|
if file.field:
|
|
42
|
-
metadata["field"]
|
|
47
|
+
metadata["field"] = file.field
|
|
43
48
|
|
|
44
49
|
if container:
|
|
45
50
|
container = provider["driver"].get_container(container_name=container)
|
|
@@ -72,13 +77,29 @@ class StorageService(JsOrc.CommonService):
|
|
|
72
77
|
|
|
73
78
|
return temp_file
|
|
74
79
|
|
|
75
|
-
def
|
|
80
|
+
def cdn_url(
|
|
81
|
+
self, file: str, provider: str = None, container: str = None, **kwargs
|
|
82
|
+
) -> str:
|
|
76
83
|
provider = self.app.get_storage(provider)
|
|
84
|
+
driver = provider["driver"]
|
|
77
85
|
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
return driver.get_object_cdn_url(
|
|
87
|
+
driver.get_object(
|
|
88
|
+
container_name=container or provider["container"].name, object_name=file
|
|
89
|
+
),
|
|
90
|
+
**kwargs,
|
|
80
91
|
)
|
|
81
92
|
|
|
93
|
+
def delete(self, file: str, provider: str = None, container: str = None) -> bool:
|
|
94
|
+
provider = self.app.get_storage(provider)
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
obj: Object = provider["driver"].get_object(
|
|
98
|
+
container_name=container or provider["container"].name, object_name=file
|
|
99
|
+
)
|
|
100
|
+
except ObjectDoesNotExistError:
|
|
101
|
+
return True
|
|
102
|
+
|
|
82
103
|
return provider["driver"].delete_object(obj)
|
|
83
104
|
|
|
84
105
|
def create_container(self, name: str, provider: str = None) -> Container:
|
|
@@ -124,3 +145,49 @@ class StorageHandler:
|
|
|
124
145
|
return self.storage[provider]
|
|
125
146
|
elif self.default:
|
|
126
147
|
return self.storage[self.default]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
#############################################################################################
|
|
151
|
+
# ----------------------------------- PROVIDER OVERRIDE ----------------------------------- #
|
|
152
|
+
#############################################################################################
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class AzureBlobsStorageDriverOverride(AzureBlobsStorageDriver):
|
|
156
|
+
AZURE_STORAGE_CDN_URL_DATE_FORMAT = "%Y-%m-%dT%HH:%M:%SZ"
|
|
157
|
+
|
|
158
|
+
def __init__(
|
|
159
|
+
self,
|
|
160
|
+
key,
|
|
161
|
+
secret=None,
|
|
162
|
+
**kwargs,
|
|
163
|
+
):
|
|
164
|
+
self.secret_raw = secret
|
|
165
|
+
super().__init__(key, secret, **kwargs)
|
|
166
|
+
|
|
167
|
+
def get_object_cdn_url(self, obj: Object, ex_expiry: float = 24, **kwargs):
|
|
168
|
+
sas = generate_blob_sas(
|
|
169
|
+
self.key,
|
|
170
|
+
obj.container.name,
|
|
171
|
+
obj.name,
|
|
172
|
+
account_key=self.secret_raw,
|
|
173
|
+
permission="r",
|
|
174
|
+
expiry=datetime.utcnow() + timedelta(hours=ex_expiry),
|
|
175
|
+
**kwargs,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return "{scheme}://{host}:{port}{action}?{sas_token}".format(
|
|
179
|
+
scheme="https" if self.secure else "http",
|
|
180
|
+
host=self.connection.host,
|
|
181
|
+
port=self.connection.port,
|
|
182
|
+
action=self.connection.morph_action_hook(
|
|
183
|
+
self._get_object_path(obj.container, obj.name)
|
|
184
|
+
),
|
|
185
|
+
sas_token=sas,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
overrided_providers = {Provider.AZURE_BLOBS: AzureBlobsStorageDriverOverride}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def get_driver(provider):
|
|
193
|
+
return overrided_providers.get(provider) or _get_driver(provider)
|
|
@@ -4,6 +4,7 @@ Sentinel interpreter for jac code in AST form
|
|
|
4
4
|
This interpreter should be inhereted from the class that manages state
|
|
5
5
|
referenced through self.
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from jaseci.prim.node import Node
|
|
8
9
|
from jaseci.prim.edge import Edge
|
|
9
10
|
from jaseci.prim.walker import Walker
|
|
@@ -206,9 +207,13 @@ class ArchitypeInterp(Interp):
|
|
|
206
207
|
.get_jac_ast()
|
|
207
208
|
.kid[-1]
|
|
208
209
|
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
(
|
|
211
|
+
self.run_attr_block(super_jac_ast, item)
|
|
212
|
+
if not isinstance(item, Walker)
|
|
213
|
+
else self.run_walker_block(super_jac_ast, item)
|
|
214
|
+
)
|
|
215
|
+
(
|
|
216
|
+
self.run_attr_block(jac_ast, item)
|
|
217
|
+
if not isinstance(item, Walker)
|
|
218
|
+
else self.run_walker_block(jac_ast, item)
|
|
219
|
+
)
|
jaseci/jac/interpreter/interp.py
CHANGED
|
@@ -4,6 +4,7 @@ Interpreter for jac code in AST form
|
|
|
4
4
|
This interpreter should be inhereted from the class that manages state
|
|
5
5
|
referenced through self.
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from jaseci.jsorc.jsorc import JsOrc
|
|
8
9
|
from jaseci.extens.svc.task_svc import TaskService
|
|
9
10
|
from jaseci.utils.utils import is_jsonable, parse_str_token, uuid_re
|
|
@@ -23,6 +24,7 @@ from json import dumps, loads
|
|
|
23
24
|
from copy import copy, deepcopy
|
|
24
25
|
from base64 import b64decode
|
|
25
26
|
from itertools import pairwise
|
|
27
|
+
from types import GeneratorType
|
|
26
28
|
|
|
27
29
|
from jaseci.jac.jsci_vm.op_codes import JsCmp
|
|
28
30
|
|
|
@@ -156,13 +158,15 @@ class Interp(VirtualMachine):
|
|
|
156
158
|
self._jac_try_mode += 1
|
|
157
159
|
try:
|
|
158
160
|
self.run_code_block(kid[1])
|
|
161
|
+
self._jac_try_mode -= 1
|
|
159
162
|
except TryException as e:
|
|
163
|
+
self._jac_try_mode -= 1
|
|
160
164
|
if len(kid) > 2:
|
|
161
165
|
self.run_else_from_try(kid[2], e.ref)
|
|
162
166
|
except Exception as e:
|
|
167
|
+
self._jac_try_mode -= 1
|
|
163
168
|
if len(kid) > 2:
|
|
164
169
|
self.run_else_from_try(kid[2], self.jac_exception(e, kid[2]))
|
|
165
|
-
self._jac_try_mode -= 1
|
|
166
170
|
|
|
167
171
|
def run_else_from_try(self, jac_ast, jac_ex):
|
|
168
172
|
"""
|
|
@@ -228,7 +232,7 @@ class Interp(VirtualMachine):
|
|
|
228
232
|
self.run_expression(kid[3])
|
|
229
233
|
lst = self.pop().value
|
|
230
234
|
|
|
231
|
-
if isinstance(lst, (list, dict)):
|
|
235
|
+
if isinstance(lst, (list, dict, GeneratorType)):
|
|
232
236
|
for i in lst:
|
|
233
237
|
self._loop_ctrl = None
|
|
234
238
|
var.value = i
|
|
@@ -324,13 +328,24 @@ class Interp(VirtualMachine):
|
|
|
324
328
|
"""
|
|
325
329
|
destroy_action: KW_DESTROY expression SEMI;
|
|
326
330
|
"""
|
|
331
|
+
from jaseci.prim.ability import Ability
|
|
332
|
+
|
|
327
333
|
kid = self.set_cur_ast(jac_ast)
|
|
328
334
|
self.run_expression(kid[1])
|
|
329
335
|
result = self.pop()
|
|
336
|
+
|
|
337
|
+
destroy_node_ids = None
|
|
338
|
+
if isinstance(self, Ability):
|
|
339
|
+
# currently, only walker process destroy_node_ids
|
|
340
|
+
# ability should be able to trigger destroy but still connected to current walker
|
|
341
|
+
destroy_node_ids = self._jac_scope.local_scope["visitor"].destroy_node_ids
|
|
342
|
+
else:
|
|
343
|
+
destroy_node_ids = self.destroy_node_ids
|
|
344
|
+
|
|
330
345
|
if isinstance(result.value, Element):
|
|
331
|
-
|
|
346
|
+
destroy_node_ids.add_obj(result.value)
|
|
332
347
|
elif isinstance(result.value, JacSet):
|
|
333
|
-
|
|
348
|
+
destroy_node_ids.add_obj_list(result.value)
|
|
334
349
|
result.self_destruct(kid[1])
|
|
335
350
|
|
|
336
351
|
def run_report_action(self, jac_ast):
|
|
@@ -4,6 +4,7 @@ Sentinel interpreter for jac code in AST form
|
|
|
4
4
|
This interpreter should be inhereted from the class that manages state
|
|
5
5
|
referenced through self.
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from jaseci.prim.architype import Architype
|
|
8
9
|
from jaseci.jac.interpreter.interp import Interp
|
|
9
10
|
from jaseci.utils.utils import parse_str_token
|
|
@@ -215,8 +216,10 @@ class SentinelInterp(Interp):
|
|
|
215
216
|
);
|
|
216
217
|
"""
|
|
217
218
|
kid = self.set_cur_ast(jac_ast)
|
|
218
|
-
|
|
219
|
-
kid[
|
|
219
|
+
(
|
|
220
|
+
self.run_multistring(kid[2])
|
|
221
|
+
if kid[1].name == "NAME"
|
|
222
|
+
else self.run_multistring(kid[1])
|
|
220
223
|
)
|
|
221
224
|
testcase = {
|
|
222
225
|
"name": kid[1].token_text() if kid[1].name == "NAME" else "",
|
|
@@ -4,6 +4,7 @@ Walker interpreter for jac code in AST form
|
|
|
4
4
|
This interpreter should be inhereted from the class that manages state
|
|
5
5
|
referenced through self.
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from jaseci.prim.node import Node
|
|
8
9
|
from jaseci.jac.interpreter.interp import Interp
|
|
9
10
|
from jaseci.jac.jac_set import JacSet
|
jaseci/jac/ir/jac_code.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Mix in for jac code object in Jaseci
|
|
3
3
|
"""
|
|
4
|
+
|
|
4
5
|
import json
|
|
5
6
|
from jaseci.utils.utils import logger
|
|
6
7
|
from jaseci.jac.ir.ast_builder import JacAstBuilder
|
|
@@ -93,9 +94,7 @@ class JacCode:
|
|
|
93
94
|
self.code_ir = (
|
|
94
95
|
ir.strip()
|
|
95
96
|
if (isinstance(ir, str))
|
|
96
|
-
else json.dumps(ir)
|
|
97
|
-
if (isinstance(ir, dict))
|
|
98
|
-
else jac_ast_to_ir(ir)
|
|
97
|
+
else json.dumps(ir) if (isinstance(ir, dict)) else jac_ast_to_ir(ir)
|
|
99
98
|
)
|
|
100
99
|
self.code_sig = hashlib.md5(self.code_ir.encode()).hexdigest()
|
|
101
100
|
JacCode.refresh(self) # should disregard overloaded versions
|
jaseci/jac/jac_set.py
CHANGED
jaseci/jac/machine/jac_scope.py
CHANGED
jaseci/jac/machine/jac_value.py
CHANGED
|
@@ -4,6 +4,7 @@ Interpreter for jac code in AST form
|
|
|
4
4
|
This interpreter should be inhereted from the class that manages state
|
|
5
5
|
referenced through self.
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from copy import copy
|
|
8
9
|
from jaseci.utils.utils import logger, exc_stack_as_str_list, generate_stack_as_str_list
|
|
9
10
|
from jaseci.jsorc.live_actions import live_actions, load_preconfig_actions
|
|
@@ -99,9 +100,11 @@ class MachineState:
|
|
|
99
100
|
"u_calls": 0 if name in MachineState.recur_detect_set else 1,
|
|
100
101
|
"tot_time": self._jac_scope._total_time
|
|
101
102
|
+ (time.time() - self._jac_scope._start_time),
|
|
102
|
-
"cum_time":
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
"cum_time": (
|
|
104
|
+
0
|
|
105
|
+
if name in MachineState.recur_detect_set
|
|
106
|
+
else time.time() - self._jac_scope._cum_start_time
|
|
107
|
+
),
|
|
105
108
|
}
|
|
106
109
|
else:
|
|
107
110
|
c = self._mast._jac_profile[name]["calls"]
|
|
@@ -210,13 +213,21 @@ class MachineState:
|
|
|
210
213
|
def inherit_runtime_state(self, mach):
|
|
211
214
|
"""Inherits runtime output state from another machine"""
|
|
212
215
|
self.report += mach.report
|
|
216
|
+
mach.report = []
|
|
213
217
|
if mach.report_status:
|
|
214
218
|
self.report_status = mach.report_status
|
|
219
|
+
mach.report_status = None
|
|
215
220
|
if mach.report_custom:
|
|
216
221
|
self.report_custom = mach.report_custom
|
|
222
|
+
mach.report_custom = None
|
|
217
223
|
if mach.report_file:
|
|
218
224
|
self.report_file = mach.report_file
|
|
225
|
+
mach.report_file = None
|
|
219
226
|
self.runtime_errors += mach.runtime_errors
|
|
227
|
+
mach.runtime_errors = []
|
|
228
|
+
mach.runtime_stack_trace = []
|
|
229
|
+
mach._loop_ctrl = None
|
|
230
|
+
mach._stopped = None
|
|
220
231
|
|
|
221
232
|
def obj_set_to_jac_set(self, obj_set):
|
|
222
233
|
"""
|
jaseci/jsorc/jsorc.py
CHANGED
|
@@ -84,7 +84,7 @@ class JsOrc:
|
|
|
84
84
|
@classmethod
|
|
85
85
|
def run(cls):
|
|
86
86
|
if not cls.__running__:
|
|
87
|
-
cls.__running__
|
|
87
|
+
cls.__running__ = True
|
|
88
88
|
cls.configure()
|
|
89
89
|
cls.push_interval(1)
|
|
90
90
|
|
|
@@ -264,6 +264,32 @@ class JsOrc:
|
|
|
264
264
|
|
|
265
265
|
return cls._service_instances[service]
|
|
266
266
|
|
|
267
|
+
@classmethod
|
|
268
|
+
def svc_conf_set(
|
|
269
|
+
cls, service: str, config: dict, hook: None, cast: T = None
|
|
270
|
+
) -> Union[T, cs]:
|
|
271
|
+
from jaseci.extens.svc.kube_svc import KubeService
|
|
272
|
+
|
|
273
|
+
if service not in cls._services:
|
|
274
|
+
raise Exception(f"Service {service} is not existing!")
|
|
275
|
+
|
|
276
|
+
if cls.db_check():
|
|
277
|
+
instance = cls._services[service][0]
|
|
278
|
+
hook = hook or cls.hook(use_proxy=instance["proxy"])
|
|
279
|
+
hook.save_glob(instance["config"], dumps(config))
|
|
280
|
+
hook.commit()
|
|
281
|
+
|
|
282
|
+
kube = cls.svc("kube", KubeService)
|
|
283
|
+
if kube.is_running() and kube.has_replicas():
|
|
284
|
+
hook.clear_cache(True)
|
|
285
|
+
return (
|
|
286
|
+
"Rollout restart commencing..."
|
|
287
|
+
if not isinstance(kube.restart(), ApiException)
|
|
288
|
+
else "Attempt to rollout restart failed! Please check the logs for further information!"
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
return cls.svc_reset(service).info()
|
|
292
|
+
|
|
267
293
|
@classmethod
|
|
268
294
|
def svc_reset(cls, service, cast: T = None) -> Union[T, cs]:
|
|
269
295
|
"""
|
|
@@ -333,7 +359,7 @@ class JsOrc:
|
|
|
333
359
|
target=cls._services,
|
|
334
360
|
entry={
|
|
335
361
|
"type": service,
|
|
336
|
-
"config": config or f"{name.upper()
|
|
362
|
+
"config": (config or f"{name}_CONFIG").upper(),
|
|
337
363
|
"manifest": manifest,
|
|
338
364
|
"manifest_type": manifest_type,
|
|
339
365
|
"priority": priority,
|
jaseci/jsorc/jsorc_utils.py
CHANGED
|
@@ -284,3 +284,15 @@ class CommonService:
|
|
|
284
284
|
# for build on pickle load
|
|
285
285
|
self.state = State.FAILED
|
|
286
286
|
del self
|
|
287
|
+
|
|
288
|
+
# ------------------- COMMON -------------------- #
|
|
289
|
+
|
|
290
|
+
def info(self):
|
|
291
|
+
return {
|
|
292
|
+
"enabled": self.enabled,
|
|
293
|
+
"automated": self.automated,
|
|
294
|
+
"quiet": self.quiet,
|
|
295
|
+
"state": self.state.name,
|
|
296
|
+
"config": self.config,
|
|
297
|
+
"error": str(self.error) if self.error else None,
|
|
298
|
+
}
|
jaseci/jsorc/live_actions.py
CHANGED
|
@@ -5639,6 +5639,7 @@ spec:
|
|
|
5639
5639
|
serviceAccountName: elastic-operator
|
|
5640
5640
|
securityContext:
|
|
5641
5641
|
runAsNonRoot: true
|
|
5642
|
+
fsGroup: 65534
|
|
5642
5643
|
containers:
|
|
5643
5644
|
- image: "docker.elastic.co/eck/eck-operator:2.7.0"
|
|
5644
5645
|
imagePullPolicy: IfNotPresent
|
|
@@ -6000,6 +6001,10 @@ spec:
|
|
|
6000
6001
|
count: 1
|
|
6001
6002
|
config:
|
|
6002
6003
|
node.store.allow_mmap: false
|
|
6004
|
+
http.cors.enabled: true
|
|
6005
|
+
http.cors.allow-origin: "*"
|
|
6006
|
+
http.cors.allow-methods: OPTIONS, POST, GET
|
|
6007
|
+
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization, Access-Control-Allow-Headers, Accept
|
|
6003
6008
|
volumeClaimTemplates:
|
|
6004
6009
|
- metadata:
|
|
6005
6010
|
name: elasticsearch-data
|
jaseci/jsorc/memory.py
CHANGED
jaseci/jsorc/redis.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
This module includes code related to hooking Jaseci's Redis to the
|
|
3
3
|
core engine.
|
|
4
4
|
"""
|
|
5
|
+
|
|
5
6
|
import json
|
|
6
7
|
|
|
7
8
|
import jaseci as core_mod
|
|
@@ -131,11 +132,9 @@ class RedisHook(MemoryHook):
|
|
|
131
132
|
# CLEANER #
|
|
132
133
|
###################################################
|
|
133
134
|
|
|
134
|
-
def clear_cache(self):
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
MemoryHook.__init__(self)
|
|
135
|
+
def clear_cache(self, all=False):
|
|
136
|
+
super().clear_cache(all)
|
|
137
|
+
self.redis.clear(all)
|
|
139
138
|
|
|
140
139
|
|
|
141
140
|
# ----------------------------------------------- #
|
jaseci/jsorc/remote_actions.py
CHANGED
jaseci/prim/ability.py
CHANGED
|
@@ -3,6 +3,7 @@ Action class for Jaseci
|
|
|
3
3
|
|
|
4
4
|
Each action has an id, name, timestamp and it's set of edges.
|
|
5
5
|
"""
|
|
6
|
+
|
|
6
7
|
from jaseci.prim.element import Element
|
|
7
8
|
from jaseci.jsorc.live_actions import live_actions
|
|
8
9
|
from jaseci.jac.jac_set import JacSet
|
|
@@ -34,7 +35,6 @@ class Ability(Element, JacCode, Interp):
|
|
|
34
35
|
"""
|
|
35
36
|
Run ability
|
|
36
37
|
"""
|
|
37
|
-
Interp.__init__(self) # Reset before as result need to be absorbed after
|
|
38
38
|
self.push_scope(
|
|
39
39
|
JacScope(
|
|
40
40
|
parent=self,
|
|
@@ -66,22 +66,17 @@ class Ability(Element, JacCode, Interp):
|
|
|
66
66
|
action_manager.pre_action_call_hook()
|
|
67
67
|
|
|
68
68
|
ts = time.time()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
**param_list["kwargs"],
|
|
73
|
-
meta={
|
|
69
|
+
try:
|
|
70
|
+
if "meta" in args:
|
|
71
|
+
param_list["kwargs"]["meta"] = {
|
|
74
72
|
"m_id": scope.parent._m_id,
|
|
75
73
|
"h": scope.parent._h,
|
|
76
74
|
"scope": scope,
|
|
77
75
|
"interp": interp,
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
result = func(*param_list["args"], **param_list["kwargs"])
|
|
83
|
-
except Exception as e:
|
|
84
|
-
interp.rt_error(e, jac_ast, True)
|
|
76
|
+
}
|
|
77
|
+
result = func(*param_list["args"], **param_list["kwargs"])
|
|
78
|
+
except Exception as e:
|
|
79
|
+
interp.rt_error(e, jac_ast, True)
|
|
85
80
|
t = time.time() - ts
|
|
86
81
|
action_manager.post_action_call_hook(action_name, t)
|
|
87
82
|
return result
|
jaseci/prim/architype.py
CHANGED
|
@@ -4,6 +4,7 @@ Architype class for Jaseci
|
|
|
4
4
|
Each architype is a registered templatized version of instances of any Jaseci
|
|
5
5
|
abstractions or collections of instances (e.g., subgraphs, etc)
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from jaseci.prim.element import Element
|
|
8
9
|
from jaseci.jac.interpreter.architype_interp import ArchitypeInterp
|
|
9
10
|
from jaseci.jac.ir.jac_code import JacCode
|