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.

File/String? coercion to File not allowed

See original GitHub issue

Hi,

I’ve been developing using WDL for quite some time now, and while I find the language powerful, there’s always been one validation error that prevents me from optimally structuring my workflows.

Whenever I make a task optional and try to pipe a File to a mandatory task I get the error “Cannot coerce expression of type ‘File?’ to 'File’”. The same goes for coercing a String? to File.

See the following example:

version 1.0

import "A.wdl" as A
import "B.wdl" as B

workflow AB_driver {
	input {
		Boolean run_A
		File? preexisting_foo #For when the user sets run_A=false
	}
	if (run_A) {
		call task A.A_workflow as A {
			input:
				…
			#output:
			#	File foo # Reference file that takes a long while to generate and the user will reuse for future workflow submissions with run_A=false.
		}
	}
	call task B.B_workflow as B {
		input:
			foo=if (run_A) then A.foo else preexisting_foo # validation with womtools throws the error and disallows me from uploading the workflow
	}
	output {…}
}

From my standpoint, I know that either A.foo will be generated by workflow A or the user will skip A and provide their own preexisting_foo. I do realize there is the chance that the user could accidentally set run_A to false and not provide the preexisting foo File, which would result in a failure. Ideally I would like that possibility to be permitted with a warning and for me to be able to catch and handle that error on my own.

There are plenty of alternatives to structuring a WDL script like this, such as having users visit A and B individually to launch them one after the other, but for my work I have the specific purpose of needing one overarching workflow that can run all subworkflows back-to-back on the Single Cell Portal. In the past I have been able to achieve this goal using some imperfect workarounds, but it would be much more desirable to be able to structure my workflows as shown in the above example.

Thanks! James

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DavyCatscommented, Nov 28, 2019

As @yfarjoun mentioned select_first seems like it would solve your problem. As a side note, you could omit the run_A input boolean and use ! defined(preexisting_foo) instead, then you won’t have the issue of foo being absent at all. Unless you want to be able to run A even if preexisting_foo is provided.

1reaction
yfarjouncommented, Nov 27, 2019

can you use

foo=select_first([A.foo,preexisting_foo])

?

Read more comments on GitHub >

github_iconTop Results From Across the Web

why does pd.to_datetime fail to convert? - Stack Overflow
I have an object column with values which are dates. I manually placed 2016-08-31 instead of NaN ...
Read more >
Allow disabling Integer to String coercion via `CoercionConfig`
I would like to disable coercion between String and Integer. Version information v2.12.1 To ... Or if not, file a new issue or...
Read more >
JavaScript type coercion explained - freeCodeCamp
To explicitly convert values to a string apply the String() function. Implicit coercion is triggered by the binary + operator, ...
Read more >
Python doesn't have type coercion
In Python, we get an error instead (see [TypeError: can only concatenate str (not "int") to str][concat str] for more on that specific...
Read more >
Coercion error caused during mongoimport - Developer Tools
The above is part of the csv file that I have. The entry_time and exit_time columns are currently in string format.
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