ripple-down-rules 0.5.81__py3-none-any.whl → 0.5.83__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.
- ripple_down_rules/__init__.py +1 -1
- ripple_down_rules/rdr.py +8 -4
- ripple_down_rules/rdr_decorators.py +8 -4
- ripple_down_rules/utils.py +4 -3
- {ripple_down_rules-0.5.81.dist-info → ripple_down_rules-0.5.83.dist-info}/METADATA +1 -1
- {ripple_down_rules-0.5.81.dist-info → ripple_down_rules-0.5.83.dist-info}/RECORD +9 -9
- {ripple_down_rules-0.5.81.dist-info → ripple_down_rules-0.5.83.dist-info}/WHEEL +0 -0
- {ripple_down_rules-0.5.81.dist-info → ripple_down_rules-0.5.83.dist-info}/licenses/LICENSE +0 -0
- {ripple_down_rules-0.5.81.dist-info → ripple_down_rules-0.5.83.dist-info}/top_level.txt +0 -0
ripple_down_rules/__init__.py
CHANGED
ripple_down_rules/rdr.py
CHANGED
@@ -1147,12 +1147,16 @@ class GeneralRDR(RippleDownRules):
|
|
1147
1147
|
is required in case of relative imports in the generated python file.
|
1148
1148
|
:return: The imports needed for the generated python file.
|
1149
1149
|
"""
|
1150
|
+
all_types = set()
|
1151
|
+
# add type hints
|
1152
|
+
all_types.update({Dict, Any})
|
1153
|
+
# import rdr type
|
1154
|
+
all_types.add(general_rdr_classify)
|
1155
|
+
# add case type
|
1156
|
+
all_types.update({Case, create_case, self.case_type})
|
1150
1157
|
# get the imports from the types
|
1151
|
-
imports = get_imports_from_types(
|
1158
|
+
imports = get_imports_from_types(all_types, target_file_path=file_path, package_name=package_name)
|
1152
1159
|
# add rdr python generated functions.
|
1153
|
-
imports.append("from typing import Dict, Any")
|
1154
|
-
imports.append("from ripple_down_rules.datastructures.case import Case, create_case")
|
1155
|
-
imports.append("from ripple_down_rules.helpers import general_rdr_classify")
|
1156
1160
|
for rdr_key, rdr in self.start_rules_dict.items():
|
1157
1161
|
imports.append(
|
1158
1162
|
f"from . import {rdr.generated_python_file_name} as {self.rdr_key_to_function_name(rdr_key)}")
|
@@ -31,7 +31,8 @@ class RDRDecorator:
|
|
31
31
|
expert: Optional[Expert] = None,
|
32
32
|
ask_always: bool = False,
|
33
33
|
update_existing_rules: bool = True,
|
34
|
-
viewer: Optional[RDRCaseViewer] = None
|
34
|
+
viewer: Optional[RDRCaseViewer] = None,
|
35
|
+
package_name: Optional[str] = None):
|
35
36
|
"""
|
36
37
|
:param models_dir: The directory to save/load the RDR models.
|
37
38
|
:param output_type: The type of the output. This is used to create the RDR model.
|
@@ -46,6 +47,8 @@ class RDRDecorator:
|
|
46
47
|
:param ask_always: If True, the function will ask the user for a target if it doesn't exist.
|
47
48
|
:param update_existing_rules: If True, the function will update the existing RDR rules
|
48
49
|
even if they gave an output.
|
50
|
+
:param viewer: The viewer to use for the RDR model. If None, no viewer will be used.
|
51
|
+
:param package_name: The package name to use for relative imports in the RDR model.
|
49
52
|
:return: A decorator to use a GeneralRDR as a classifier that monitors and modifies the function's output.
|
50
53
|
"""
|
51
54
|
self.rdr_models_dir = models_dir
|
@@ -59,6 +62,7 @@ class RDRDecorator:
|
|
59
62
|
self.ask_always = ask_always
|
60
63
|
self.update_existing_rules = update_existing_rules
|
61
64
|
self.viewer = viewer
|
65
|
+
self.package_name = package_name
|
62
66
|
self.load()
|
63
67
|
|
64
68
|
def decorator(self, func: Callable) -> Callable:
|
@@ -166,7 +170,7 @@ class RDRDecorator:
|
|
166
170
|
"""
|
167
171
|
Save the RDR model to the specified directory.
|
168
172
|
"""
|
169
|
-
self.rdr.save(self.rdr_models_dir)
|
173
|
+
self.rdr.save(self.rdr_models_dir, package_name=self.package_name)
|
170
174
|
|
171
175
|
def load(self):
|
172
176
|
"""
|
@@ -176,7 +180,7 @@ class RDRDecorator:
|
|
176
180
|
if self.model_name is not None:
|
177
181
|
model_path = os.path.join(self.rdr_models_dir, self.model_name + f"/rdr_metadata/{self.model_name}.json")
|
178
182
|
if os.path.exists(os.path.join(self.rdr_models_dir, model_path)):
|
179
|
-
self.rdr = GeneralRDR.load(self.rdr_models_dir, self.model_name)
|
183
|
+
self.rdr = GeneralRDR.load(self.rdr_models_dir, self.model_name, package_name=self.package_name)
|
180
184
|
self.rdr.set_viewer(self.viewer)
|
181
185
|
if self.rdr is None:
|
182
186
|
self.rdr = GeneralRDR(save_dir=self.rdr_models_dir, model_name=self.model_name,
|
@@ -186,4 +190,4 @@ class RDRDecorator:
|
|
186
190
|
"""
|
187
191
|
Update the RDR model from a python file.
|
188
192
|
"""
|
189
|
-
self.rdr.update_from_python(self.rdr_models_dir, self.model_name)
|
193
|
+
self.rdr.update_from_python(self.rdr_models_dir, self.model_name, package_name=self.package_name)
|
ripple_down_rules/utils.py
CHANGED
@@ -798,10 +798,11 @@ def get_import_path_from_path(path: str) -> Optional[str]:
|
|
798
798
|
:return: The Python import path.
|
799
799
|
"""
|
800
800
|
package_name = os.path.abspath(path)
|
801
|
-
|
801
|
+
packages = package_name.split(os.path.sep)
|
802
|
+
# formated_package_name = package_name.replace('/', '.')
|
802
803
|
parent_package_idx = 0
|
803
|
-
packages = formated_package_name.split('.')
|
804
|
-
for i
|
804
|
+
# packages = formated_package_name.split('.')
|
805
|
+
for i in range(len(packages)):
|
805
806
|
if i == 0:
|
806
807
|
current_path = package_name
|
807
808
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.83
|
4
4
|
Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
|
5
5
|
Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -1,11 +1,11 @@
|
|
1
|
-
ripple_down_rules/__init__.py,sha256=
|
1
|
+
ripple_down_rules/__init__.py,sha256=xixYpXbV9gGErJuj1TxFPGGMaaFTOvzOpHpkn65VVoU,100
|
2
2
|
ripple_down_rules/experts.py,sha256=bwozulI1rv0uyaMZQqEgapDO-s8wvW0D6Jqxmvu5fik,12610
|
3
3
|
ripple_down_rules/helpers.py,sha256=v4oE7C5PfQUVJfSUs1FfLHEwrJXEHJLn4vJhJMvyCR8,4453
|
4
|
-
ripple_down_rules/rdr.py,sha256=
|
5
|
-
ripple_down_rules/rdr_decorators.py,sha256=
|
4
|
+
ripple_down_rules/rdr.py,sha256=C6bvlq6MsKa2Mym1wW6JUMj705aCaoihTP279TM6eT0,55218
|
5
|
+
ripple_down_rules/rdr_decorators.py,sha256=amXUjgc-rfYxPKFW16Xm8Z9vfaaslNl5OvDOg9fKaTg,9447
|
6
6
|
ripple_down_rules/rules.py,sha256=iVevv6iZ-6L2IPI0ZYbBjxBymXEQMmJGRFhiKUS-NmA,20352
|
7
7
|
ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
|
8
|
-
ripple_down_rules/utils.py,sha256=
|
8
|
+
ripple_down_rules/utils.py,sha256=ikzlXjgBWM95dgL-idzeWcYyZs2IAwgA5BXMNRoKE2w,60144
|
9
9
|
ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
|
10
10
|
ripple_down_rules/datastructures/callable_expression.py,sha256=f3wUPTrLa1INO-1qfgVz87ryrCABronfyq0_JKWoZCs,12800
|
11
11
|
ripple_down_rules/datastructures/case.py,sha256=1zSaXUljaH6z3SgMGzYPoDyjotNam791KpYgvxuMh90,15463
|
@@ -17,8 +17,8 @@ ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=Jrf7NxOdlrwGXH0X
|
|
17
17
|
ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
|
18
18
|
ripple_down_rules/user_interface/prompt.py,sha256=AkkltdDIaioN43lkRKDPKSjJcmdSSGZDMYz7AL7X9lE,8082
|
19
19
|
ripple_down_rules/user_interface/template_file_creator.py,sha256=xWUt-RHRqrvoMo74o-bMLo8xNxil68wgbOZAMADZp2A,13570
|
20
|
-
ripple_down_rules-0.5.
|
21
|
-
ripple_down_rules-0.5.
|
22
|
-
ripple_down_rules-0.5.
|
23
|
-
ripple_down_rules-0.5.
|
24
|
-
ripple_down_rules-0.5.
|
20
|
+
ripple_down_rules-0.5.83.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
21
|
+
ripple_down_rules-0.5.83.dist-info/METADATA,sha256=PGZ_KSayeTFDv3fTPBln3u3AzWwilfHgRdkHz5i-dv8,48214
|
22
|
+
ripple_down_rules-0.5.83.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
ripple_down_rules-0.5.83.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
|
24
|
+
ripple_down_rules-0.5.83.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|