ripple-down-rules 0.5.86__tar.gz → 0.5.88__tar.gz
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-0.5.86 → ripple_down_rules-0.5.88}/PKG-INFO +1 -1
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/__init__.py +1 -1
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/experts.py +7 -3
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/rdr_decorators.py +3 -7
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/ipython_custom_shell.py +3 -1
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/prompt.py +31 -13
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/template_file_creator.py +1 -2
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/utils.py +26 -15
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/PKG-INFO +1 -1
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr.py +1 -1
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_helpers_rdrs.py +2 -5
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.github/workflows/build_and_deploy_doc.yml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.github/workflows/ci.yml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.github/workflows/publish-to-test-pypi.yml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.idea/shelf/Uncommitted_changes_before_Checkout_at_2_4_25,_6_32_PM_[Changes]/shelved.patch +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.idea/shelf/Uncommitted_changes_before_Checkout_at_2_4_25,_6_32_PM_[Changes]1/shelved.patch +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/LICENSE +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/README.md +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/_config.yml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/_toc.yml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/bibliography.md +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/intro.md +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/references.bib +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/doc/requirements.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/animal_species.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/rdr_metadata/part_containment_rdr.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/robot_contained_objects_mcrdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/robot_contained_objects_mcrdr_defs.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/robot_rdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/relational_example.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/images/scrdr.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/images/scrdr.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/images/thinking_pr2.jpg +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/pyproject.toml +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/pytest.ini +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/requirements-dev-ci.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/requirements-dev.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/requirements-gui.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/requirements-viz.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/requirements.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_extra.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_extra.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_only.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_only.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_plus_rule.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_plus_rule.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr_2.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr_2.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr_3.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_scrdr_3.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/grdr_Habitat.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/grdr_Habitat.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/grdr_Species.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/grdr_Species.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_extra.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_extra.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_extra_classify.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_extra_classify.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_stop_plus_rule_combined.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_stop_plus_rule_combined.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/partial_mcrdr_extra.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/partial_mcrdr_extra.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/relational_scrdr_classify.dot +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/relational_scrdr_classify.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/setup.cfg +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/callable_expression.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/case.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/dataclasses.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/enums.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/helpers.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/rdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/rules.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/start-code-server.sh +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/gui.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/object_diagram.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/SOURCES.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/dependency_links.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/requires.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/top_level.txt +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conf/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conf/world/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conf/world/base_config.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conf/world/handles_and_containers.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conftest.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/datasets.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/factories/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/factories/world/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/factories/world/handles_and_containers.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/correct_drawer_rdr_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/drawer_cabinet_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/grdr_expert_answers_classify.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/grdr_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/grdr_expert_answers_fit_extra.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/grdr_expert_answers_fit_no_targets.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_expert_answers_classify.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_expert_answers_fit_no_targets.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_expert_answers_stop_only_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_extra_expert_answers_classify.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_extra_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_multi_line_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_stop_only_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_stop_plus_rule_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_stop_plus_rule_combined_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mcrdr_stop_plus_rule_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/mutagenic_expert_answers.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/relational_scrdr_expert_answers_classify.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/scrdr_expert_answers_classify.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/scrdr_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/scrdr_expert_answers_fit_no_targets.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/scrdr_multi_line_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_expert_answers/scrdr_world_expert_answers_fit.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_generated_rdrs/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_helpers/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_helpers/helpers.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_helpers/object_diagram_case_query.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_helpers/object_diagram_person.png +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_json_serialization.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_object_diagram.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_on_mutagenic.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_alchemy.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_decorators.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_world/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_world/conftest.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_rdr_world/test_rdr_world.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_relational_rdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_relational_rdr_alchemy.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_is_a_robot/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_output__scrdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_output__scrdr_defs.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_is_a_robot/physical_object_is_a_robot_rdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_is_a_robot/rdr_metadata/datasets_physical_object_is_a_robot.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_output__mcrdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_output__mcrdr_defs.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/physical_object_select_objects_that_are_parts_of_robot_rdr.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_results/datasets_physical_object_select_objects_that_are_parts_of_robot/rdr_metadata/datasets_physical_object_select_objects_that_are_parts_of_robot.json +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_sql_model.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_template_file_creator.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/__init__.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_ipython.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_ipython_copilot.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_prompt.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_qt_gui_inline.py +0 -0
- {ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.88
|
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
|
@@ -252,6 +252,8 @@ class Human(Expert):
|
|
252
252
|
condition = CallableExpression(user_input, bool, scope=case_query.scope)
|
253
253
|
else:
|
254
254
|
user_input, condition = self.user_prompt.prompt_user_for_expression(case_query, PromptFor.Conditions)
|
255
|
+
if user_input == 'exit':
|
256
|
+
exit()
|
255
257
|
if not self.use_loaded_answers:
|
256
258
|
self.all_expert_answers.append((condition.scope, user_input))
|
257
259
|
if self.answers_save_path is not None:
|
@@ -284,11 +286,13 @@ class Human(Expert):
|
|
284
286
|
if self.user_prompt.viewer is None:
|
285
287
|
show_current_and_corner_cases(case_query.case)
|
286
288
|
expert_input, expression = self.user_prompt.prompt_user_for_expression(case_query, PromptFor.Conclusion)
|
287
|
-
if
|
289
|
+
if expert_input is None:
|
288
290
|
self.all_expert_answers.append(({}, None))
|
289
|
-
|
291
|
+
elif expert_input != 'exit':
|
290
292
|
self.all_expert_answers.append((expression.scope, expert_input))
|
291
|
-
if self.answers_save_path is not None:
|
293
|
+
if self.answers_save_path is not None and expert_input != 'exit':
|
292
294
|
self.save_answers()
|
295
|
+
if expert_input == 'exit':
|
296
|
+
exit()
|
293
297
|
case_query.target = expression
|
294
298
|
return expression
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/rdr_decorators.py
RENAMED
@@ -29,7 +29,6 @@ class RDRDecorator:
|
|
29
29
|
output_name: str = "output_",
|
30
30
|
fit: bool = True,
|
31
31
|
expert: Optional[Expert] = None,
|
32
|
-
ask_always: bool = False,
|
33
32
|
update_existing_rules: bool = True,
|
34
33
|
viewer: Optional[RDRCaseViewer] = None,
|
35
34
|
package_name: Optional[str] = None):
|
@@ -44,7 +43,6 @@ class RDRDecorator:
|
|
44
43
|
classification mode. This means that the RDR will classify the function's output based on the RDR model.
|
45
44
|
:param expert: The expert that will be used to prompt the user for the correct output. If None, a Human
|
46
45
|
expert will be used.
|
47
|
-
:param ask_always: If True, the function will ask the user for a target if it doesn't exist.
|
48
46
|
:param update_existing_rules: If True, the function will update the existing RDR rules
|
49
47
|
even if they gave an output.
|
50
48
|
:param viewer: The viewer to use for the RDR model. If None, no viewer will be used.
|
@@ -59,7 +57,6 @@ class RDRDecorator:
|
|
59
57
|
self.output_name = output_name
|
60
58
|
self.fit: bool = fit
|
61
59
|
self.expert: Optional[Expert] = expert
|
62
|
-
self.ask_always = ask_always
|
63
60
|
self.update_existing_rules = update_existing_rules
|
64
61
|
self.viewer = viewer
|
65
62
|
self.package_name = package_name
|
@@ -76,7 +73,7 @@ class RDRDecorator:
|
|
76
73
|
self.initialize_rdr_model_name_and_load(func)
|
77
74
|
if self.expert is None:
|
78
75
|
self.expert = Human(viewer=self.viewer,
|
79
|
-
answers_save_path=self.rdr_models_dir + f'/expert_answers')
|
76
|
+
answers_save_path=self.rdr_models_dir + f'/{self.model_name}/expert_answers')
|
80
77
|
|
81
78
|
func_output = {self.output_name: func(*args, **kwargs)}
|
82
79
|
|
@@ -86,7 +83,6 @@ class RDRDecorator:
|
|
86
83
|
self.mutual_exclusive,
|
87
84
|
*args, **kwargs)
|
88
85
|
output = self.rdr.fit_case(case_query, expert=self.expert,
|
89
|
-
ask_always_for_target=self.ask_always,
|
90
86
|
update_existing_rules=self.update_existing_rules,
|
91
87
|
viewer=self.viewer)
|
92
88
|
else:
|
@@ -170,7 +166,7 @@ class RDRDecorator:
|
|
170
166
|
"""
|
171
167
|
Save the RDR model to the specified directory.
|
172
168
|
"""
|
173
|
-
self.rdr.save(self.rdr_models_dir, package_name=self.package_name)
|
169
|
+
self.rdr.save(self.rdr_models_dir, self.model_name, package_name=self.package_name)
|
174
170
|
|
175
171
|
def load(self):
|
176
172
|
"""
|
@@ -190,4 +186,4 @@ class RDRDecorator:
|
|
190
186
|
"""
|
191
187
|
Update the RDR model from a python file.
|
192
188
|
"""
|
193
|
-
self.rdr.update_from_python(self.rdr_models_dir,
|
189
|
+
self.rdr.update_from_python(self.rdr_models_dir, package_name=self.package_name)
|
@@ -134,7 +134,9 @@ class IPythonShell:
|
|
134
134
|
"""
|
135
135
|
Update the user input from the code lines captured in the shell.
|
136
136
|
"""
|
137
|
-
if self.shell.all_lines[
|
137
|
+
if self.shell.all_lines[-1] in ['quit', 'exit']:
|
138
|
+
self.user_input = 'exit'
|
139
|
+
elif self.shell.all_lines[0].replace('return', '').strip() == '':
|
138
140
|
self.user_input = None
|
139
141
|
else:
|
140
142
|
self.all_code_lines = extract_dependencies(self.shell.all_lines)
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/prompt.py
RENAMED
@@ -20,12 +20,15 @@ from ..datastructures.dataclasses import CaseQuery
|
|
20
20
|
from ..datastructures.enums import PromptFor
|
21
21
|
from .ipython_custom_shell import IPythonShell
|
22
22
|
from ..utils import make_list
|
23
|
+
from threading import Lock
|
23
24
|
|
24
25
|
|
25
26
|
class UserPrompt:
|
26
27
|
"""
|
27
28
|
A class to handle user prompts for the RDR.
|
28
29
|
"""
|
30
|
+
shell_lock: Lock = Lock() # To ensure that only one thread can access the shell at a time
|
31
|
+
|
29
32
|
def __init__(self, viewer: Optional[RDRCaseViewer] = None):
|
30
33
|
"""
|
31
34
|
Initialize the UserPrompt class.
|
@@ -58,6 +61,10 @@ class UserPrompt:
|
|
58
61
|
else:
|
59
62
|
self.print_func(f"{Fore.RED}Conditions must be provided. Please try again.{Style.RESET_ALL}")
|
60
63
|
continue
|
64
|
+
elif user_input == "exit":
|
65
|
+
self.print_func(f"{Fore.YELLOW}Exiting.{Style.RESET_ALL}")
|
66
|
+
return user_input, None
|
67
|
+
|
61
68
|
prev_user_input = '\n'.join(user_input.split('\n')[2:-1])
|
62
69
|
conclusion_type = bool if prompt_for == PromptFor.Conditions else case_query.attribute_type
|
63
70
|
callable_expression = CallableExpression(user_input, conclusion_type, expression_tree=expression_tree,
|
@@ -139,19 +146,9 @@ class UserPrompt:
|
|
139
146
|
"""
|
140
147
|
while True:
|
141
148
|
if user_input is None:
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
user_input = shell.user_input
|
146
|
-
else:
|
147
|
-
app = QApplication.instance()
|
148
|
-
if app is None:
|
149
|
-
raise RuntimeError("QApplication instance is None. Please run the application first.")
|
150
|
-
self.viewer.show()
|
151
|
-
app.exec()
|
152
|
-
user_input = self.viewer.user_input
|
153
|
-
if user_input is None:
|
154
|
-
return None, None
|
149
|
+
user_input = self.start_shell_and_get_user_input(shell=shell)
|
150
|
+
if user_input is None or user_input == 'exit':
|
151
|
+
return user_input, None
|
155
152
|
self.print_func(f"{Fore.GREEN}Captured User input: {Style.RESET_ALL}")
|
156
153
|
highlighted_code = highlight(user_input, PythonLexer(), TerminalFormatter())
|
157
154
|
self.print_func(highlighted_code)
|
@@ -162,3 +159,24 @@ class UserPrompt:
|
|
162
159
|
logging.error(msg)
|
163
160
|
self.print_func(f"{Fore.RED}{msg}{Style.RESET_ALL}")
|
164
161
|
user_input = None
|
162
|
+
|
163
|
+
def start_shell_and_get_user_input(self, shell: Optional[IPythonShell] = None) -> Optional[str]:
|
164
|
+
"""
|
165
|
+
Start the shell and get user input.
|
166
|
+
|
167
|
+
:param shell: The Ipython shell to use for prompting the user.
|
168
|
+
:return: The user input.
|
169
|
+
"""
|
170
|
+
with self.shell_lock:
|
171
|
+
if self.viewer is None:
|
172
|
+
shell = IPythonShell() if shell is None else shell
|
173
|
+
shell.run()
|
174
|
+
user_input = shell.user_input
|
175
|
+
else:
|
176
|
+
app = QApplication.instance()
|
177
|
+
if app is None:
|
178
|
+
raise RuntimeError("QApplication instance is None. Please run the application first.")
|
179
|
+
self.viewer.show()
|
180
|
+
app.exec()
|
181
|
+
user_input = self.viewer.user_input
|
182
|
+
return user_input
|
@@ -222,10 +222,9 @@ class TemplateFileCreator:
|
|
222
222
|
if list in self.output_type:
|
223
223
|
output_type_imports.append(List)
|
224
224
|
import_types = list(self.case_query.scope.values())
|
225
|
-
# imports = [i for i in imports if ("get_ipython" not in i)]
|
226
225
|
import_types.extend(case_type_imports)
|
227
226
|
import_types.extend(output_type_imports)
|
228
|
-
imports = get_imports_from_types(import_types)
|
227
|
+
imports = get_imports_from_types(import_types, excluded_modules=["IPython.core.interactiveshell"])
|
229
228
|
imports = set(imports)
|
230
229
|
return '\n'.join(imports)
|
231
230
|
|
@@ -905,50 +905,60 @@ def get_path_starting_from_latest_encounter_of(path: str, package_name: str) ->
|
|
905
905
|
|
906
906
|
def get_imports_from_types(type_objs: Iterable[Type],
|
907
907
|
target_file_path: Optional[str] = None,
|
908
|
-
package_name: Optional[str] = None
|
908
|
+
package_name: Optional[str] = None,
|
909
|
+
exclueded_names: Optional[List[str]] = None,
|
910
|
+
excluded_modules: Optional[List[str]] = None) -> List[str]:
|
909
911
|
"""
|
910
912
|
Format import lines from type objects.
|
911
913
|
|
912
914
|
:param type_objs: A list of type objects to format.
|
913
915
|
:param target_file_path: The file path to which the imports should be relative.
|
914
916
|
:param package_name: The name of the package to use for relative imports.
|
917
|
+
:param exclueded_names: A list of names to exclude from the imports.
|
918
|
+
:param excluded_modules: A list of modules to exclude from the imports.
|
919
|
+
:return: A list of formatted import lines.
|
915
920
|
"""
|
916
|
-
|
921
|
+
excluded_modules = [] if excluded_modules is None else excluded_modules
|
922
|
+
exclueded_names = [] if exclueded_names is None else exclueded_names
|
917
923
|
module_to_types = defaultdict(list)
|
918
|
-
module_to_path = {}
|
919
|
-
other_imports = []
|
920
924
|
for tp in type_objs:
|
921
925
|
try:
|
922
926
|
if isinstance(tp, type) or is_typing_type(tp):
|
923
927
|
module = tp.__module__
|
924
|
-
file = getattr(tp, '__file__', None)
|
925
928
|
name = tp.__qualname__
|
926
929
|
elif callable(tp):
|
927
930
|
module, name = get_function_import_data(tp)
|
928
|
-
file = get_method_file_name(tp)
|
929
931
|
elif hasattr(type(tp), "__module__"):
|
930
932
|
module = type(tp).__module__
|
931
|
-
file = getattr(tp, '__file__', None)
|
932
933
|
name = type(tp).__qualname__
|
933
934
|
else:
|
934
935
|
continue
|
935
|
-
if module is None or module == 'builtins' or module.startswith('_')
|
936
|
+
if module is None or module == 'builtins' or module.startswith('_')\
|
937
|
+
or module in sys.builtin_module_names or module in excluded_modules or "<" in module \
|
938
|
+
or name in exclueded_names:
|
936
939
|
continue
|
937
940
|
module_to_types[module].append(name)
|
938
|
-
if file:
|
939
|
-
module_to_path[module] = file
|
940
941
|
except AttributeError:
|
941
942
|
continue
|
942
943
|
|
943
944
|
lines = []
|
945
|
+
stem_imports = []
|
944
946
|
for module, names in module_to_types.items():
|
945
|
-
|
947
|
+
filtered_names = set()
|
948
|
+
for name in set(names):
|
949
|
+
if '.' in name:
|
950
|
+
stem = '.'.join(name.split('.')[1:])
|
951
|
+
name_to_import = name.split('.')[0]
|
952
|
+
filtered_names.add(name_to_import)
|
953
|
+
stem_imports.append(f"{stem} = {name_to_import}.{stem}")
|
954
|
+
else:
|
955
|
+
filtered_names.add(name)
|
956
|
+
joined = ", ".join(sorted(set(filtered_names)))
|
946
957
|
import_path = module
|
947
958
|
if (target_file_path is not None) and (package_name is not None) and (package_name in module):
|
948
959
|
import_path = get_relative_import(target_file_path, module=module, package_name=package_name)
|
949
960
|
lines.append(f"from {import_path} import {joined}")
|
950
|
-
|
951
|
-
lines.extend(other_imports)
|
961
|
+
lines.extend(stem_imports)
|
952
962
|
return sorted(lines)
|
953
963
|
|
954
964
|
|
@@ -1376,6 +1386,7 @@ def table_rows_as_str(row_dicts: List[Dict[str, Any]], columns_per_row: int = 20
|
|
1376
1386
|
:param row_dicts: The rows to print.
|
1377
1387
|
:param columns_per_row: The maximum number of columns per row.
|
1378
1388
|
"""
|
1389
|
+
max_line_sze = 100
|
1379
1390
|
all_row_dicts_items = [list(row_dict.items()) for row_dict in row_dicts]
|
1380
1391
|
# make items a list of n rows such that each row has a max size of 4
|
1381
1392
|
all_items = [all_items[i:i + columns_per_row] for all_items in all_row_dicts_items
|
@@ -1388,9 +1399,9 @@ def table_rows_as_str(row_dicts: List[Dict[str, Any]], columns_per_row: int = 20
|
|
1388
1399
|
keys_values = [list(r[0]) + list(r[1]) if len(r) > 1 else r[0] for r in keys_values]
|
1389
1400
|
all_table_rows = []
|
1390
1401
|
row_values = [list(map(lambda v: str(v) if v is not None else "", row)) for row in keys_values]
|
1391
|
-
row_values = [list(map(lambda v: v[:
|
1402
|
+
row_values = [list(map(lambda v: v[:max_line_sze] + '...' if len(v) > max_line_sze else v, row)) for row in row_values]
|
1392
1403
|
row_values = [list(map(lambda v: v.lower() if v in ["True", "False"] else v, row)) for row in row_values]
|
1393
|
-
table = tabulate(row_values, tablefmt='simple_grid', maxcolwidths=[
|
1404
|
+
table = tabulate(row_values, tablefmt='simple_grid', maxcolwidths=[max_line_sze] * 2)
|
1394
1405
|
all_table_rows.append(table)
|
1395
1406
|
return "\n".join(all_table_rows)
|
1396
1407
|
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.88
|
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
|
@@ -69,7 +69,7 @@ class TestRDR(TestCase):
|
|
69
69
|
scrdr, _ = get_fit_scrdr(self.all_cases, self.targets, draw_tree=False,
|
70
70
|
expert_answers_dir=self.expert_answers_dir,
|
71
71
|
expert_answers_file="scrdr_expert_answers_fit",
|
72
|
-
load_answers=
|
72
|
+
load_answers=False,
|
73
73
|
scenario=self.test_fit_scrdr)
|
74
74
|
# render_tree(scrdr.start_rule, use_dot_exporter=True,
|
75
75
|
# filename=self.test_results_dir + f"/scrdr")
|
@@ -10,7 +10,7 @@ from ripple_down_rules.utils import is_iterable, make_list
|
|
10
10
|
save_dir = join(dirname(__file__), '..', 'src', 'ripple_down_rules')
|
11
11
|
# viewer = RDRCaseViewer(save_dir=save_dir)
|
12
12
|
viewer = None
|
13
|
-
rdr_decorator: RDRDecorator = RDRDecorator(save_dir, (bool,), True,
|
13
|
+
rdr_decorator: RDRDecorator = RDRDecorator(save_dir, (bool,), True,
|
14
14
|
fit=False,
|
15
15
|
viewer=viewer)
|
16
16
|
|
@@ -18,7 +18,6 @@ rdr_decorator: RDRDecorator = RDRDecorator(save_dir, (bool,), True, ask_always=T
|
|
18
18
|
@rdr_decorator.decorator
|
19
19
|
def should_i_ask_the_expert_for_a_target(conclusions: Union[Any, Dict[str, Any]],
|
20
20
|
case_query: CaseQuery,
|
21
|
-
ask_always: bool,
|
22
21
|
update_existing: bool) -> bool:
|
23
22
|
"""
|
24
23
|
Determine if the rdr should ask the expert for the target of a given case query.
|
@@ -29,9 +28,7 @@ def should_i_ask_the_expert_for_a_target(conclusions: Union[Any, Dict[str, Any]]
|
|
29
28
|
:param update_existing: Whether to update rules that gave the required type of conclusions.
|
30
29
|
:return: True if the rdr should ask the expert, False otherwise.
|
31
30
|
"""
|
32
|
-
if
|
33
|
-
return True
|
34
|
-
elif conclusions is None:
|
31
|
+
if conclusions is None:
|
35
32
|
return True
|
36
33
|
elif is_iterable(conclusions) and len(conclusions) == 0:
|
37
34
|
return True
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.github/workflows/build_and_deploy_doc.yml
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/.github/workflows/publish-to-test-pypi.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/examples/part_containment_rdr/robot_rdr.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_plus_rule.dot
RENAMED
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/complete_mcrdr_stop_plus_rule.png
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_stop_plus_rule_combined.dot
RENAMED
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/results/mcrdr_stop_plus_rule_combined.png
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/case.py
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/datastructures/enums.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/start-code-server.sh
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules/user_interface/gui.py
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/requires.txt
RENAMED
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/src/ripple_down_rules.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/conf/world/handles_and_containers.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/factories/world/handles_and_containers.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_helpers/object_diagram_person.png
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_ipython.py
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_prompt.py
RENAMED
File without changes
|
{ripple_down_rules-0.5.86 → ripple_down_rules-0.5.88}/test/test_user_interface/test_qt_gui_inline.py
RENAMED
File without changes
|
File without changes
|