insightsengineering / teal

Exploratory Web Apps for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal/
Other
180 stars 38 forks source link

Issue with loading data into app and using datasets$set_data in module #78

Closed cicdguy closed 3 years ago

cicdguy commented 3 years ago

When initializing an app with dummy data and then loading in data from another source, when trying to set the loaded data it gives the following error:

Error in choices_labeled: is_character_vector(labels, min_length = 0L) is not TRUE

App runs fine when not setting the loaded data but then incorrect data is obviously being used in the other modules and filters.

@martik32 had a look at the issue with me and suspects there is an issue with filtered_data_view but can't be sure. Unfortunately delayed loading is not currently an option as data is being sourced from teradata and DCH.

This previously worked without error in 2020_07_07 release

Provenance:

Creator: palangaa
cicdguy commented 3 years ago

Note that my guess here is that one of the in built views of the data, such as the tabulation of numbers, is hard coding in the datasets which then causes issues.

During the data load app, we can confirm that all variables have labels, however, when we use debug(choices_labeled) suddenly most of the labels have become NA. I assume this is due to column mismatch between the dummy and real data, but it is occuring during a module

Provenance:

Creator: martik32
cicdguy commented 3 years ago

Hi, all!

The problem is that we could not use 2020_07_07 release as it has troubles with handling of multiple anonymous users or multiple sessions at the same time of the same user:

3.6.1/public/nest/2020_07_07/efficacy/) if you open this app in a couple of tabs of your browser, then set one of the filter, eg ADSL.AGE, then it will be appearing in all of your open tabs (and applications). We could not release our apps under 2020_07_07 as we need to have then in public area of Shiny server. They are the apps, which work across the studies. If one anonymous user loads one study, the apps are not accessible at the same time for any other users. 3.6.1/public/nest/2020_08_20/), but then we have mentioned above problem with updates of datasets. We have a release deadline as of December, 1st and we have to find a way around with handing multiple sessions per users. We need a time to migrate the app to the latest versions, when the bug with "choices_labeled" fixed, and test multisession with DDL from Teradata too. We are hoping to release the apps in time on the November release. Could you be so kind to support Central Monitoring team and find the resolution of this DLL bug for November version? It would be great to find an interim solution sooner! We will be happy to provide access to our data sources and apps' code if necessary. The bug is reproduced by Rohan in Entimice environment with a simple app too. Regards, Masha Provenance: ``` Creator: lapaevam ```
cicdguy commented 3 years ago

@lapaevam could you please provide the explanation that we have found out together?

Provenance:

Creator: pawelru
cicdguy commented 3 years ago

Sure! @pawelru, thank you so much for the support!

The problem seems to appear due to latest change in DDL schema. The correct way for now is to use dataset_connectors():

NEST/docs/hugo/NEST/agile-R/master/teal/app_development/delayed_data_loading/testing-delayed-data/ As the case was reproduced with Entimice, the additional test for DDL with Entimice connectors should be done. For our specific case: we could not proceed with Teradata connector, because - In DCH and PDIL (DBs on Teradata, which move to the Snowflake in ~March) the data for all studies is stored in one table. We need to be able to pass at least a parameter with STUDYID (it has different names in different tables). So, we need to be able to pass the whole WHERE clause for a different fields. It also would be good to think of GROUP BY , or just passing the whole custom SQL query to the connector **Interim solution for the DDL, without dataset_connectors()** 1) in app.R before `teal::init()` every dataset has to be wrapped in `teal_data()` eg, `QueryData <- data.frame( "STUDYID" = "null", "USUBJID" = "null", "Query_ID" = "null", "Query_Text" = "null" ....... )` `teal_data(dataset("QueryData", QueryData, keys(primary = c( "STUDYID","USUBJID","Query_ID"),` ` foreign = c("STUDYID","USUBJID"),` ` parent = "ADSL")))` `inix <- teal::init(` `data = cdisc_data(` ` cdisc_dataset("ADSL", ADSL),` ` dataset("QueryData", QueryData, keys = teal::keys(` ` primary = c( "STUDYID","USUBJID","Query_ID"),` ` foreign = c("STUDYID","USUBJID"),` ` parent = "ADSL")),code = '',check = F` ` ), ` ` modules = ().....` 2) in the module, which loads data, `dataset$set_data()` should be removed. Then, after the data loading and all mutations, the datasets should be again wrapped in `teal_data()` * if the data follows cdisc, it could be wrapped in cdisc_data Then, `teal:::set_datasets_data(datasets,x)` should be used. eg, user/1898/files/4fb74600-330b-11eb-815f-b67f9c1ec20d) Thank you for providing us the solution! Regards, Masha Provenance: ``` Creator: lapaevam ```