PRL-PRG / promisedyntracer

Tracer for promises in R
1 stars 3 forks source link

Nested hook execution in package "cleanEHR" #22

Closed kondziu closed 6 years ago

kondziu commented 6 years ago

I got the following log:

[1/1] Executing file: /media/kondziu/b7a9548c-13a0-4fe6-8a28-de8d491a209b/R/traces/lucoa/2018-01-19-18-30-19/vignettes/cleanEHR-tour.R
       site_id episode_id nhs_number pas_number         t_admission t_discharge
1: pseudo_site          1         NA         NA 1970-01-01 01:00:00        <NA>
2: pseudo_site          2         NA         NA 1970-01-01 01:00:00        <NA>
3: pseudo_site          3         NA         NA 1970-01-01 01:00:00        <NA>
4: pseudo_site          4         NA         NA 1970-01-01 01:00:00        <NA>
5: pseudo_site          5         NA         NA 1970-01-01 01:00:00        <NA>
6: pseudo_site          6         NA         NA 1970-01-01 01:00:00        <NA>
   parse_file parse_time pid index
1:         NA       <NA>   1     1
2:         NA       <NA>   2     2
3:         NA       <NA>   3     3
4:         NA       <NA>   4     4
5:         NA       <NA>   5     5
6:         NA       <NA>   6     6
Error in  : 
  DYNTRACE: encountered ACTIVE BINDING frame, missing implementation, confused
Calls: create.cctable -> <Anonymous>
In addition: Warning messages:
1: In Èx³2ÃU :
  '/media/kondziu/b7a9548c-13a0-4fe6-8a28-de8d491a209b/R/traces/lucoa/2018-01-19-18-30-19/vignettes' already exists
