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

Workflow url in run mode #3988

Merged
merged 10 commits into from
Aug 16, 2018
Merged

Workflow url in run mode #3988

merged 10 commits into from
Aug 16, 2018

Conversation

salonishah11
Copy link
Contributor

This PR adds the remaining functionality of submitting workflow url to run a workflow in Run mode.

Closes #3849
Closes #3986

@@ -40,7 +41,7 @@ The Cromwell jar file can be built as described in [Building](Building).
`run` mode executes a single workflow in Cromwell and then exits.

* **`workflow-source`**
The single required argument for the workflow source file.
The single required argument. It can either be a workflow source file or a url pointing to the workflow (The maximum length of url can be 2000 characters).
Copy link
Contributor

@mcovarr mcovarr Aug 9, 2018

Choose a reason for hiding this comment

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

Not sure I would bother with the part between parentheses since that limit is so high it's unlikely anyone would ever hit it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Will remove it 👍

}

workflowUrl.length match {
case l if l > 2000 => s"Invalid workflow url. Length of the url:$l is more than 2000 characters".invalidNel
Copy link
Contributor

Choose a reason for hiding this comment

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

TOL something like val MaxWorkflowUrlLength = 2000 in the companion object would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

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

TOL suggestion: Invalid workflow url: url has length $l, longer than the maximum allowed $MaxWorkflowUrlLength characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

logger.info("Pre Processing Workflow...")
lazy val preProcessedCwl = cwlPreProcessor.preProcessCwlFileToString(workflowPath, None)

imports match {
case Some(explicitImports) => readOptionContent("Workflow source", workflowSource).map((_, Option(File(explicitImports.pathAsString)), workflowRoot))
case None => Try(preProcessedCwl.map((_, None, None)).value.unsafeRunSync())
case Some(_) => readContent("Workflow source", workflowSourcePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not following what's going on here with imports. If they're present the logic reads the workflow source from the source path but ignores the imports. If the imports are missing this returns the preprocessed CWL.

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 have tried to keep this CWL part of logic same as it was before workflow url was introduced. I thought it was better to keep it the same way as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked with @Horneth, and it does make sense to send CWL file path as workflow url if imports are present (in Run mode). Will change it. :)

case (None, Some(url)) => PartialWorkflowSources.convertStringToUrl(url)
case (Some(_), Some(_)) => "Both Workflow source and Workflow url can't be supplied".invalidNel
case (None, None) => "Workflow source and Workflow url needs to be supplied".invalidNel
def getWorkflowSourceFromPath(workflowPath: Path): ErrorOr[(Option[String], Option[String])] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

TOL This 2-tuple of optional Strings would probably be better as a proper type, something like

case class SourceOrUrl(source: Option[String], url: Option[String])

but there are other options for representing this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! Thank you! I have implemented the case class :)

workflowSource = w,
workflowUrl = u,
workflowSource = finalWorkflowSourceAndUrl._1,
workflowUrl = finalWorkflowSourceAndUrl._2,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you do the case class thing above you can unapply:

val SourceOrUrl(source, url) = {
 if (w.isDefined) (w, u)
.
.
.
 }
.
.
.
WorkflowSingleSubmission(
  workflowSource = source,
  workflowUrl = url,
.
.
.
)

@salonishah11 salonishah11 force-pushed the ss_workflow_url_run_mode branch from 7bdddb4 to 9c6560c Compare August 9, 2018 21:41
@gemmalam gemmalam requested a review from danbills August 14, 2018 15:37
@salonishah11 salonishah11 force-pushed the ss_workflow_url_run_mode branch from 9c6560c to 757617f Compare August 14, 2018 15:56
Copy link
Contributor

@cjllanwarne cjllanwarne left a comment

Choose a reason for hiding this comment

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

Just a few minor nit-picks

@@ -40,7 +41,7 @@ The Cromwell jar file can be built as described in [Building](Building).
`run` mode executes a single workflow in Cromwell and then exits.

* **`workflow-source`**
The single required argument for the workflow source file.
The single required argument. It can either be a workflow source file or a url pointing to the workflow.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say "it can be either a local path or a remote URL pointing to the workflow source file"

}

workflowUrl.length match {
case l if l > MaxWorkflowUrlLength => s"Invalid workflow url: url has length $l, longer than the maximum allowed $MaxWorkflowUrlLength characters".invalidNel
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor point but this whole match/case could be restructured as a simpler if (l > MaxWorkflowUrlLength) {} else {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It sure can! 👍

@@ -175,17 +176,24 @@ object CromwellEntryPoint extends GracefulStopSupport {
import spray.json._

val validation = args.validateSubmission(EntryPointLogger) map {
case ValidSubmission(w, u, r, i, o, l, z) =>
case ValidSubmission(w, u, r, i, o, l, z) =>{
Copy link
Contributor

Choose a reason for hiding this comment

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

The { and } are redundant on a case (but maybe you want them to make things easier to read?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I like to add braces if it make things easier to read. But, here it does not matter as there is just one case! So, will remove it.

validation.get.workflowUrl shouldBe Some(threeStep.wdl)
}

it should "run single when supplying workflow using url" in {
Copy link
Contributor

Choose a reason for hiding this comment

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

what does "run single" mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run single workflow/submission. The test is meant for Run mode.

@salonishah11 salonishah11 merged commit 6a0ac14 into develop Aug 16, 2018
mcovarr pushed a commit that referenced this pull request Aug 17, 2018
* Workflow url support in Run mode
@salonishah11 salonishah11 deleted the ss_workflow_url_run_mode branch August 24, 2018 17:25
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.

4 participants