Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Add sector order to create_interactive_report input #356

Merged
merged 6 commits into from
Dec 9, 2020

Conversation

MonikaFu
Copy link
Contributor

@MonikaFu MonikaFu commented Dec 9, 2020

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 read sector_order data from create_interactive_report directory and add it as an input to the create_interactive_report function call.


depends on 2DegreesInvesting/create_interactive_report/pull/313

@MonikaFu MonikaFu self-assigned this Dec 9, 2020
@maurolepore maurolepore marked this pull request as draft December 9, 2020 13:26
@maurolepore
Copy link
Contributor

@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.

Copy link
Contributor

@maurolepore maurolepore left a 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 Show resolved Hide resolved
@@ -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
Copy link
Contributor

@maurolepore maurolepore Dec 9, 2020

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().

Copy link
Contributor

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.

@MonikaFu
Copy link
Contributor Author

MonikaFu commented Dec 9, 2020

@maurolepore - indeed. Both PRs are needed for the code to work.

@maurolepore maurolepore marked this pull request as ready for review December 9, 2020 15:38
Copy link
Contributor

@maurolepore maurolepore left a 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.

Comment on lines +166 to +180
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()
)
}
Copy link
Contributor

@maurolepore maurolepore Dec 9, 2020

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)
Copy link
Contributor

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.)

@maurolepore
Copy link
Contributor

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 on: push passes on: pull_request, so I suspect the problem may go away by itself -- I'll re-run the workflows and see what happens.

image

@MonikaFu
Copy link
Contributor Author

MonikaFu commented Dec 9, 2020

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!

@MonikaFu MonikaFu closed this Dec 9, 2020
@MonikaFu MonikaFu reopened this Dec 9, 2020
@MonikaFu MonikaFu merged commit cb57451 into master Dec 9, 2020
@MonikaFu MonikaFu deleted the add-sector-order-to-interactive-report-input branch December 9, 2020 16:32
@maurolepore
Copy link
Contributor

The scafolding I added here is removed via #360

maurolepore added a commit that referenced this pull request Dec 11, 2020
Closes #359

This reverts a bunch of commits (with minor changes) to remove scaffolding added via #356.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants