Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented funtionality to support scatter, loops, conditionals and call sorting #3

Merged
merged 12 commits into from
Apr 17, 2017

Conversation

daniilsavchuk
Copy link
Collaborator

General idea

This Pull Request introduces support for Scatter, Loop and Conditionals syntax. These features are widely used in WDL scripts hosted on the Broad Institute FireCloud service, so it seems that visualization and generation of such constructions is a must

Examples of WDL visualizations are listed below

Conditionals

WDL Specification: Conditionals

Code example:

workflow foo {
		Boolean useXTask
		if (useXTask) {
		call x
	}

		call y { input: optional_int = x.out }
}

Visual representation:

if-view

Scatter

WDL Specification: Scatter

Code example:

workflow foo {
	File inputSamples
	scatter (sample in inputSamples) {
		call x
	}
	call y {
		input: 
			GVCFs=x.GVCF
	}
}

Visual:

scatter-view

Loop

WDL Specification: Loops

Code example:

workflow status {
	while(true) {
		call print_status
	}
}

Visual:

while-view

Calls sorting

According to WDL specification it is necessary to sort the calls during the generation in case of order calls should be executed

Changes

Added

  • Model/Group.js - describing the group inherited from Step.js class
  • Visualizer/VisualGroup - represent the visual group

Changed

  • Parser/WDLWorkflow - added support for parsing substeps
  • Generator/WorkflowGenerator - added support for substeps generation
  • Visualizer/Paper - changed the preferences to enable grouping and embedding
  • Visualizer/Visualizer - refactored the function of links update to make possible linking the grouped element with usual
  • WorkflowGenerator - added sorting function that iterates througs children and select the first suitable ordered

@coveralls
Copy link

Coverage Status

Coverage increased (+2.09%) to 94.822% when pulling 1b537c9 on feature/scatter-gather-support into be6cd03 on dev.

@sidoruka
Copy link
Contributor

@daniilsavchuk thanks a lot, this is great!
@paulsmirnov , @voidest could you please review the changes?

One remark from my side: @daniilsavchuk could you please update http://pb.opensource.epam.com/ demo application once this PR is merged?

Copy link
Member

@paulsmirnov paulsmirnov left a comment

Choose a reason for hiding this comment

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

Great job. However, I think a few changes should be made before accepting the PR.

@@ -123,7 +196,7 @@ describe('parser/WDL/entities/WDLWorkflow', () => {
})).to.throws(WDLParserError);
});

