OHDSI / Achilles

Automated Characterization of Health Information at Large-scale Longitudinal Evidence Systems (ACHILLES) - descriptive statistics about a OMOP CDM database
https://ohdsi.github.io/Achilles/
130 stars 122 forks source link

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

Open chgl opened 1 year ago

chgl commented 1 year ago

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?

thunders1984 commented 1 year ago

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.

Jananiaridhia commented 1 year ago

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

chrisknoll commented 8 months ago

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

PieterMaertens commented 8 months ago

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, ...)

actualben commented 8 months ago

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, ...)
Volpym commented 8 months ago

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?

Blappchri commented 8 months ago

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.

Volpym commented 8 months ago

Sorry for the confusion, I edited my comment

KAR2022 commented 2 months ago

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?