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.

reads_json does not work

See original GitHub issue

Whenever I try to use read_json it does not work. For instance, when I make a simple wdl like:

workflow quantification {

    File references
    Map[String, String] indexes = read_json(references)
}
where test.json is:
```json
{
  "quantification.references": "/home/antonkulaga/rna-seq/workflows/rna-seq/quantification/inputs/test.json"
}
it tells

Unable to build WOM node for Declaration ‘indexes’: Return type of read_json() can’t be known statically at cromwell.engine.workflow.lifecycle.materialization.MaterializeWorkflowDescriptorActor.cromwell$engine$workflow$lifecycle$materialization$MaterializeWorkflowDescriptorActor$$workflowInitializationFailed(MaterializeWorkflowDescriptorActor.scala:211) at cromwell.engine.workflow.lifecycle.materialization.MaterializeWorkflowDescriptorActor$$anonfun$2.applyOrElse(MaterializeWorkflowDescriptorActor.scala:181) at cromwell.engine.workflow.lifecycle.materialization.MaterializeWorkflowDescriptorActor$$anonfun$2.applyOrElse(MaterializeWorkflowDescriptorActor.scala:176) at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:34)

That means I cannot just load a file and parse it, so how else can I read JSON then?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
antonkulagacommented, Mar 3, 2018

Looks like read_json in current trunk still has some issues. When I give a json like this:

{
  "Homo sapiens": {
    "transcriptome" : "/pipelines/indexes/HUMAN/27/gencode.v27.transcripts.fa",
    "gtf": "/pipelines/indexes/HUMAN/27/",
    "salmon": "/pipelines/indexes/HUMAN/27/salmon"
  },
  "Mus musculus": {
    "transcriptome" : "/pipelines/indexes/MOUSE/M16/gencode.vM16.transcripts.fa",
    "gtf": "/pipelines/indexes/MOUSE/M16/gencode.vM16.annotation.gtf",
    "salmon": "/pipelines/indexes/MOUSE/M16/salmon"
  }
}

with wdl like this

Map[String, Map[String, String]] indexes = read_json(references)   

I get:

Workflow input processing failed
WorkflowFailure(ERROR: indexes is declared as a Map[String, Map[String, String]] but the expression evaluates to a Object: Map[String, Map[String, String]] indexes = read_json(references) ^ ,List())

I do not get what is wrong there, I’ve tried different type combinations.

0reactions
cjllanwarnecommented, Jun 20, 2018

Hi @antonkulaga - sorry to come to this so late. It does look like the coercion function might require a little bit of a fixup here. In the mean time did you try using the Object type?

Object indexes = read_json(references)
Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON.parse() not working - Stack Overflow
Your JsonObject seems is a Json Object. The reasons why you can't parse Json from a String: the String is surround by "...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >
Converting JSON into Javascript Objects with JSON.parse()
JSON parsing is the process of converting a JSON object in text format to a Javascript object that can be used inside a...
Read more >
JSON file | Databricks on AWS
Learn how to read data from JSON files using Databricks.
Read more >
Pandas Read JSON - W3Schools
JSON objects have the same format as Python dictionaries. If your JSON code is not in a file, but in a Python Dictionary,...
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