Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLP package generated by WebAPI v2.12.0 fails on renv #2162

Closed
konstjar opened this issue Nov 15, 2022 · 17 comments · Fixed by #2174
Closed

PLP package generated by WebAPI v2.12.0 fails on renv #2162

konstjar opened this issue Nov 15, 2022 · 17 comments · Fixed by #2174
Assignees
Labels
Milestone

Comments

@konstjar
Copy link
Contributor

Expected behavior

As a user I'm able to run generated package from RStudio

Actual behavior

a. Wrong command in STUDY-PACKAGE-SETUP.md

# Download the lock file:
download.file("https://raw.githubusercontent.com/ohdsi-studies/regressPLP/main/renv.lock", "renv.lock")

b. The 'renv::init()' failes on the error:

Retrieving 'https://cloud.r-project.org/src/contrib/Archive/CohortGenerator/CohortGenerator_0.3.0.tar.gz' ...
Warning: failed to find binary for 'CohortGenerator 0.3.0' in package repositories
Warning: failed to find source for 'CohortGenerator 0.3.0' in package repositories
Warning: failed to retrieve 'https://cloud.r-project.org/src/contrib/Archive/CohortGenerator/CohortGenerator_0.3.0.tar.gz' [error code 22]
Error: failed to retrieve package 'CohortGenerator@0.3.0'
In addition: Warning message:
curl: (22) The requested URL returned error: 404 

image

Steps to reproduce behavior

  1. Download zip file for PLP package from ATLAS UI
  2. Follow steps in STUDY-PACKAGE-SETUP.md instruction
  3. Run 'renv::init()' command
@konstjar konstjar changed the title PLP package generated by WebAPI fails on renv PLP package generated by WebAPI v2.12.0 fails on renv Nov 15, 2022
@konstjar
Copy link
Contributor Author

More questions. CohortGenerator 0.3.0 fails. But package requires CohortGenerator >= 0.4.0 version. Does it mean renv.lock file is wrong?

image

@anthonysena anthonysena self-assigned this Nov 15, 2022
@konstjar
Copy link
Contributor Author

Also PLP package should not be higher v5.0.5? v6.0 is not compatible further because of some methods were changed

@anthonysena
Copy link
Collaborator

Hi @konstjar - yes, seems like there are a few problems here.

a. Wrong command in STUDY-PACKAGE-SETUP.md

Not sure what is wrong with this command? The presumption is that the package would be uploaded to the ohdsi-studies area for use.

b. The 'renv::init()' failes on the error....

The renv.lock file reference for CohortGenerator should point to GitHub. An example of how that should look is here: https://github.com/OHDSI/CohortGeneratorModule/blob/main/renv.lock#L420-L428. Next, we'll need to decide which version to use....

More questions. CohortGenerator 0.3.0 fails. But package requires CohortGenerator >= 0.4.0 version. Does it mean renv.lock file is wrong?

Presumably we should make use of CohortGenerator v0.4.0 and this should be the version referenced in the renv.lock file.

Also PLP package should not be higher v5.0.5? v6.0 is not compatible further because of some methods were changed

Yes, we should probably move that to v5.0.5 as v6 has breaking changes. We should also ensure this is referenced in the renv.lock file properly.

Appreciate you digging into this! As a suggestion here, could you make these changes locally and if there are any other issues encountered, can you post them here? Once your package is working, we can revise the skeleton reference in Hydra and plan another release.

@konstjar
Copy link
Contributor Author

@anthonysena Thank you for quick response. I'm moving forward and collecting the set of changes to be addressed and my steps.

  1. STUDY-PACKAGE-SETUP.md - I got it, it's intruction file for end users who download the analysis after it's published on ohdsi-studies. In this case I think STUDY-PACKAGE-BUILD.md instruction should be updated to reflect "renv". What do you think?

image

  1. In reality, renv.lock file contains 2 CohortGenerator entries:

image

image

I removed first one with "CRAN".

  1. I changed reference to CohortGenerator v0.4.0. After that I was able to restore environment with "renv".

I'm trying to run the analysis and I will update here on results

