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
jaseci/utils/id_list.py DELETED
@@ -1,168 +0,0 @@
1
- """
2
- ID list class for Jaseci
3
-
4
- Generalized functions for managing '_ids' convention for lists of Jaseci
5
- objects
6
-
7
- parent_obj is the instance that the list belongs to
8
- """
9
- from jaseci.utils.utils import logger
10
-
11
-
12
- class IdList(list):
13
- """
14
- ID list class for tracking lists of objects in Jaseci
15
-
16
- ingest_list is a list of hex strings to convert to UUID and append.
17
- """
18
-
19
- def __init__(self, parent_obj, auto_save=True, in_list=None):
20
- self.parent_obj = parent_obj
21
- self.cached_objects = []
22
- self.heal_list = []
23
- self.auto_save = auto_save
24
- if in_list:
25
- self.extend(in_list)
26
-
27
- def cache_reset(self):
28
- self.cached_objects = []
29
-
30
- def add_obj(
31
- self, obj, push_front=False, allow_dups=False, silent=False, bypass=False
32
- ):
33
- """Adds a obj obj to Jaseci object"""
34
- self.parent_obj.check_hooks_match(obj)
35
- if not allow_dups and obj.jid in self:
36
- if not silent:
37
- logger.warning(str(f"{obj} is already in {self.parent_obj}'s list"))
38
- else:
39
- self.cache_reset()
40
- if push_front:
41
- self.insert(0, obj.jid)
42
- else:
43
- self.append(obj.jid)
44
-
45
- if not bypass:
46
- if not obj.j_parent:
47
- obj.j_parent = self.parent_obj.jid
48
- self.save(obj)
49
- self.save()
50
-
51
- def add_obj_list(self, obj_list, push_front=False, allow_dups=False, silent=False):
52
- self.cache_reset()
53
- if push_front:
54
- obj_list.reverse()
55
- for i in obj_list:
56
- self.add_obj(i, push_front=push_front, allow_dups=allow_dups, silent=silent)
57
-
58
- def remove_obj(self, obj):
59
- """Remove a Jaseci obj from list"""
60
- self.cache_reset()
61
- self.remove(obj.jid)
62
- self.save()
63
-
64
- def heal(self):
65
- for i in self.heal_list:
66
- self.remove(i)
67
- if len(self.heal_list) and hasattr(self.parent_obj, "save"):
68
- self.save()
69
- self.heal_list = []
70
-
71
- def destroy_obj(self, obj):
72
- """Completely destroys a Jaseci obj obj by it's name"""
73
- self.remove_obj(obj)
74
- obj.destroy()
75
-
76
- def obj_for_id_not_exist_error(self, item_id):
77
- self.heal_list.append(item_id)
78
- my_name = "id_list"
79
- for k, v in self.parent_obj.__dict__.items():
80
- if id(v) == id(self):
81
- my_name = k
82
- return f"{item_id} not found in {my_name} of {self.parent_obj}!"
83
-
84
- def get_obj_by_name(self, name, kind=None, silent=False):
85
- """Returns a Jaseci obj obj by it's name"""
86
- ret = None
87
- for i in self:
88
- obj = self.parent_obj._h.get_obj(self.parent_obj._m_id, i)
89
- if not obj:
90
- logger.critical(self.obj_for_id_not_exist_error(i))
91
- continue
92
- if obj.name == name:
93
- if kind and obj.kind != kind:
94
- continue
95
- ret = obj
96
- break
97
- if not ret and not silent:
98
- logger.error(str(f"object for '{name}' not found in '{self.parent_obj}'!"))
99
- self.heal()
100
- return ret
101
-
102
- def has_obj_by_name(self, name, kind=None):
103
- """Returns whether a Jaseci obj exists by it's name"""
104
- return self.get_obj_by_name(name, kind, silent=True) is not None
105
-
106
- def remove_obj_by_name(self, name, kind=None):
107
- """Remove a Jaseci obj by it's name"""
108
- self.remove_obj(self.get_obj_by_name(name, kind))
109
-
110
- def destroy_obj_by_name(self, name, kind=None):
111
- """Destroy a Jaseci obj by it's name"""
112
- self.destroy_obj(self.get_obj_by_name(name, kind))
113
-
114
- def obj_list(self):
115
- """Return list of objects from ids"""
116
- if not len(self.cached_objects):
117
- for i in self:
118
- obj = self.parent_obj._h.get_obj(self.parent_obj._m_id, i)
119
- if not obj:
120
- logger.critical(self.obj_for_id_not_exist_error(i))
121
- else:
122
- self.cached_objects.append(obj)
123
- self.heal()
124
- return self.cached_objects.copy()
125
-
126
- def remove_all(self):
127
- """Remove a Jaseci obj obj by it's name"""
128
- for i in self.obj_list():
129
- self.remove_obj(i)
130
- if len(self):
131
- logger.critical(
132
- str(
133
- f"Remove all failed in id_list of {self.parent_obj} - "
134
- + f"still has {self}!"
135
- )
136
- )
137
-
138
- def destroy_all(self):
139
- """Remove a Jaseci obj obj by it's name"""
140
- for i in self.obj_list():
141
- self.destroy_obj(i)
142
- if len(self):
143
- logger.critical(
144
- str(
145
- f"Destroy all failed in id_list of {self.parent_obj} - "
146
- + f"still has {self}!"
147
- )
148
- )
149
-
150
- def first_obj(self):
151
- """Get first object in list"""
152
- if not self:
153
- logger.error(str(f"List in '{self.parent_obj}' is empty!"))
154
- return None
155
- return self.parent_obj._h.get_obj(self.parent_obj._m_id, self[0])
156
-
157
- def pop_first_obj(self):
158
- """Get first object in list"""
159
- ret = self.first_obj()
160
- if ret:
161
- self.remove_obj(ret)
162
- return ret
163
-
164
- def save(self, obj=None):
165
- if self.auto_save:
166
- self.parent_obj.save()
167
- if obj:
168
- obj.save()
@@ -1,70 +0,0 @@
1
- import json
2
- from json import JSONDecoder, JSONEncoder
3
-
4
- from jaseci.jsorc.jsorc import JsOrc
5
- from jaseci.utils.id_list import IdList
6
- from jaseci.utils.utils import logger
7
-
8
-
9
- class JaseciJsonEncoder(JSONEncoder):
10
- def default(self, obj):
11
- from jaseci.prim.element import Element
12
-
13
- if isinstance(obj, Element):
14
- return {"__mem_id__": obj.jid}
15
- else:
16
- return super().default(obj)
17
-
18
-
19
- class JaseciJsonDecoder(JSONDecoder):
20
- def __init__(self, *args, **kwargs):
21
- JSONDecoder.__init__(self, object_hook=self.object_hook, *args, **kwargs)
22
-
23
- def object_hook(self, obj):
24
- if isinstance(obj, dict):
25
- if "__mem_id__" in obj:
26
- return self.convert(obj["__mem_id__"])
27
- else:
28
- for k in obj:
29
- self.transform(obj, k)
30
- elif isinstance(obj, (list, tuple)):
31
- for idx, k in enumerate(obj):
32
- self.transform(obj, idx)
33
- return obj
34
-
35
- def transform(self, obj, key):
36
- if isinstance(obj[key], dict):
37
- if "__mem_id__" in obj[key]:
38
- obj[key] = self.convert(obj[key]["__mem_id__"])
39
- else:
40
- for k in obj[key]:
41
- self.transform(obj[key], k)
42
- elif isinstance(obj[key], (list, tuple)):
43
- for idx, k in enumerate(obj[key]):
44
- self.transform(obj[key], idx)
45
-
46
- def convert(self, urn):
47
- return JsOrc.hook().get_obj_from_store(urn)
48
-
49
-
50
- def json_str_to_jsci_dict(input_str, parent_obj=None):
51
- """
52
- Helper function to convert JSON strings to dictionarys with _ids list
53
- conversions from hex to UUID
54
-
55
- ret_obj is the owning object for id_list objects
56
- """
57
-
58
- try:
59
- obj_fields = json.loads(input_str, cls=JaseciJsonDecoder)
60
- except ValueError:
61
- logger.error(str(f"Invalid jsci_obj string {input_str} on {parent_obj.jid}"))
62
- obj_fields = {}
63
- jsci_dict_normalize(obj_fields, parent_obj)
64
- return obj_fields
65
-
66
-
67
- def jsci_dict_normalize(obj_fields, parent_obj):
68
- for i in obj_fields.keys():
69
- if str(i).endswith("_ids") and isinstance(obj_fields[i], list):
70
- obj_fields[i] = IdList(parent_obj=parent_obj, in_list=obj_fields[i])
jaseci/utils/log_utils.py DELETED
@@ -1,57 +0,0 @@
1
- from io import StringIO
2
- import re
3
- from typing import List, Dict
4
-
5
-
6
- def match_date(line: str) -> str:
7
- """Extracts the date from a log line"""
8
- matched = re.match(r"\d\d\d\d-\d\d-\d\d\ \d\d:\d\d:\d\d", line)
9
- if matched:
10
- return matched.group()
11
-
12
- return None
13
-
14
-
15
- def match_level(line: str) -> str:
16
- """Extracts the level from a log line"""
17
- matched = re.search(r"-\s(ERROR|WARNING|INFO|DEBUG)\s-", line)
18
- if matched:
19
- [level] = matched.groups()
20
- return level
21
-
22
- return None
23
-
24
-
25
- def parse_logs(logs: List[str]) -> List[Dict[str, str]]:
26
- """Convert log lines into an object with log metadata"""
27
- result = []
28
- for log in logs:
29
- date = match_date(log)
30
- level = match_level(log)
31
- result.append({"date": date, "level": level, "log": log})
32
-
33
- return result
34
-
35
-
36
- class LimitedSlidingBuffer(StringIO):
37
- def __init__(self, buffer=None, max_size=5 * 1000 * 1000) -> None:
38
- """A string buffer that accepts a maximum length."""
39
- StringIO.__init__(self, buffer)
40
- self.current_size = 0
41
- self.max_size = max_size
42
-
43
- def write(self, str: str):
44
- self.current_size += len(str)
45
- ret = StringIO.write(self, str)
46
-
47
- if self.current_size > self.max_size:
48
- new_size = min(int(self.current_size / 2), self.max_size)
49
- keep_str = self.getvalue()
50
- if len(keep_str) > 1:
51
- keep_str = keep_str[len(keep_str) - new_size :]
52
- self.truncate(0)
53
- self.seek(0)
54
- StringIO.write(self, keep_str)
55
- self.current_size = new_size
56
-
57
- return ret
jaseci/utils/test_core.py DELETED
@@ -1,62 +0,0 @@
1
- import os
2
- import unittest
3
- from unittest import TestCase
4
-
5
- from jaseci.jsorc.jsorc import JsOrc
6
- from jaseci.utils.utils import TestCaseHelper
7
-
8
-
9
- class CoreTest(TestCaseHelper, TestCase):
10
- """Unit tests for Jac Core APIs"""
11
-
12
- fixture_src = __file__
13
-
14
- def setUp(self):
15
- super().setUp()
16
- self.smast = JsOrc.super_master()
17
- self.mast = JsOrc.master(h=self.smast._h)
18
-
19
- def tearDown(self):
20
- super().tearDown()
21
-
22
- def call(self, mast, pl):
23
- ret = mast.general_interface_to_api(api_name=pl[0], params=pl[1])
24
- return ret
25
-
26
- def load_jac(self, fn):
27
- with open(os.path.dirname(self.fixture_src) + "/fixtures/" + fn) as f:
28
- return f.read()
29
-
30
-
31
- def jac_testcase(jac_file: str, test_name: str, log_out: bool = False):
32
- """decorator for test cases"""
33
-
34
- def decorator(func):
35
- def wrapper(self):
36
- if log_out:
37
- self.logger_on()
38
- self.call(
39
- self.mast,
40
- ["sentinel_register", {"code": self.load_jac(jac_file)}],
41
- )
42
- ret = self.call(self.mast, ["walker_run", {"name": test_name}])
43
- func(self, ret)
44
- if log_out:
45
- self.logger_off()
46
-
47
- return wrapper
48
-
49
- return decorator
50
-
51
-
52
- def skip_without_redis(test):
53
- """
54
- Skip test if expected not to work without redis.
55
- """
56
-
57
- def skipper(*args, **kwargs):
58
- if not JsOrc.svc("redis").is_running():
59
- raise unittest.SkipTest("No Redis!")
60
- test(*args, **kwargs)
61
-
62
- return skipper