<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">The problem with existing syntax is it is not defined: there is no docs on inlining complex variables [*], and we haven’t tested it for anything more than the simplest cases: <a href="https://github.com/stackforge/mistral/blob/master/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py#L114">https://github.com/stackforge/mistral/blob/master/mistral/tests/unit/workbook/v2/test_dsl_specs_v2.py#L114</a>. I will be surprised if anyone figured how to provide a complex object as an inline parameter.<div><div><br></div><div>Do you think regex is the right approach for parsing arbitrary key-values where values is arbitrary json structures? Will it work with something like </div><div><span class="Apple-tab-span" style="white-space: pre;">    </span>workflow: wf2 object_list=[ {“url”: “http://{$hostname}.<a href="http://example.com">example.com</a>:8080?x=a&y={$.b}}, 33, null, {{$.key}, [{$.value1}, {$.value2}]}</div><div>How much tests should we write to be confident we covered all cases? I share Lakshmi’s concern it is fragile and maintaining it reliably is difficult. </div><div><br></div><div>But back to the original question, it’s about requirements, not implementation. </div><div>My preference is “option 3”, “make it work as is now”. But if it’s too hard I am ok to compromise. </div><div>Than option 2 as it resembles option 3 and YAML/JSON conversion makes complete sense. At the expense of quoting the objects. Slight change, not significant. </div><div>Option 1 introduce a new syntax; although familiar to CLI users, I think it’s a bit out of place in YAML definition. </div><div>Option 4 is no go :)</div><div><br></div><div><div>DZ. </div><div><br></div><div>[*] “there is no docs to this” - I subscribe on fixing this.</div><div><br><div><div><div><div>On Dec 16, 2014, at 9:48 PM, Renat Akhmerov <<a href="mailto:rakhmerov@mirantis.com">rakhmerov@mirantis.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Ok, I would prefer to spend some time and think how to improve the existing reg exp that we use to parse key-value pairs. We definitely can’t just drop support of this syntax and can’t even change it significantly since people already use it.<div class=""><br class=""><div class="">
<div class="">Renat Akhmerov</div><div class="">@ Mirantis Inc.</div><div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 17 Dec 2014, at 07:28, Lakshmi Kannan <<a href="mailto:lakshmi@lakshmikannan.me" class="">lakshmi@lakshmikannan.me</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important" class="">Apologies for the long email. If this fancy email doesn’t render correctly for you, please read it here: <a href="https://gist.github.com/lakshmi-kannan/cf953f66a397b153254a" class="">https://gist.github.com/lakshmi-kannan/cf953f66a397b153254a</a></p><p style="margin:1.2em 0px!important" class="">I was looking into fixing bug: <a href="https://bugs.launchpad.net/mistral/+bug/1401039" class="">https://bugs.launchpad.net/mistral/+bug/1401039</a>. My idea was to use shlex to parse the string. This actually would work for anything that is supplied in the linux shell syntax. Problem is this craps out when we want to support complex data structures such as arrays and dicts as arguments. I did not think we supported a syntax to take in complex data structures in a one line format. Consider for example:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="">      task7:
        for-each:
          vm_info: $.vms
        workflow: wf2 is_true=true object_list=[1, null, "str"]
        on-complete:
          - task9
          - task10