@konstjar
Copy link
Contributor Author

I continue with exercise.

My initial platform was Macbook Pro with M1 processor. During restoring all packages I met the issue that RJSONIO package was not able to compile. I switched to Windows 10 platform. After setting up all things, I ran the analysis and got this error:

Creating cohorts
Connecting using PostgreSQL driver
Creating cohort tables
- Created table results_atlas_demo.plpanalysisCohort
- Created table results_atlas_demo.plpanalysisCohort_inclusion
- Created table results_atlas_demo.plpanalysisCohort_inclusion_result
- Created table results_atlas_demo.plpanalysisCohort_inclusion_stats
- Created table results_atlas_demo.plpanalysisCohort_summary_stats
- Created table results_atlas_demo.plpanalysisCohort_censor_stats
Creating cohort tables took 2.71secs
Loading cohortDefinitionSet
1/2- Generating cohort: Transfusion (4)                                                                                                                     
  |===============================================================================================================| 100%
Executing SQL took 1.34 mins
2/2- Generating cohort: ibuprofen (8)
  |===============================================================================================================| 100%
Executing SQL took 18.1 secs
Generating cohort set took 1.66 mins
Counting cohorts
Counting cohorts took 0.741 secs
Running predictions
Updating as cohort covariate settings is being used
Error in predictionAnalysisList$analyses[[i]] : subscript out of bounds
> 

Here is a sessionInfo:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_Europe.1251  LC_CTYPE=English_Europe.1251    LC_MONETARY=English_Europe.1251
[4] LC_NUMERIC=C                    LC_TIME=English_Europe.1251    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] plpanalysis_1.0.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7                   pillar_1.5.1                 compiler_4.1.2               DatabaseConnector_5.0.2     
 [5] tools_4.1.2                  bit_4.0.4                    jsonlite_1.7.2               lubridate_1.7.10            
 [9] checkmate_2.0.0              RSQLite_2.2.5                memoise_2.0.0                lifecycle_1.0.0             
[13] tibble_3.1.0                 pkgconfig_2.0.3              rlang_0.4.10                 rstudioapi_0.13             
[17] DBI_1.1.1                    parallel_4.1.2               PatientLevelPrediction_5.0.4 FeatureExtraction_3.1.1     
[21] fastmap_1.1.0                rJava_0.9-13                 withr_2.4.1                  CohortGenerator_0.4.0       
[25] dplyr_1.0.5                  generics_0.1.0               vctrs_0.3.7                  hms_1.0.0                   
[29] triebeard_0.3.0              bit64_4.0.5                  tidyselect_1.1.0             glue_1.6.1                  
[33] R6_2.5.0                     fansi_0.4.2                  vroom_1.5.7                  Andromeda_0.6.0             
[37] tzdb_0.1.1                   readr_2.1.2                  purrr_0.3.4                  ParallelLogger_2.0.1        
[41] SqlRender_1.7.0              blob_1.2.1                   magrittr_2.0.1               backports_1.2.1             
[45] urltools_1.7.3               ellipsis_0.3.1               assertthat_0.2.1             renv_0.13.2                 
[49] utf8_1.2.1                   stringi_1.7.6                cachem_1.0.4                 crayon_1.4.1                
> 

Next step will be to update PLP to v5.0.5

@konstjar
Copy link
Contributor Author

Attempt to use PLP v5.0.5 failed with the same problem:

Creating cohorts
Connecting using PostgreSQL driver
Creating cohort tables
- Created table results_atlas_demo.plpanalysisCohort
- Created table results_atlas_demo.plpanalysisCohort_inclusion
- Created table results_atlas_demo.plpanalysisCohort_inclusion_result
- Created table results_atlas_demo.plpanalysisCohort_inclusion_stats
- Created table results_atlas_demo.plpanalysisCohort_summary_stats
- Created table results_atlas_demo.plpanalysisCohort_censor_stats
Creating cohort tables took 2.38secs
Loading cohortDefinitionSet
1/2- Generating cohort: Transfusion (4)                                                                                                                     
  |===============================================================================================================| 100%
