diff --git a/arcaflow_plugin_opensearch/opensearch_plugin.py b/arcaflow_plugin_opensearch/opensearch_plugin.py index f6578dd..a0a9c32 100644 --- a/arcaflow_plugin_opensearch/opensearch_plugin.py +++ b/arcaflow_plugin_opensearch/opensearch_plugin.py @@ -21,9 +21,7 @@ def convert_to_supported_type(value) -> typing.Dict: elif type_of_val == dict: result = {} for k in value: - result[convert_to_supported_type(k)] = convert_to_supported_type( - value[k] - ) + result[convert_to_supported_type(k)] = convert_to_supported_type(value[k]) return result elif type_of_val in (float, int, str, bool): return value @@ -33,6 +31,7 @@ def convert_to_supported_type(value) -> typing.Dict: print("Unknown type", type_of_val, "with val", str(value)) return str(value) + def convert_to_homogenous_list(input_list: list): # To make all types in list homogeneous, we upconvert them # to the least commom type. @@ -49,6 +48,7 @@ def convert_to_homogenous_list(input_list: list): list_type = int() return list(map(type(list_type), input_list)) + @plugin.step( id="opensearch", name="OpenSearch", diff --git a/tests/unit/test_arcaflow_plugin_opensearch.py b/tests/unit/test_arcaflow_plugin_opensearch.py index 5bc21f9..5150d37 100644 --- a/tests/unit/test_arcaflow_plugin_opensearch.py +++ b/tests/unit/test_arcaflow_plugin_opensearch.py @@ -33,7 +33,7 @@ def test_serialization(): " 'mapper_parsing_exception','failed to parse')" ) ) - + def test_convert_to_homogeneous_list(self): test_cases = [ ["a", "b", "c"], # all str @@ -73,6 +73,5 @@ def validate_list_items_homogeous_type(t, input_list): t.assertEqual(type(item), expected_type) - if __name__ == "__main__": unittest.main()