From e61c49072dde0b99057b24cadf80bd55599fdee1 Mon Sep 17 00:00:00 2001 From: trgiangdo Date: Mon, 16 Oct 2023 16:59:07 +0700 Subject: [PATCH 1/2] fix: deepdiff should ignore order of list attributes --- .../_config_comparator/_config_comparator.py | 2 +- tests/config/test_config_comparator.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/taipy/config/_config_comparator/_config_comparator.py b/src/taipy/config/_config_comparator/_config_comparator.py index 0e77a9b..9d80799 100644 --- a/src/taipy/config/_config_comparator/_config_comparator.py +++ b/src/taipy/config/_config_comparator/_config_comparator.py @@ -94,7 +94,7 @@ def __get_config_diff(self, config_1, config_2): json_config_1 = json.loads(_JsonSerializer._serialize(config_1)) json_config_2 = json.loads(_JsonSerializer._serialize(config_2)) - config_deepdiff = DeepDiff(json_config_1, json_config_2) + config_deepdiff = DeepDiff(json_config_1, json_config_2, ignore_order=True) comparator_result = _ComparatorResult(copy(self._unconflicted_sections)) diff --git a/tests/config/test_config_comparator.py b/tests/config/test_config_comparator.py index b6b00f0..450c5f4 100644 --- a/tests/config/test_config_comparator.py +++ b/tests/config/test_config_comparator.py @@ -25,8 +25,9 @@ class TestConfigComparator: section_1 = SectionForTest("section_1", attribute="attribute_1", prop="prop_1") section_2 = SectionForTest("section_2", attribute=2, prop="prop_2") section_2b = SectionForTest("section_2", attribute="attribute_2", prop="prop_2b") - section_3 = SectionForTest("section_5", attribute=[1, 2, 3, 4], prop=["prop_1"]) - section_3b = SectionForTest("section_5", attribute=[1, 2], prop=["prop_1", "prop_2", "prop_3"]) + section_3 = SectionForTest("section_3", attribute=[1, 2, 3, 4], prop=["prop_1"]) + section_3b = SectionForTest("section_3", attribute=[1, 2], prop=["prop_1", "prop_2", "prop_3"]) + section_3c = SectionForTest("section_3", attribute=[2, 1], prop=["prop_3", "prop_1", "prop_2"]) def test_comparator_compare_method_call(self): _config_1 = _Config._default_config() @@ -176,6 +177,19 @@ def test_comparator_with_modified_list_attribute(self): assert conflicted_config_diff.get("removed_items") is None assert conflicted_config_diff.get("added_items") is None + def test_comparator_with_different_order_list_attributes(self): + _config_1 = _Config._default_config() + _config_1._unique_sections + _config_1._sections[SectionForTest.name] = {"section_3": self.section_3b} + + # Create _config_2 with different order of list attributes + _config_2 = _Config._default_config() + _config_2._sections[SectionForTest.name] = {"section_3": self.section_3c} + config_diff = Config._comparator._find_conflict_config(_config_1, _config_2) + + # There should be no difference since the order of list attributes is ignored + assert config_diff == {} + def test_comparator_with_new_unique_section(self): _config_1 = _Config._default_config() From 15f4120561a4e361a79afa3729f5e64b28f3d879 Mon Sep 17 00:00:00 2001 From: trgiangdo Date: Mon, 16 Oct 2023 10:00:42 +0000 Subject: [PATCH 2/2] Apply automatic changes --- src/taipy/config/config.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/taipy/config/config.pyi b/src/taipy/config/config.pyi index ad13c0c..0070505 100644 --- a/src/taipy/config/config.pyi +++ b/src/taipy/config/config.pyi @@ -164,10 +164,6 @@ class Config: def tasks(cls) -> Dict[str, TaskConfig]: """""" - @_Classproperty - def sequences(cls) -> Dict[str, SequenceConfig]: - """""" - @_Classproperty def scenarios(cls) -> Dict[str, ScenarioConfig]: """""" @@ -187,6 +183,7 @@ class Config: additional_data_node_configs: Optional[List[DataNodeConfig]] = None, frequency: Optional[Frequency] = None, comparators: Optional[Dict[str, Union[List[Callable], Callable]]] = None, + sequences: Optional[Dict[str, List[TaskConfig]]] = None, **properties, ) -> "ScenarioConfig": """Configure a new scenario configuration. @@ -208,6 +205,8 @@ class Config: comparison, each comparator is applied to all the data nodes instantiated from the data node configuration attached to the comparator. See `(taipy.)compare_scenarios()^` more more details. + sequences (Optional[Dict[str, List[TaskConfig]]]): Dictionary of sequence descriptions. + The default value is None. **properties (dict[str, any]): A keyworded variable length list of additional arguments. Returns: @@ -220,6 +219,7 @@ class Config: additional_data_node_configs: List[DataNodeConfig] = None, frequency: Optional[Frequency] = None, comparators: Optional[Dict[str, Union[List[Callable], Callable]]] = None, + sequences: Optional[Dict[str, List[TaskConfig]]] = None, **properties, ) -> "ScenarioConfig": """Set the default values for scenario configurations. @@ -244,6 +244,7 @@ class Config: comparison, each comparator is applied to all the data nodes instantiated from the data node configuration attached to the comparator. See `taipy.compare_scenarios()^` more more details. + sequences (Optional[Dict[str, List[TaskConfig]]]): Dictionary of sequences. The default value is None. **properties (dict[str, any]): A keyworded variable length list of additional arguments. Returns: