question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarifying "Absence of presence" and "presence of absence" (optional -> non optional task input with default)

See original GitHub issue

Essentially, if I have some workflow and task that connections an optional value to a non-optional value. This should be a validation failure right?

workflow SmallWorkflow {
  input {
    String? myString
  }
  call Print {
    input:
      inp=myString
  }
}

task Print {
  input {
    String inp = "default"
  }
  command <<<
    echo '{inp}'
  >>>
  output {
    String out = read_string(stdout())
  }
}

How about if you slightly change the workflow to have:

task Print {
  input {
    String? inp = "default"
  }
  #...
}

My interpretation is:

  • providing a value that is null => value becomes null
  • not providing a value (ie, it’s not present in the input: map => default is applied

But I don’t think the spec clarifies this, and looks like there is ambiguity in Cromwell and MiniWDL.

Edit: I believe the way to apply a default in a task is to do:

task Print {
  input {
    String? inp
    String _inp = select_first([inp, "default"])
  }
  #...
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mlincommented, May 13, 2021

miniwdl has a command-line flag --no-quant-check that relaxes some of the static checks and would probably make this pass validation.

However, I’m not certain whether it would then exhibit the same runtime behavior as Cromwell. In particular, if task Print receives an explicit binding of inp to None, miniwdl would consider that a runtime error since its type is not optional; but another interpretation might use the default value in that case.

By analogy, consider this python function

def f(x=1):
  return x

f() == 1 but f(x=None) == None. “Absence of presence” isn’t the same as “presence of absence” (in python)

1reaction
pshapiro4broadcommented, May 12, 2021

I tried out your example, after adding version 1.0 and fixing a typo. miniwdl check rejects it (correctly), cromwell allows it (incorrectly). To me this looks like a bug in cromwell. It looks like the presence of a default value is affecting the type cromwell creates for the task input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

crowd-input - Amazon SageMaker - AWS Documentation
A preset that becomes the default if the worker does not provide input. ... should be able to handle the presence or absence...
Read more >
Allow Task Group parameters to be optional
I would like to have Task Group parameters to be optional, like having a checkmark in the UI. Currently there's only a default...
Read more >
AWS step functions and optional parameters - Stack Overflow
I'm solving this using a combination of the Choice and Pass states. Given that a state machine at least gets an empty input...
Read more >
The YANG 1.1 Data Modeling Language RFC 7950
A container node without a "presence" statement and that has at least one mandatory node as a child. o module: A YANG module...
Read more >
RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
Router Advertisement: Routers advertise their presence together with various ... but not frequently enough to rely on an absence of advertisements to detect ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found