Executing SQL took 19.8 secs
2/2- Generating cohort: ibuprofen (8)
  |===============================================================================================================| 100%
Executing SQL took 4.92 secs
Generating cohort set took 25.36 secs
Counting cohorts
Counting cohorts took 0.712 secs
Running predictions
Updating as cohort covariate settings is being used
Error in predictionAnalysisList$analyses[[i]] : subscript out of bounds
> 

Here is sessionInfo:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_Europe.1251  LC_CTYPE=English_Europe.1251    LC_MONETARY=English_Europe.1251
[4] LC_NUMERIC=C                    LC_TIME=English_Europe.1251    

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] plpanalysis_1.0.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7                   compiler_4.1.2               pillar_1.5.1                 DatabaseConnector_5.0.2     
 [5] tools_4.1.2                  bit_4.0.4                    jsonlite_1.7.2               lubridate_1.7.10            
 [9] checkmate_2.0.0              RSQLite_2.2.5                memoise_2.0.0                lifecycle_1.0.0             
[13] tibble_3.1.0                 pkgconfig_2.0.3              rlang_0.4.10                 rstudioapi_0.13             
[17] DBI_1.1.1                    cli_3.2.0                    parallel_4.1.2               PatientLevelPrediction_5.0.5
[21] FeatureExtraction_3.2.0      fastmap_1.1.0                rJava_0.9-13                 withr_2.4.1                 
[25] CohortGenerator_0.4.0        dplyr_1.0.5                  generics_0.1.0               vctrs_0.3.7                 
[29] hms_1.0.0                    triebeard_0.3.0              bit64_4.0.5                  tidyselect_1.1.0            
[33] glue_1.6.1                   R6_2.5.0                     fansi_0.4.2                  vroom_1.5.7                 
[37] Andromeda_0.6.0              tzdb_0.1.1                   readr_2.1.2                  purrr_0.3.4                 
[41] ParallelLogger_3.0.1         SqlRender_1.7.0              blob_1.2.1                   magrittr_2.0.1              
[45] backports_1.2.1              urltools_1.7.3               ellipsis_0.3.1               assertthat_0.2.1            
[49] renv_0.13.2                  utf8_1.2.1                   stringi_1.7.6                cachem_1.0.4                
[53] crayon_1.4.1               

@konstjar
Copy link
Contributor Author

konstjar commented Nov 17, 2022

I found similar issue in PLP package, but there is no solution shared:
OHDSI/PatientLevelPrediction#292

Problem happens here:
https://github.com/OHDSI/SkeletonPredictionStudy/blob/main/R/Main.R#L165

Do you have any suggestions for any next steps I can try?

@anthonysena
Copy link
Collaborator

Thanks @konstjar - can you post the JSON for the study if possible? I'd like to take a look at that as it would appear that the predictionAnalysisList$analyses[[i]] is going beyond the length of the list for some reason.

@konstjar
Copy link
Contributor Author

Please find attached.
plp.txt

@iamalonso
Copy link

Hi @anthonysena, I'm facing the same error as @konstjar. The steps I follow was:

  1. Create the Study Package with Hydra
  2. Edit the Main.R as suggested in this thread

My JSON for the study is this and my sessionInfo():

R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.2.2
[plp.txt](https://github.com/OHDSI/WebAPI/files/10053386/plp.txt)

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] StudyClaveAZulPackage_1.0.6

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0             rJava_1.0-6                  vctrs_0.5.1                  generics_0.1.3               htmltools_0.5.3             
 [6] utf8_1.2.2                   blob_1.2.3                   rlang_1.0.6                  pillar_1.8.1                 later_1.3.0                 
