Git Product home page Git Product logo

Comments (5)

Gvaihir avatar Gvaihir commented on August 26, 2024 1

I'll update the doc/Internals.md with regards to that + recommendations. Short answer - pls avoid declaring variables which don't depend on the outputs of any task/workflow in the body. Allocate those things to the top level inputs - this will eliminate unwanted dependencies. I don't envision any immediate changes to the current logic of dxCompiler with regards to that so will probably close the issue shortly. Otherwise, will update here

from dxcompiler.

emiloslavsky avatar emiloslavsky commented on August 26, 2024

I think this is the issue discussed in dnanexus/dxWDL#162 where wdl expression evaluations in a WDL workflow gets merged into a fragment for the first following applet.

Referring to the following basic test:

version 1.0
task t1 {
  input {
    String s
  }
  command <<<
  echo t1 >s
   >>>
   output {
     File out = "s"
   }
}

task t2 {
  input {
    Array[String] s
  }
  command <<<
	echo t1 >s
  >>>
  output {
    File out = "s"
  }
}

task dummy {
  input {
  }
command <<<
>>>
  output {
  }
}

workflow tinytest3 {
	Array[String] chr_num = ["1"]
	Array[String] chrs = prefix("chr", chr_num)
        call dummy

	call t2 {input: s = chrs}
	scatter (chr in chrs) {
		call t1 { input: s = chr }
	}
	output {
		Array[File] out1 = t1.out
		File out2 = t2.out
	}
}

With dxCompiler 2.10.0

  1. The following makes a dnanexus workflow where t2 depends on scatter
workflow tinytest {
  Array[String] chr_num = ["1"]
  Array[String] chrs = prefix("chr", chr_num)
  scatter (chr in chrs) {
    call t1 { input: s = chr }
  }
  call t2 {input: s = chrs}
  1. The following makes a dnanexus workflow where scatter depends on t2
workflow tinytest2 {
  Array[String] chr_num = ["1"]
  Array[String] chrs = prefix("chr", chr_num)

  call t2 {input: s = chrs}
  scatter (chr in chrs) {
    call t1 { input: s = chr }
  }
  1. The following makes a dnanexus workflow where scatter and t2 both depend on dummy, but not on each other.
workflow tinytest3 {
  Array[String] chr_num = ["1"]
  Array[String] chrs = prefix("chr", chr_num)
  call dummy

  call t2 {input: s = chrs}
  scatter (chr in chrs) {
    call t1 { input: s = chr }
  }

The dependency can be seen by examining the inputs to each stage. E.g. for tinytest3:

$ dx describe workflow-GGGQzJ00Bvbj46PP4gjFyXP9 --json | jq '.stages|.[]|{id: .id,name: .name, input: .input}'
{
  "id": "stage-common",
  "name": "common",
  "input": {}
}
{
  "id": "stage-1",
  "name": "frag dummy",
  "input": {}
}
{
  "id": "stage-2",
  "name": "t2",
  "input": {
    "s": {
      "$dnanexus_link": {
        "outputField": "chrs",
        "stage": "stage-1"
      }
    }
  }
}
{
  "id": "stage-4",
  "name": "scatter (chr in chrs)",
  "input": {
    "chrs": {
      "$dnanexus_link": {
        "outputField": "chrs",
        "stage": "stage-1"
      }
    }
  }
}
{
  "id": "stage-outputs",
  "name": "outputs",
  "input": {
    "t1___out": {
      "$dnanexus_link": {
        "outputField": "t1___out",
        "stage": "stage-4"
      }
    },
    "t2___out": {
      "$dnanexus_link": {
        "outputField": "out",
        "stage": "stage-2"
      }
    }
  }
}

from dxcompiler.

emiloslavsky avatar emiloslavsky commented on August 26, 2024

So it's a known behavior that reduces the number of jobs at the expense of potential decrease in concurrency of execution, with a known workaround (see tinytest3).
We can consider making identification of such situations easier or changing the behavior of dxCompiler to place expression evaluation into a separate job when multiple tasks depend on the results of expression evaluation.

from dxcompiler.

Gvaihir avatar Gvaihir commented on August 26, 2024

@Ben-Habermeyer is there a reason to declare chr_num and chrs in the body of the WF, instead of declaring them at the workflow level inputs (with defaults)? This way muse should depend on a common stage and not on the scatter.

from dxcompiler.

Ben-Habermeyer avatar Ben-Habermeyer commented on August 26, 2024

Hi @Gvaihir thanks for the reply. Yes that is the approach we went with. I think the user was confused why placing the variables in the body of the WF resulted in this behavior

from dxcompiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.