Achilles icon indicating copy to clipboard operation
Achilles copied to clipboard

Error in jsonlite::fromJSON(file = treemapFile) argument "txt" is missing, with no default

Open chgl opened this issue 1 year ago • 9 comments

When running the latest version of Achilles, v1.7.2:

Error in jsonlite::fromJSON(file = treemapFile) : 
argument "txt" is missing, with no default
Calls: exportToJson -> generateConditionReports -> <Anonymous>

I believe this is a regression caused in https://github.com/OHDSI/Achilles/commit/de786a64f107bf9ab289e81d6154191072aea684 since the jsonlite fromJSON function definition requires a parameter called txt (which apparently can be a URL or file path as well): https://github.com/jeroen/jsonlite/blob/7287acf3925392c33b523c76dedd5fed631971a3/R/fromJSON.R#L44.

I could find the following 4 instances of fromJSON using GitHub's search: https://github.com/search?q=repo%3AOHDSI%2FAchilles%20fromJson&type=code

With https://github.com/OHDSI/Broadsea-Atlasdb it might be possible to create a basic integration test for running Achilles against a DB as part of the CI?

chgl avatar May 24 '23 11:05 chgl

we got the same issue when trying to generate json file using Achilles::exportToJson. the error : Generating condition reports Error in jsonlite::fromJSON(file = treemapFile) : argument "txt" is missing, with no default is there any solution or some guide how to fix it.

thunders1984 avatar May 29 '23 08:05 thunders1984

Hi , is there any solution identified for the above problem ? Currently we are having same issue while generating report through Achilles .

Jananiaridhia avatar Jul 07 '23 13:07 Jananiaridhia

I added a comment to the PR, I don't think the PR addresses this since you can't remove file = and have the value passed in as the first param (the json text) and have it just work.

Secondly, there is no parameter named 'txt' in the function signature of jsonlite::fromJSON() I think this error is from somewhere else.

We need the full stack trace to know what the exact line is that is reporting the error. the message Calls: exportToJson -> generateConditionReports -> <Anonymous> gives us some info, but we need to know where the <Annonymous> call is

chrisknoll avatar Jan 10 '24 13:01 chrisknoll

The full stack trace:

traceback() 3: jsonlite::fromJSON(file = treemapFile) 2: generateConditionReports(conn, connectionDetails$dbms, cdmDatabaseSchema, resultsDatabaseSchema, outputPath, vocabDatabaseSchema) 1: exportToJson(connectionDetails, cdmDatabaseSchema = "omopcdm", resultsDatabaseSchema = "results", vocabDatabaseSchema = "omopcdm", outputPath = "/exportToJson", compressIntoOneFile = FALSE)

and signature of jsonlite::fromJSON(), package version 1.8.8

jsonlite::fromJSON function (txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE, ...)

PieterMaertens avatar Jan 10 '24 15:01 PieterMaertens

As @Blappchri pointed out in #743, this is because we're calling jsonlite::fromJSON using rjson::fromJSON's signature

rjson::fromJSON:

fromJSON( json_str, file, method = "C", unexpected.escape = "error", simplify = TRUE )

jsonlite::fromJSON:

fromJSON( txt, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, simplifyMatrix = simplifyVector, flatten = FALSE, ...)

actualben avatar Jan 19 '24 11:01 actualben

Since the PR hasn't been reviewed yet, I removed the Achilles from my HADES instance and installed @ziporah 's #743. But I still got the same error. Am I missing something?

Volpym avatar Jan 31 '24 08:01 Volpym

Note that the branch isn't mine, @ziporah developed it. I am just the one being annoying about getting this issue fixed^^. I have not verified myself that the branch works in its entirety, but based on the code it is fixing the thing that need to be changed. I myself have used a workaround based on using trace() to rewrite the fromJSON function to how Achilles assumes it works within my R session.

Blappchri avatar Feb 01 '24 07:02 Blappchri

Sorry for the confusion, I edited my comment

Volpym avatar Feb 01 '24 08:02 Volpym

We are getting the same error :( I am unable to find the function exportToJson.R inside Achilles package directory to make the edits per PR. Any thoughts on this?

KAR2022 avatar Jul 26 '24 20:07 KAR2022