StackStorm / orquestaconvert

Converts Mistral workflows into Orchestra workflows
Apache License 2.0
13 stars 7 forks source link

Add support for converting with-items #17

Closed blag closed 5 years ago

blag commented 5 years ago

This PR adds support for converting Mistral's with-items and concurrency task attributes.

See this page of the Mistral docs for some examples.

with-items:
  - i in <% $.yaql_data %>

with-items:
  - i in <% $.yaql_data %>
  - j in <% $.more_data %>
  - k in <% $.all_the_data %>

with-items: i in <% $.yaql_data %>
concurrency: 2

with-items: i in {{ _.jinja_data }}

with-items: i in [0, 1, 2, 3]

should produce the following in orquesta

with:
  items: i in <% ctx().yaql_data %>

with:
  items: i, j, k in <% zip($.yaql_data, $.more_data, $.all_the_data) %>

with:
  items: i in <% $.yaql_data %>
  concurrency: 2

with:
  items: i in {{ ctx().jinja_data }}

with:
  items: i in <% [0, 1, 2, 3] %>

There is quite a bit of code churn in the pack tests, and it was a little difficult for me to extract the churn from the additional tests, so I recommend looking at the end results than the commit diff for that. I added quite a few additional fixtures for the integration tests for the pack client.

Interpreting and converting the with-items list correctly requires that all items in the list utilize the same expression format (eg: either all static/Jinja expressions or all static/YAQL expressions), however, it does not validate that.

Also, this does support syntax like:

with-items: i in [0, 1, 2, 3]

and converts it to:

with:
  items: i in <% [0, 1, 2, 3] %>

because we have some workflows that utilize that. I'm not 100% sure it's valid Mistral syntax, but since Mistral does seem to run it just fine I wanted to convert it to a more proper format that Orquesta can run just fine as well.

codecov-io commented 5 years ago

Codecov Report

Merging #17 into master will increase coverage by 0.3%. The diff coverage is 99.3%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #17     +/-   ##
=========================================
+ Coverage   98.27%   98.57%   +0.3%     
=========================================
  Files          11       12      +1     
  Lines         463      561     +98     
=========================================
+ Hits          455      553     +98     
  Misses          8        8
Impacted Files Coverage Δ
orquestaconvert/expressions/mixed.py 100% <100%> (ø)
orquestaconvert/expressions/yaql.py 100% <100%> (ø) :arrow_up:
orquestaconvert/expressions/jinja.py 100% <100%> (ø) :arrow_up:
orquestaconvert/expressions/base.py 100% <100%> (ø) :arrow_up:
orquestaconvert/workflows/base.py 100% <100%> (ø) :arrow_up:
orquestaconvert/expressions/__init__.py 100% <100%> (ø) :arrow_up:
orquestaconvert/pack_client.py 92.47% <75%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3423e71...bc819f4. Read the comment docs.