2: Removed 4 rows containing missing values (geom_vline). 
3: In Èx³2ÃU : NAs introduced by coercion
4: In X OCÃU : NAs introduced by coercion
5: In Èx³2ÃU : NAs introduced by coercion
6: In Èx³2ÃU : NAs introduced by coercion
7: In Èx³2ÃU : NAs introduced by coercion
8: In Èx³2ÃU :
  Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or been created manually using structure() or similar). Avoid key<-, names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. Also, in R<=v3.0.2, list(DT1,DT2) copied the entire DT1 and DT2 (R's list() used to copy named objects); please upgrade to R>v3.0.2 if that is biting. If this message doesn't help, please report to datatable-help so the root cause can be fixed.
error while dyntracing code block
Error: [ERROR] - [NESTED HOOK EXECUTION] - probe_promise_created triggers probe_end
Execution halted
Error: [ERROR] - [NESTED HOOK EXECUTION] - probe_promise_created triggers probe_promise_created
Error: [ERROR] - [NESTED HOOK EXECUTION] - probe_promise_created triggers probe_environment_lookup_var
Fatal error: error during cleanup

The code of the vignette (including instrumentation):

library(promisedyntracer)

dyntracer <- create_dyntracer('/media/kondziu/b7a9548c-13a0-4fe6-8a28-de8d491a209b/R/traces/lucoa/2018-01-19-18-30-19/data/cleanEHR-tour.sqlite',verbose=FALSE)
dyntrace(dyntracer, {

    ## ------------------------------------------------------------------------
    library(cleanEHR)
    data.path <- paste0(find.package("cleanEHR"), "/doc/sample_ccd.RData")
    load(data.path)

    ## ------------------------------------------------------------------------
    print(head(ccd@infotb))

    ## ------------------------------------------------------------------------
    # quickly check how many episodes are there in the dataset.
    ccd@nepisodes

    ## ---- fig.width=10, fig.height=11, out.width='700px', results='hide', message=FALSE, warning=FALSE----
    # check the heart rate, bilirubin, fluid balance, and drugs of episode_id = 7. 
    # NOTE: due to anonymisation reason, some episodes data cannot be displayed
    # properly. 
    episode.graph(ccd, 7, c("h_rate",  "bilirubin", "fluid_balance_d"))

    ## ---- fig.width=10, fig.height=6, out.width='700px', results='hide', message=FALSE, warning=FALSE----
    # contains all the 1D fields i.e. non-longitudinal
    tb1 <- sql.demographic.table(ccd)

    # filter out all dead patient. (All patients are dead in the dataset.)
    tb1 <- tb1[DIS=="D"]

    # subset variables we want (ARSD = Advanced respiratory support days,
    # apache_prob = APACHE II probability)
    tb <- tb1[, c("SEX", "ARSD", "apache_prob"), with=F]
    tb <- tb[!is.na(apache_prob)]

    # plot
    library(ggplot2)
    ggplot(tb, aes(x=apache_prob, y=ARSD, color=SEX)) + geom_point()

    ## ------------------------------------------------------------------------
    # To prepare a YAML configuration file like this. You write the following text
    # in a YAML file. 
    conf <- "
    NIHR_HIC_ICU_0108:
      shortName: hrate
    NIHR_HIC_ICU_0112:
      shortName: bp_sys_a
      dataItem: Systolic Arterial blood pressure - Art BPSystolic Arterial blood pressure
    NIHR_HIC_ICU_0093:
       shortName: sex
    "
    library(yaml)
    tb <- create.cctable(ccd, yaml.load(conf), freq=1)

    # a lazy way to do that. 
    tb <- create.cctable(ccd, list(NIHR_HIC_ICU_0108=list(), 
                             NIHR_HIC_ICU_0112=list(), 
                             NIHR_HIC_ICU_0093=list()), 
                         freq=1)
    print(tb$tclean)

    ## ------------------------------------------------------------------------
    tb$tclean[, mean(NIHR_HIC_ICU_0108, na.rm=T), by=c("site", "episode_id")]

    ## ---- fig.width=12, fig.height=12, out.width='700px', results='hide', message=FALSE, warning=FALSE----
    conf <-"
    NIHR_HIC_ICU_0108:
      shortName: hrate
      dataItem: Heart rate
      distribution: normal
      decimal_places: 0
      range:
        labels:
          red: (0, 300)
          amber: (11, 150)
        apply: drop_entry
      missingness: # remove episode if missingness is higher than 70% in any 24 hours interval 
        labels:
          yellow: 24
        accept_2d:
          yellow: 70 
        apply: drop_episode
    "

    ctb <- create.cctable(ccd, yaml.load(conf), freq=1)
    ctb$filter.ranges("amber") # apply range filters
    ctb$filter.missingness()
    ctb$apply.filters()

    cptb <- rbind(cbind(ctb$torigin, data="origin"), 
                  cbind(ctb$tclean, data="clean"))

    ggplot(cptb, aes(x=time, y=NIHR_HIC_ICU_0108, color=data)) + 
      geom_point(size=1.5) + facet_wrap(~episode_id, scales="free_x")

})
destroy_dyntracer(dyntracer)
write('OK', '/media/kondziu/b7a9548c-13a0-4fe6-8a28-de8d491a209b/R/traces/lucoa/2018-01-19-18-30-19/data/cleanEHR-tour.OK')
aviralg commented 6 years ago

I suspect this is related to issue #20. This prints a bit more stuff as opposed to others but I believe that solving other issues will also solve this one.

kondziu commented 6 years ago
[1/1] Executing file: /home/kondziu/workspace/promise-dyntracing-experiment/data/2018-01-25-15-17-33/vignettes/cleanEHR-tour.R
       site_id episode_id nhs_number pas_number         t_admission t_discharge
1: pseudo_site          1         NA         NA 1970-01-01 01:00:00        <NA>
2: pseudo_site          2         NA         NA 1970-01-01 01:00:00        <NA>
3: pseudo_site          3         NA         NA 1970-01-01 01:00:00        <NA>
4: pseudo_site          4         NA         NA 1970-01-01 01:00:00        <NA>
5: pseudo_site          5         NA         NA 1970-01-01 01:00:00        <NA>
6: pseudo_site          6         NA         NA 1970-01-01 01:00:00        <NA>
   parse_file parse_time pid index
1:         NA       <NA>   1     1
2:         NA       <NA>   2     2
3:         NA       <NA>   3     3
4:         NA       <NA>   4     4
5:         NA       <NA>   5     5
6:         NA       <NA>   6     6
DYNTRACE LOG - ERROR - lookup.cpp · get_binding_value(...) · 19 - encountered ACTIVE BINDING frame, missing implementation, confused