[Bug]: qenv is valid but code is not reproducible
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Tái hiện các ví dụ within(qenv(), ...) trong một phiên R --vanilla mới, sau đó kiểm tra việc khởi tạo qenv và cách sử dụng .GlobalEnv. So sánh hành vi khi teal.modules.clinical được nạp và khi không có; công việc được xem là hoàn tất khi ngăn không cho một qenv có vẻ hợp lệ nếu mã của nó phụ thuộc vào các đối tượng hoặc hàm không khả dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened?
When creating/modifying a qenv object or derivative, it fails if there are objects or calls to packages outside the environment.
However, when a library is loaded before the creation of the qenv object, functions or object can be found so the code succeeds and results in a valid object even if code results on not reproducible.
This results on teal applications that work, but when users copy and paste the code on a new vanilla R session (R --vanilla), the code will raise an error because there aren't some objects or functions in the environment.
Some testing might also fail as in that environment(s) libraries might not be loaded (as I found on https://github.com/insightsengineering/coredev-tasks/issues/536) .
library("teal.code")
within(qenv(), {ADSL <- tmc_ex_adsl})
#> <qenv.error: object 'tmc_ex_adsl' not found
#> when evaluating qenv code:
#> ADSL <- tmc_ex_adsl>
library("teal.modules.clinical")
#> Loading required package: teal
#> Loading required package: shiny
#> Loading required package: teal.slice
#> Registered S3 method overwritten by 'teal':
#> method from
#> c.teal_slices teal.slice
#>
#> You are using teal version 1.0.0
#>
#> Attaching package: 'teal'
#> The following objects are masked from 'package:teal.slice':
#>
#> as.teal_slices, teal_slices
#> Loading required package: teal.transform
#> Loading required package: tern
#> Loading required package: rtables
#> Loading required package: formatters
#>
#> Attaching package: 'formatters'
#> The following object is masked from 'package:base':
#>
#> %||%
#> Loading required package: magrittr
#>
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#>
#> str
#> Registered S3 method overwritten by 'tern':
#> method from
#> tidy.glm broom
within(qenv(), {ADSL <- tmc_ex_adsl})
#> <environment: 0x000001dc3ac0c8d0> 🔒
#> Parent: <environment: package:teal.modules.clinical>
#> Bindings:
#> - ADSL: [tbl_df]
Created on 2025-09-09 with reprex v2.1.1
I would expect that the last object don't succeed as the code can't be run in a fresh R session without the teal.modules.clinical package, and often there is no information about it (except in some occasions via parent.env([email protected]) and the attr(env, "name")).
I think this is because the package uses the global environment instead of the base environment on initialization.
This might be related to #201
sessionInfo()
R version 4.5.1 (2025-06-13 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.utf8
time zone: Europe/Madrid
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] teal.modules.clinical_0.11.1 tern_0.9.9
[3] rtables_0.6.13 magrittr_2.0.3
[5] formatters_0.5.11 teal.transform_0.7.0
[7] teal_1.0.0 teal.slice_0.7.0
[9] teal.data_0.8.0 shiny_1.11.1
[11] teal.code_0.7.0 pkgdown_2.1.3
[13] devtools_2.4.5 usethis_3.2.0
loaded via a namespace (and not attached):
[1] gtable_0.3.6 ggplot2_3.5.2 htmlwidgets_1.6.4 remotes_2.5.0.9000
[5] lattice_0.22-7 vctrs_0.6.5 tools_4.5.1 Rdpack_2.6.4
[9] generics_0.1.4 tibble_3.3.0 pkgconfig_2.0.3 Matrix_1.7-4
[13] checkmate_2.3.3 RColorBrewer_1.1-3 lifecycle_1.0.4 compiler_4.5.1
[17] farver_2.1.2 textshaping_1.0.3 httpuv_1.6.16 htmltools_0.5.8.1
[21] later_1.4.4 pillar_1.11.0 urlchecker_1.0.1 tidyr_1.3.1
[25] ellipsis_0.3.2 cachem_1.1.0 sessioninfo_1.2.3 mime_0.13
[29] nestcolor_0.1.3 tidyselect_1.2.1 digest_0.6.37 stringi_1.8.7
[33] dplyr_1.1.4 purrr_1.1.0 splines_4.5.1 fastmap_1.2.0
[37] grid_4.5.1 cli_3.6.5 logger_0.4.0 bsicons_0.1.2
[41] survival_3.8-3 pkgbuild_1.4.8 broom_1.0.9 rutils_0.0.2.92
[45] scales_1.4.0 promises_1.3.3 backports_1.5.0 ragg_1.5.0
[49] memoise_2.0.1 evaluate_1.0.5 rbibutils_2.3 miniUI_0.1.2
[53] profvis_0.4.0 rlang_1.1.6 Rcpp_1.1.0 xtable_1.8-4
[57] glue_1.8.0 pkgload_1.4.0 rstudioapi_0.17.1 teal.logger_0.4.0
[61] R6_2.6.1 systemfonts_1.2.3 fs_1.6.6
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct.
Contribution Guidelines
- I agree to follow this project's Contribution Guidelines.
Security Policy
- I agree to follow this project's Security Policy.
- Ngôn ngữ chính
- R
- Star
- 12
- Fork
- 11
- Merge trung bình
- 8 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của insightsengineering/teal.code
-
Move to PharmaverseCó thể đã có người làm @llrs-roche đã nhận 38 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
insightsengineering/teal.code#292 ·
-
[Feature Request]: High cyclomatic complexity leds to bad readabilityCó thể đã có người làm @llrs-roche đã nhận 39 ngày trước. Đang mởenhancement
Độ khó 3/5 3-5 ngày Mức phù hợp với người mới 45/100
insightsengineering/teal.code#295 ·
-
core discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
insightsengineering/teal.code#291 · 2 bình luận · 1 reaction ·
-
bug core
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
insightsengineering/teal.code#275 ·
-
This is test issue to test copilot capabilitiesCó thể đã có người làm @copilot-swe-agent đã nhận 435 ngày trước. Đang mởbug
insightsengineering/teal.code#266 · 1 reaction · 1 người được giao ·
Tất cả issue của insightsengineering/teal.code
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
mitchelloharawild/ggtime#39 ·
-
Add more snippets to R and JuliaĐang mởenhancement good first issue help wanted
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Breaking 🏴☠️ Consistency :green_apple: :apple:
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
easystats/bayestestR#789 ·
Maintainer thường phản hồi trong vòng 1 ngày