</code></pre><p style="margin:1.2em 0px!important" class="">Specifically </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="">wf2 is_true=true object_list=[1, null, "str"]
</code></pre><p style="margin:1.2em 0px!important" class="">shlex will not handle this correctly because object_list is an array. Same problem with dict. </p><p style="margin:1.2em 0px!important" class="">There are 3 potential options here:</p>
<h2 id="option-1" style="margin:1.3em 0px 1em;padding:0px;font-weight:bold;font-size:1.4em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238)" class="">Option 1</h2><p style="margin:1.2em 0px!important" class="">1) Provide a spec for specifying lists and dicts like so:<br class="">list_arg=1,2,3 and dict_arg=h1:h2,h3:h4,h5:h6</p><p style="margin:1.2em 0px!important" class="">shlex will handle this fine but there needs to be a code that converts the argument values to appropriate data types based on schema. (ActionSpec should have a parameter schema probably in jsonschema). This is doable. </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="">wf2 is_true=true object_list="1,null,"str""
</code></pre><h2 id="option-2" style="margin:1.3em 0px 1em;padding:0px;font-weight:bold;font-size:1.4em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238)" class="">Option 2</h2><p style="margin:1.2em 0px!important" class="">2) Allow JSON strings to be used as arguments so we can json.loads them (if it fails, use them as simple string). For example, with this approach, the line becomes</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important" class="">wf2 is_true=true object_list="[1, null, "str"]"
</code></pre><p style="margin:1.2em 0px!important" class="">This would pretty much resemble <a href="http://stackoverflow.com/questions/7625786/type-dict-in-argparse-add-argument" class="">http://stackoverflow.com/questions/7625786/type-dict-in-argparse-add-argument</a></p>
<h2 id="option-3" style="margin:1.3em 0px 1em;padding:0px;font-weight:bold;font-size:1.4em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238)" class="">Option 3</h2><p style="margin:1.2em 0px!important" class="">3) Keep the spec as such and try to parse it. I have no idea how we can do this reliably. We need a more rigorous lexer. This syntax doesn’t translate well when we want to build a CLI. Linux shells cannot support this syntax natively. This means people would have to use shlex syntax and a translation needs to happen in CLI layer. This will lead to inconsistency. CLI uses some syntax and the action input line in workflow definition will use another. We should try and avoid this. </p>
<h2 id="option-4" style="margin:1.3em 0px 1em;padding:0px;font-weight:bold;font-size:1.4em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238)" class="">Option 4</h2><p style="margin:1.2em 0px!important" class="">4) Completely drop support for this fancy one line syntax in workflow. This is probably the least desired option. </p>
<h2 id="my-preference" style="margin:1.3em 0px 1em;padding:0px;font-weight:bold;font-size:1.4em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238)" class="">My preference</h2><p style="margin:1.2em 0px!important" class="">Looking the options, I like option2/option 1/option 4/option 3 in the order of preference. </p><p style="margin:1.2em 0px!important" class="">With some documentation, we can tell people why this is hard. People will also grok because they are already familiar with CLI limitations in linux.</p><p style="margin:1.2em 0px!important" class="">Thoughts? </p>
<div title="MDH:QXBvbG9naWVzIGZvciB0aGUgbG9uZyBlbWFpbC4gSWYgdGhpcyBmYW5jeS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JIGxpbWl0YXRpb25zIGluIGxpbnV4Ljwvc3Bhbj48
YnI+PC9kaXY+PGRpdj48c3BhbiBzdHlsZT0iY29sb3I6IHJnYig1MSwgNTEsIDUxKTsgZm9udC1m
YW1pbHk6ICdIZWx2ZXRpY2EgTmV1ZScsIEhlbHZldGljYSwgJ1NlZ29lIFVJJywgQXJpYWwsIGZy
ZWVzYW5zLCBzYW5zLXNlcmlmOyBmb250LXNpemU6IDE1cHg7IGxpbmUtaGVpZ2h0OiAyMi4zOTk5
OTk2MTg1MzAzcHg7Ij48YnI+PC9zcGFuPjwvZGl2PjxkaXY+PHNwYW4gc3R5bGU9ImNvbG9yOiBy
Z2IoNTEsIDUxLCA1MSk7IGZvbnQtZmFtaWx5OiAnSGVsdmV0aWNhIE5ldWUnLCBIZWx2ZXRpY2Es
ICdTZWdvZSBVSScsIEFyaWFsLCBmcmVlc2Fucywgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxNXB4
OyBsaW5lLWhlaWdodDogMjIuMzk5OTk5NjE4NTMwM3B4OyI+VGhvdWdodHM/Jm5ic3A7PC9zcGFu
PjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="">​</div></div></div>
_______________________________________________<br class="">OpenStack-dev mailing list<br class=""><a href="mailto:OpenStack-dev@lists.openstack.org" class="">OpenStack-dev@lists.openstack.org</a><br class=""><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br>OpenStack-dev mailing list<br><a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev<br></blockquote></div><br></div></div></div></div></div></body></html>