it('throws error when workflow uses scatter', () => {
it('requires scatter', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Did you really mean requires scatter/while/if or supports / knows / understands / whatever?

README.md Outdated
* [Loop](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#loops) - IN DEVELOPMENT
* [Workflow level resolution](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#workflow-level-resolution)
* [Order when generating declarations of any step(workflow, call, if, scatter, while and task)](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#workflow-level-resolution)
* [Declarations into the [call, if, scatter and while] blocks are not supported](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#conditionals)
Copy link
Member

Choose a reason for hiding this comment

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

  1. Could you reformulate these long titles, please? I am unable to understand the first one completely.
  2. I'm not a meanie, you know, but: into the -> in a / inside a

Copy link
Collaborator Author

@daniilsavchuk daniilsavchuk Apr 14, 2017

Choose a reason for hiding this comment

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

Thank you very much for this note!

Would it be suitable to write:
"Order of steps (workflow, call, if, scatter, while) in generated WDL code" for the first case?

(It is placed in the limitation paragraph)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you!

Done in afde1ce commit

/* Override the parent function to prohibit the port addition*/
// eslint-disable-next-line class-methods-use-this
_onActionChanged() {
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this code really prevents port addition? I think, an Action will still hold new ports but they will be out of sync with the Step. That's not good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you!

Done in 14ae69c commit

scatter: this.genScatter,
whileloop: this.genWhile,
if: this.genIf,
};
Copy link
Member

Choose a reason for hiding this comment

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

What is the justification for the whileloop name? You've used if and scatter but not while. Consider changing the name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you so much for deep analysis of my changes, it is really helpfull for me to get so detailed review!

This name threated by this way because hermes\wdl_parser.js named this so.

Please look at the endings of the grammar rules listed below: (there are names the same to my processor names mapping array)
grammar.hgr

    $while_loop = :while :lparen $e :rparen :lbrace list($wf_body_element) :rbrace -> WhileLoop(expression=$2, body=$5)
    $if_stmt = :if :lparen $e :rparen :lbrace list($wf_body_element) :rbrace -> If(expression=$2, body=$5)

    $scatter = :scatter :lparen :identifier :in $e :rparen :lbrace list($wf_body_element) :rbrace
        -> Scatter(item=$2, collection=$4, body=$7)

If this conduct could not be a reason of some issues related to this naming, please let me to leave it.

Copy link
Member

Choose a reason for hiding this comment

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

You converted if_stmt -> if, but while_loop -> whileloop... I still don't see the logic. I wish you would keep names clear and concise, no matter how ugly and complicated they are in hermes grammar =) Ok, go on, if you are sure.


it('throws error when try to create with ports', () => {
expect(() => new Group(name, type, config)).to.throw(Error);
});
Copy link
Member

Choose a reason for hiding this comment

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

Is a port creation disabled in such Actions? A user can create without ports and add them later. You removed a test which (incorrectly) asserts on _onActionChanged() but didn't add a correct test for the case I mention.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you!

Done in 14ae69c commit

Copy link
Member

Choose a reason for hiding this comment

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

Probably the reference is broken.

Copy link
Contributor

@voidest voidest left a comment

Choose a reason for hiding this comment

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

Well done. Everything is almost fine. Nevertheless, I found several issues that I believe have to be resolved prior to the merge.

}

return `${res}${EOL}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth trying to add all strings into array and then just join them with EOL separator? It applies to this particular case as well as to the overall routine.
To be honest, I don't think this is a major issue, but I would like you to consider this oppotunity too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you so it is a one more great thing done by your review!

It is special case for call generating function because it could be leaded by different way (it could have the "input mapping block" or could not) and so it is impossible to place ${EOL} by way you recommened.

Let me leave it if you do not mindly?

* @private
*/
export default class VisualGroup extends joint.shapes.devs.Model {
constructor(step, opts = {}) {
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 this class inherits joint Model instead of the VisualStep

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you very much for your valuable review it is making development cleaner!

In this case I did not use the inheritance because in my opinion it is not necessary, so the both classes are doing different (not at all, them looks like to be inherited but it could be a reason of additional problems related to styles, updates, and bbox functions).

If you do not mind I'll leave them both inherited from joint.shapes.devs.Model

},
},
type: 'VisualStep',
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, check if it is OK to have two different Model classes with the same type name.

Copy link
Collaborator Author

@daniilsavchuk daniilsavchuk Apr 14, 2017

Choose a reason for hiding this comment

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

Thank you!

Done in 1b537c9 commit


expect(parse(src).status).to.equal(false);
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Test name says that this code throws something, but there is no check that it actually does it.

Copy link
Collaborator Author

@daniilsavchuk daniilsavchuk Apr 14, 2017

Choose a reason for hiding this comment

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

Thank you!

Done in afde1ce commit

bottom: 50,
},
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it wrong to move this code to VisualGroup's update method?

Copy link
Collaborator Author

@daniilsavchuk daniilsavchuk Apr 14, 2017

Choose a reason for hiding this comment

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

Thank you, very strong and trully note, I followed it!

Done in d47a5df commit

@coveralls
Copy link

Coverage Status

Coverage increased (+2.0%) to 94.703% when pulling dda3b6b on feature/scatter-gather-support into be6cd03 on dev.

Copy link
Contributor

@voidest voidest left a comment

Choose a reason for hiding this comment

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

Great job! Now everything is fine by me.

Copy link
Member

@paulsmirnov paulsmirnov left a comment

Choose a reason for hiding this comment

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

Ok, thanks.

@paulsmirnov paulsmirnov merged commit fa591e4 into dev Apr 17, 2017
@paulsmirnov paulsmirnov deleted the feature/scatter-gather-support branch April 17, 2017 11:22
@sidoruka sidoruka mentioned this pull request Apr 17, 2017
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