-
Notifications
You must be signed in to change notification settings - Fork 70
Add sector order to create_interactive_report input #356
Conversation
@MonikaFu, I made this a draft because I see it depends on https://github.com/2DegreesInvesting/create_interactive_report/pull/313 -- so I interpret that this PR is not ready to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! See my comments.
web_tool_script_3.R
Outdated
@@ -218,7 +223,8 @@ create_interactive_report( | |||
ipr_results_stress_test = ipr_results_stress_test, | |||
display_currency = display_currency, | |||
currency_exchange_value = currency_exchange_value, | |||
header_dictionary = header_dictionary | |||
header_dictionary = header_dictionary, | |||
sector_order = sector_order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion above adds logic that you can't inject in a variable like sector_order
, but you can inject it in a function sector_order()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try something out. An example may be clearer than my words above.
@maurolepore - indeed. Both PRs are needed for the code to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made minor changes to break the dependency with create_interactive_report#313. All workflows on GitHub actions now pass, and you can merge this PR before create_interactive_report#313.
It now LGTM. Feel free to edit or merge.
sector_order <- function(path) { | ||
# TODO: Remove following create_interactive_report#313 | ||
if (!fs::file_exists(path)) { | ||
rlang::warn(glue::glue( | ||
"This file doesn't exit: {path}. | ||
Have you already merged create_interactive_report#313?" | ||
)) | ||
return(NULL) | ||
} | ||
|
||
readr::read_csv( | ||
path(template_path, "data", "sector_order", "sector_order.csv"), | ||
col_types = cols() | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will now work even if the data is unavailable.
(This is an intermediate refactoring step to break the dependency on create_interactive_report#313.)
arg <- list(sector_order = sector_order()) | ||
arguments <- append(arguments, arg) | ||
} | ||
purrr::invoke(create_interactive_report, arguments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will now work even if create_interactive_report()
has no formal argument sector_order
.
(This is an intermediate refactoring step to break the dependency on create_interactive_report#313.)
I see one test fails (R-release on Windows) do to problems with latex. That seems unrelated to this PR so I would approve it anyway. Error: Error: LaTeX failed to compile D:/a/PACTA_analysis/PACTA_analysis/PACTA_analysis/working_dir/50_Outputs/TestPortfolio_Input/executive_summary/template.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See template.log for more info. Also, the same environment that fails |
Thanks @maurolepore for making this PR deployable without the dependency on create_interactive_report#313. I will try to follow your steps in the future! |
The scafolding I added here is removed via #360 |
Relates to https://github.com/2DegreesInvesting/create_interactive_report/pull/313
For this PR to work properly above PR from
create_interactive_report
is needed.In this PR I modify
web_tool_script_3.R
to readsector_order
data fromcreate_interactive_report
directory and add it as an input to thecreate_interactive_report
function call.depends on 2DegreesInvesting/create_interactive_report/pull/313