Browse Source

Revert "Fix how Mistral prepares data for evaluating a YAQL expression"

This reverts commit a39db2d3dc.

Change-Id: Ib45ad50cd1523e079b780e953091ddedbd49a54a
Related-bug: #1816026
tags/8.0.0.0b2
Chandan Kumar 3 months ago
parent
commit
1d16d2ffba
2 changed files with 1 additions and 63 deletions
  1. 0
    40
      mistral/tests/unit/engine/test_yaql_functions.py
  2. 1
    23
      mistral/utils/expression_utils.py

+ 0
- 40
mistral/tests/unit/engine/test_yaql_functions.py View File

@@ -13,7 +13,6 @@
13 13
 #    limitations under the License.
14 14
 
15 15
 from oslo_config import cfg
16
-import six
17 16
 
18 17
 from mistral.db.v2 import api as db_api
19 18
 from mistral.services import workflows as wf_service
@@ -432,42 +431,3 @@ class YAQLFunctionsEngineTest(engine_test_base.EngineTestCase):
432 431
         self.assertIsNotNone(json_str)
433 432
         self.assertIn('"key1": "foo"', json_str)
434 433
         self.assertIn('"key2": "bar"', json_str)
435
-
436
-    def test_built_in_str_function(self):
437
-        wf_text = """---
438
-        version: '2.0'
439
-
440
-        wf:
441
-          input:
442
-            - my_list
443
-
444
-          tasks:
445
-            task1:
446
-              publish:
447
-                val: <% str($.my_list) %>
448
-        """
449
-
450
-        wf_service.create_workflows(wf_text)
451
-
452
-        wf_ex = self.engine.start_workflow(
453
-            'wf',
454
-            wf_input={
455
-                'my_list': [
456
-                    {
457
-                        'k1': 'v1',
458
-                        'k2': 'v2'
459
-                    }
460
-                ]
461
-            }
462
-        )
463
-
464
-        self.await_workflow_success(wf_ex.id)
465
-
466
-        with db_api.transaction(read_only=True):
467
-            wf_ex = db_api.get_workflow_execution(wf_ex.id)
468
-
469
-            val = wf_ex.task_executions[0].published['val']
470
-
471
-            self.assertIsInstance(val, six.string_types)
472
-            self.assertIn('[', val)
473
-            self.assertIn(']', val)

+ 1
- 23
mistral/utils/expression_utils.py View File

@@ -14,7 +14,6 @@
14 14
 #    limitations under the License.
15 15
 
16 16
 from functools import partial
17
-import six
18 17
 import warnings
19 18
 
20 19
 from oslo_log import log as logging
@@ -40,27 +39,6 @@ LOG = logging.getLogger(__name__)
40 39
 ROOT_YAQL_CONTEXT = None
41 40
 
42 41
 
43
-def _convert_yaql_input_data(obj, rec=None):
44
-    # NOTE(rakhmerov): We have to define our own wrapper function
45
-    # around the function 'convert_input_data' from 'yaql_utils'
46
-    # because the latter always converts all sequences (except strings)
47
-    # into tuples, and it in turn breaks a number of things. For example,
48
-    # if we use the built-in 'str' YAQL function with an argument of the
49
-    # type 'list' then the result will be '(item1, item2 ..., itemN,)'
50
-    # instead of '[item1, item2 ..., itemN]'.
51
-    # So we override this behavior for sequences that are not strings and
52
-    # tuples.
53
-    if rec is None:
54
-        rec = _convert_yaql_input_data
55
-
56
-    if (isinstance(obj, yaql_utils.SequenceType) and
57
-            not isinstance(obj, six.string_types) and
58
-            not isinstance(obj, tuple)):
59
-        return list(rec(t, rec) for t in obj)
60
-    else:
61
-        return yaql_utils.convert_input_data(obj, rec)
62
-
63
-
64 42
 def get_yaql_context(data_context):
65 43
     global ROOT_YAQL_CONTEXT
66 44
 
@@ -70,7 +48,7 @@ def get_yaql_context(data_context):
70 48
         _register_yaql_functions(ROOT_YAQL_CONTEXT)
71 49
 
72 50
     new_ctx = ROOT_YAQL_CONTEXT.create_child_context()
73
-    new_ctx['$'] = _convert_yaql_input_data(data_context)
51
+    new_ctx['$'] = yaql_utils.convert_input_data(data_context)
74 52
 
75 53
     if isinstance(data_context, dict):
76 54
         new_ctx['__env'] = data_context.get('__env')

Loading…
Cancel
Save