[11] glue_1.6.2                   withr_2.5.0                  DBI_1.1.3                    ParallelLogger_3.0.1         bit64_4.0.5                 
[16] lifecycle_1.0.3              memoise_2.0.1                tzdb_0.3.0                   fastmap_1.1.0                httpuv_1.6.5                
[21] DatabaseConnector_5.1.0      fansi_1.0.3                  urltools_1.7.3               triebeard_0.3.0              Rcpp_1.0.9                  
[26] xtable_1.8-4                 readr_2.1.3                  renv_0.15.2                  backports_1.4.1              promises_1.2.0.1            
[31] checkmate_2.1.0              cachem_1.0.6                 vroom_1.6.0                  jsonlite_1.8.3               mime_0.12                   
[36] bit_4.0.5                    CohortGenerator_0.7.0        hms_1.1.2                    digest_0.6.30                stringi_1.7.8               
[41] dplyr_1.0.10                 shiny_1.7.1                  SqlRender_1.10.1             cli_3.4.1                    tools_4.1.2                 
[46] magrittr_2.0.3               FeatureExtraction_3.2.0      tibble_3.1.8                 RSQLite_2.2.18               crayon_1.5.2                
[51] pkgconfig_2.0.3              ellipsis_0.3.2               lubridate_1.8.0              assertthat_0.2.1             Andromeda_0.6.1             
[56] rstudioapi_0.14              R6_2.5.1                     PatientLevelPrediction_5.0.5 compiler_4.1.2              

@iamalonso
Copy link

Hello @konstjar, have you made any progress with this issue?

@konstjar
Copy link
Contributor Author

@iamalonso Nothing yet, I hope to have some information after Thanksgiving.

@alex-odysseus alex-odysseus added this to the v2.12.1 milestone Nov 28, 2022
@anthonysena
Copy link
Collaborator

Hi all - I'm still investigating this issue and I've been able to reproduce the problem described in this issue. I'll follow up when I have more information and hopefully a solution.

@anthonysena
Copy link
Collaborator

OK - thanks to @jreps for the help while investigating this. I'll work to make a new release of Hydra that has these changes but before I do that, it would be great if @konstjar and @iamalonso could confirm this change works for you.

In terms of the R code, there was 1 change made to the R/Main.R file that is in the resulting hydrated package. On line 149, here is the original code:

    # make backwards compatible
    if(is.null(predictionAnalysisList)){
      predictionAnalysisList <- backwards(predictionAnalysisListFile)
    }

Replace that with:

    # make backwards compatible
    if(length(predictionAnalysisList$analyses) <= 0){
      predictionAnalysisList <- backwards(predictionAnalysisListFile)
    }

This should allow for the package to properly format the predictionAnalysisList such that the predictionAnalysisList$analyses are found and allow the code to run to completion.

Additionally, I had to make some updates to the renv lock file to capture some updates to dependencies. Here are the notes:

  • Removed the xml2 dependency
  • Bumped up the following libraries to later versions (since I was having trouble compiling them):
    • Hmisc -> 4.7-2
    • ParallelLogger -> 3.0.1 (the skeleton requires this)
    • httpuv -> 1.6.6
    • RJSONIO -> 1.3-1.6
    • curl -> 4.3.3
    • openssl -> 2.0.4
    • CohortGenerator -> 0.4.0
    • PatientLevelPrediction -> 5.0.5
  • Removed the CohortGenerator dependency that was pointing to CRAN (it is not in CRAN)
  • Added reference to OHDSI/BigKnn v1.0.1

@konstjar
Copy link
Contributor Author

konstjar commented Dec 6, 2022

@anthonysena Thank you! Your fix solves the issue.

anthonysena added a commit to OHDSI/Hydra that referenced this issue Dec 6, 2022
anthonysena added a commit that referenced this issue Dec 6, 2022
@iamalonso
Copy link

@anthonysena During these days I will dedicate time to implement the solution you propose.
As soon as I have news I will inform you.
Thanks!

@anthonysena
Copy link
Collaborator

Hi @iamalonso - I've implemented the fix on the branch referenced in #2174 which should make testing things a bit easier if you'd like to install that version of WebAPI.

@anthonysena anthonysena linked a pull request Dec 13, 2022 that will close this issue
ssuvorov-fls pushed a commit that referenced this issue Jan 23, 2023
ssuvorov-fls pushed a commit that referenced this issue Jan 23, 2023
(cherry picked from commit 84a2cdc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants