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

enforce yaml 1.2 #22

Open
grst opened this issue Oct 29, 2024 · 2 comments
Open

enforce yaml 1.2 #22

grst opened this issue Oct 29, 2024 · 2 comments

Comments

@grst
Copy link
Collaborator

grst commented Oct 29, 2024

Description of feature

We don't want THIS 👇

Antifibrotic:
    "no": "#262626"
    "yes": "#d4d4d4"
unlist(params$colors$Antifibrotic)
    FALSE      TRUE 
"#262626" "#d4d4d4"

originally reported by @DSchreyer

@grst
Copy link
Collaborator Author

grst commented Nov 18, 2024

dso uses ruamel to read/write yaml files which is already exclusively using yaml 1.2.
The problem is really on the R side, as it seems there's no yaml 1.2 library in R.
See also this discussion: vubiostat/r-yaml#76

@grst grst transferred this issue from Boehringer-Ingelheim/dso Nov 18, 2024
@grst
Copy link
Collaborator Author

grst commented Nov 18, 2024

@DSchreyer there's now a workaround described in vubiostat/r-yaml#76

yaml::read_yaml(...,
                     handlers = list("bool#yes" = \(x) {attr(x, "yaml_bool") <- TRUE; x},
                                     "bool#no"  = \(x) {attr(x, "yaml_bool") <- FALSE; x})) |>
        purrr::modify_tree(leaf = \(x) {
            
            if (is.character(x) && is.logical(attr(x, "yaml_bool"))) {
                if (x %in% c("true", "false")) {
                    return(attr(x, "yaml_bool"))
                } else {
                    attr(x, "yaml_bool") <- NULL
                    return(x)
                }
            } else {
                return(x)
            }
        })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant