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

Tefera update branch #100

Closed
wants to merge 25 commits into from
Closed

Tefera update branch #100

wants to merge 25 commits into from

Conversation

Tefera19
Copy link

Hi @randrescastaneda,

I have added `detail' argument in the main functions.

@Tefera19
Copy link
Author

Hi @randrescastaneda ,

I have updated country_list (cl_validation_raw()) script, I have also added a function that clean validation report object from the environment variable.

@Tefera19
Copy link
Author

Hi @randrescastaneda ,

I have updated test-countries-validation() as per the update implemented in pip_countries(). I have also added gls in the unit test functions when it is requred.

@randrescastaneda
Copy link
Member

Thank you so much. I'll check and get back to you.

@Tefera19
Copy link
Author

Hi @randrescastaneda , Thank you for the feedback, I have updated the unit test functions. But, there are two outstanding issues that I couldn't resolve ("test-load_aux.R" and "test-pip_sign_save.R").

@@ -53,7 +53,12 @@ Imports:
joyn,
dm,
config,
collapse
collapse,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these dependencies? For example, do we need covr? Could it be moved to suggests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved covr package to suggests section.

@@ -2,8 +2,26 @@

export("%>%")
export(auto_aux_update)
export(cl_validate_raw)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to export all the validation functions? I think they are meant to be used internally. If they are, you should use #' @keywords internal in the roxygen chunk of those functions. If they are not, please provide a short explanation. Thanks !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you have suggested, I included #' @Keywords internal to roxygen chunk to all the data validation functions.

Thanks

validate(cl, name = "CL raw data validation") |>
validate_if(is.character(country_code),
description = "`country_code` should be character") |>
validate_cols(in_set(c("ABW", "AFG", "AGO", "ALB", "AND", "ARE", "ARG", "ARM", "ASM", "ATG", "AUS", "AUT", "AZE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be hardcoded. The list of countries could vary from one year to another (though unlikely). Please use unique() over the column with the country codes in the priceframework data (pfw)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comment, I pulled the country list from pfw data.

Thanks

#' @importFrom assertr in_set not_na is_uniq
#'
#' @export
cpi_validate_raw <- function(cpi, detail = getOption("pipaux.detail.raw")){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent you an email showing you a real case of a problem that this check should find out... please add a check for that. THANKS!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case you have sent me via email shows same cpi value for multiple years. What would be the minimum years where the cpi value could be same? In the example, cpi value are same for four survey reference years. In the latest PR, I checked same cpi / duplicate cpi.

Thanks


}

cli::cli_inform("Validation report ('validation_report') has been added to the environment varaible (.pipaux).")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use cli syntax. like "({.field validation_report})" . See here: https://cli.r-lib.org/reference/inline-markup.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I implemented your suggestion.

Thanks

@@ -27,6 +28,9 @@ pip_country_list <- function(action = c("update", "load"),
## Special national accounts --------
cl <- pip_country_list_update(class_branch = class_branch)

# validate country list raw data
cl_validate_raw(cl, detail = detail)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i am a little confused. Where does cl_validate_output() go? Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results from this function depends on value of detail argument. By default (detail = FALSE), for example result cl_validate_output() goes to the console. If detail = TRUE, the result will be emailed (now - will be printed to the console when we run send_report() function)

Thanks


print(.pipaux$validation_report)

# fname <- file.path(tempdir(), "data_validation_report.csv")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will work on this later, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will work !

description = "`2026` should be character") |>
validate_if(is.character(`2027`),
description = "`2027` should be character") |>
validate_if(is.character(`2028`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an easier way to check all these columns. First, these columns will increase and we can't update the code each time they do. Second, the importance here is that they years exists, so that's what is needed to be checked. There should no be jumps in the years.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment, I have implemented your comment in the latest PR.

@@ -0,0 +1,25 @@
Repo,hash,branch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, this file should be part of the PR. It could break something else later on. For now, remove it from the PR. Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed this file from the latest PR.

Copy link
Member

@randrescastaneda randrescastaneda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Tefera19 ,

I think the PR is really, really good. Great job. Thanks.

I added a few comments. Please address them and push to the same branch. You don't neet to create a new PR. Just let me know when it is ready to review again. Thanks!

@randrescastaneda
Copy link
Member

Hi @Tefera19 ,

I'm closing this PR because we need this changes to be added to branch DEV_v2_tefera_testing.

Thank you.

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

Successfully merging this pull request may close these issues.

2 participants