dark-peak-analytics / assertHE

R package to assist in the verification of health economic decision models.
https://dark-peak-analytics.github.io/assertHE/
Other
4 stars 10 forks source link

When add-in used successfully, function call should be printed to the console. #90

Closed RobertASmith closed 3 months ago

RobertASmith commented 3 months ago

Currently there is no way to replicate a run of the assertHE functionality from the add-in.

We should print the code run to the console so that the same output could be replicated rather than using the add-in again.

Smit-tay commented 3 months ago

This seems trivial, but, for some reason, the string I construct and cat() is being emitted multiple times - although, not exactly.

Construct the function call string from the parameters provided

func_text <- paste0("assertHE::visualise_project(
project_path = '", app_env$p_project_path,  "',
foo_path = '", app_env$p_foo_path,  "',
test_path = '", app_env$p_test_path,  "',
exclude_files = '", app_env$p_exclude_files,  "',
exclude_dirs = '", app_env$p_exclude_dirs,  "',
run_coverage = ", app_env$p_run_coverage,  ",
color_no_test = '", app_env$p_color_no_test,  "',
color_with_test = '", app_env$p_color_with_test,  "',
color_mod_coverage = '", app_env$p_color_mod_coverage,  "',
moderate_coverage_range = ", app_env$p_moderate_coverage_range,  ",
print_isolated_foo = ", app_env$p_print_isolated_foo,  ",
show_in_shiny = ", app_env$p_show_in_shiny,  ",
network_title = '", app_env$p_network_title,  "',
scale_node_size_by_degree = ", app_env$p_scale_node_size_by_degree, ")" )

# Print the function call to the console
# Ensure the message is printed immediately
flush.console()
cat("\n\n Calling assertHE::visualise_project:\n\n", func_text, "\n\n")
flush.console()

Listening on http://127.0.0.1:4455

Calling assertHE::visualise_project:

assertHE::visualise_project( project_path = '.', foo_path = 'R', test_path = '', exclude_files = 'NA', exclude_dirs = 'NA', run_coverage = FALSE, color_no_test = '#FAD1D0', color_with_test = '#E6FFE6', color_mod_coverage = '#FFD580', moderate_coverage_range = 0.2, print_isolated_foo = TRUE, show_in_shiny = FALSE, network_title = 'Function Network', scale_node_size_by_degree = TRUE) assertHE::visualise_project( project_path = '.', foo_path = 'R', test_path = '', exclude_files = 'NA', exclude_dirs = 'NA', run_coverage = FALSE, color_no_test = '#9C0000', color_with_test = '#65A765', color_mod_coverage = '#E49B0F', moderate_coverage_range = 0.8, print_isolated_foo = TRUE, show_in_shiny = FALSE, network_title = 'Function Network', scale_node_size_by_degree = TRUE) assertHE::visualise_project( project_path = '.', foo_path = 'R', test_path = '', exclude_files = 'NA', exclude_dirs = 'NA', run_coverage = FALSE, color_no_test = '#9C0000', color_with_test = '#65A765', color_mod_coverage = '#E49B0F', moderate_coverage_range = 0.2, print_isolated_foo = TRUE, show_in_shiny = FALSE, network_title = 'Function Network', scale_node_size_by_degree = TRUE)

The following functions are isolated (no parent or child):

RobertASmith commented 3 months ago

I think it is because the input for moderate_coverage_range is a vector of length 2.

The following reprex should work:

app_env <- letters
names(app_env) <- LETTERS

# the moderate_coverage_range variable with two values
app_env$K <- c(0.2, 0.8)

func_text <- paste0("assertHE::visualise_project(
project_path = '", app_env$A,  "',
foo_path = '", app_env$B,  "',
test_path = '", app_env$C,  "',
exclude_files = '", app_env$D,  "',
exclude_dirs = '", app_env$E,  "',
run_coverage = ", app_env$G,  ",
color_no_test = '", app_env$H,  "',
color_with_test = '", app_env$I,  "',
color_mod_coverage = '", app_env$J,  "',
moderate_coverage_range = c(", paste0(app_env$K, collapse = ","),  "),
print_isolated_foo = ", app_env$L,  ",
show_in_shiny = ", app_env$M,  ",
network_title = '", app_env$N,  "',
scale_node_size_by_degree = ", app_env$O, ")" )

cat("\n\n Calling assertHE::visualise_project:\n\n", func_text, "\n\n")
Smit-tay commented 3 months ago

Right, and not just that element, the colors are also collections.
I am submitting a Pull Request for this now

Smit-tay commented 3 months ago

My currently open PR https://github.com/dark-peak-analytics/assertHE/pull/88 contains this and the other issue

Smit-tay commented 3 months ago

Output is now a correct R command which can be executed to run the visualizer .

example output:

assertHE::visualise_project(project_path = ".", foo_path = "R", test_path = "", exclude_files = "NA", exclude_dirs = "NA", run_coverage = FALSE, color_no_test = c("background" = "#FAD1D0", "border" = "#9C0000", "highlight" = "#9C0000"), color_with_test = c("background" = "#E6FFE6", "border" = "#65A765", "highlight" = "#65A765"), color_mod_coverage = c("background" = "#FFD580", "border" = "#E49B0F", "highlight" = "#E49B0F"), moderate_coverage_range = c(0.2, 0.8), print_isolated_foo = TRUE, show_in_shiny = FALSE, network_title = "Function Network", scale_node_size_by_degree = TRUE)