Skip to content

Conversation

@m4dcoder
Copy link
Contributor

@m4dcoder m4dcoder commented Jan 9, 2015

Allow user to define workbook in native DSL without the st2.action
proxy. Before action execution, st2 transforms the workbook definition
and adds the st2.action proxy to appropriate actions before creating and
updating the workbook in Mistral. A st2-mistral pack with an action to
test the transform is included.

@m4dcoder
Copy link
Contributor Author

m4dcoder commented Jan 9, 2015

The DSL transform is temporary until ActionProvider is implemented in Mistral. I punt on DSL validation in this iteration. I did have to eval inline action parameters to transform the workbook properly. To be consistent with the evaluation, I copied two utility functions from Mistral to avoid having to import and depend on the entire mistral module.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a complete regex n00b so I have no clue what this is doing. Can you add some docs or comments in the method to describe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from Mistral @ https://github.com/stackforge/mistral/blob/master/mistral/workbook/base.py#L23. It's used to evaluate inline action parameters (i.e. action: core.local cmd={$.cmd}). The regex could have been written better. But I would fix it at the Mistral side. I'm just trying to keep the evaluation consistent here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K.

@manasdk
Copy link
Contributor

manasdk commented Jan 9, 2015

I get the idea that a transform is required although I don't understand the transform. Perhaps it is not worth spending time on the details since you guys expect to deprecate the transformation anyway once the ActionProvider is put in place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the impl here and in st2actions/st2actions/runners/mistral/utils.py look so similar? Perhaps you can call into the utils from here?

Also, what is the purpose of this action? Could the actions have been a separate PR or at least a separate commit?

Btw, we typically put sandbox action in st2incubator now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that's what he does.

from st2actions.runners.mistral import utils

But I agree this could have been a separate PR. I was very confused too.

EDIT: I see what you mean. utils.transform_definition() could have been used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move this to the st2-incubator. I put this here because the mistral pack was placed here first by lakshmi. I can't use utils.transform_definition() because reading from the Action model is different. The action here uses the st2client whereas the one in utils uses the st2common persistence directly.

@lakshmi-kannan
Copy link
Contributor

Yeah as long as this transform works, I am willing to assume the details as a blackbox. There are tests. So we are good. That damn regex made it to our code :).

@manasdk
Copy link
Contributor

manasdk commented Jan 9, 2015

Hmm ... perhaps it is better if @lakshmi-kannan or @dzimine take a look at this PR.

@lakshmi-kannan
Copy link
Contributor

I think the PR could have been split in the following way:

  1. Transformer utility and tests
  2. Use transformer in mistral runner and change the examples
  3. Create a mistral action using that transformer

@m4dcoder
Copy link
Contributor Author

m4dcoder commented Jan 9, 2015

Sure it would have been nice with #3. But it's inconsistent with your early comments before that st2 action should not have access to st2 DB directly.

@lakshmi-kannan
Copy link
Contributor

#3 could be create a mistral action.

@m4dcoder
Copy link
Contributor Author

m4dcoder commented Jan 9, 2015

I'm not sure what you mean. But maybe you can patch afterward.

The utility function takes a mistral workbook written in native DSL and
wraps st2 action with the st2.action proxy.

Before Transform:
```
name: 'examples.mistral-basic'
version: '2.0'
description: 'Basic mistral workflow example'
workflows:
    demo:
        type: direct
        input:
            - cmd
        tasks:
            run-cmd:
                action: core.local cmd={$.cmd}
                publish:
                    stdout: $.stdout
                    stderr: $.stderr
```

After Transform:
```
name: 'examples.mistral-basic'
version: '2.0'
description: 'Basic mistral workflow example'
workflows:
    demo:
        type: direct
        input:
            - cmd
        tasks:
            run-cmd:
                action: st2.action
                input:
                    ref: core.local
                    parameters:
                        cmd: $.cmd
                publish:
                    stdout: $.stdout
                    stderr: $.stderr
```
Allow user to define workbook in native DSL without the st2.action
proxy. Before action execution, st2 transforms the workbook definition
and adds the st2.action proxy to appropriate actions before creating and
updating the workbook in Mistral.
@m4dcoder m4dcoder force-pushed the STORM-884/mistral_dsl_transformer branch from b0ce72a to b522670 Compare January 9, 2015 20:36
@m4dcoder
Copy link
Contributor Author

m4dcoder commented Jan 9, 2015

Split to multiple commits and added comments for _eval_inline_params.

m4dcoder added a commit to StorminStanley/st2incubator that referenced this pull request Jan 9, 2015
Add st2-mistral pack with an action to test the DSL transformation. The
transformation takes a native DSL and wraps st2 action with the
st2.action proxy. Please refer to PR StackStorm/st2#964
for details of the DSL transformation.
m4dcoder added a commit that referenced this pull request Jan 9, 2015
…rmer

Transform mistral workbook definition
@m4dcoder m4dcoder merged commit 3cb6a2a into master Jan 9, 2015
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make this worklfow actually working against 'mock' actions (make them part of example), run this workflow as part of the test, and literanlinclude it in the docs.

@dzimine
Copy link

dzimine commented Jan 9, 2015

LGTM.

@m4dcoder m4dcoder deleted the STORM-884/mistral_dsl_transformer branch January 21, 2015 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants