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

Add argument for log_write to export log object as Rds #164

Merged
merged 15 commits into from
Jul 6, 2023

Conversation

parmsam-pfizer
Copy link
Collaborator

@parmsam-pfizer parmsam-pfizer commented Feb 14, 2023

Thank you for your Pull Request!

We have developed a Pull Request template to aid you and our reviewers. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the logrx codebase remains robust and consistent.

The spirit of logrx

While many packages to facilitate the logging of code already exist in the R ecosystem, it is hard to find a solution that works well for clinical programming applications. Many logging implementations are more implicit and rely on user input to create the log for the execution of a script. While this is useful for logging specific events of an application, in clinical programming a log has a set purpose.

logrx is built around the concept of creating a log for the execution of an R script that provides an overview of what happened as well as the environment that it happened in. We set out to create a flexible logging utility that could provide the necessary information to anyone reviewing the code execution so they can recreate the execution environment and run the code for themselves. Please make sure your Pull Request meets this spirit of logrx.

Please check off each taskbox as an acknowledgment that you completed the task. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the dev branch until you have checked off each task.

  • The spirit of logrx is met in your Pull Request
  • Check that your Pull Request is targeting the dev branch, Pull Requests to master should use the Release Pull Request Template
  • Code is formatted according to the tidyverse style guide
  • Updated relevant unit tests or have written new unit tests. Remember to remove any configured log objects at the end of every test using log_remove().
  • Creation/updates to relevant roxygen headers and examples.
  • Run devtools::document() so all .Rd files in the man folder and the NAMESPACE file in the project root are updated appropriately
  • Run pkgdown::build_site() and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.
  • Update NEWS.md if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers)
  • Address any updates needed for vignettes and/or templates
  • Run R CMD check locally and address all errors and warnings - devtools::check()
  • Link the issue so that it closes after successful merging.
  • Address all merge conflicts and resolve appropriately
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

Adds optional argument (FALSE by default) to export log object into Rds format that users can more easily subset/filter. Addresses the second part of #162.

@parmsam-pfizer parmsam-pfizer marked this pull request as ready for review February 15, 2023 18:58
R/log.R Outdated Show resolved Hide resolved
R/log.R Outdated Show resolved Hide resolved
@kodesiba
Copy link
Collaborator

@parmsam-pfizer thanks so much for putting this in, definitely hoping to get this through review this week and into dev branch then we can see what else we might want to look into including in another release.

Copy link
Collaborator

@nicholas-masel nicholas-masel left a comment

Choose a reason for hiding this comment

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

Everything looks good. I did add a few comments for discussion. @thomasp-b @kodesiba @bms63 @parmsam-pfizer Would love to hear your thoughts on:

  • Should we export everything into the rds or subset?
  • Should we just store the session_info object, rather than capture it's output and store, and let write function capture the output and write it out nicely?

R/log.R Outdated
}
}
)
cleaned_log_list$session_info <- session_info(info = "all")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you have to do this because we capture the output of session_info and store it, rather than just storing the session info object. I think we can move the capture output to the write function so this will still print pretty, and then you won't need to get the session info again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Adjusted and updated the unit test.

"unapproved_packages_functions", "errors", "warnings"
)
log_options <- as.list(getOption('log.rx'))
cleaned_log_list <- purrr::map2(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't 100% convinced myself, but I'm wondering if we would just return everything to the rds rather than NULL out sections. Those writing the log and those consuming these rds files might be different people with different use cases.

@bms63
Copy link
Collaborator

bms63 commented Feb 23, 2023

Everything looks good. I did add a few comments for discussion. @thomasp-b @kodesiba @bms63 @parmsam-pfizer Would love to hear your thoughts on:

  • Should we export everything into the rds or subset?

The ability to subset what you want in the rds output sounds interesting. I don't want to clutter up axecute with so many options, but I could see that being handy rather then a full export.

Is J&J interested in this as well or is this just Pfizer folks?

  • Should we just store the session_info object, rather than capture it's output and store, and let write function capture the output and write it out nicely?

I'm not sure? What are pros and cons?

We talked of meeting in June and doing another release in the Summer. Are we trying to get this out before that Summer release?

NEWS.md Outdated
Comment on lines 1 to 3
# logrx 0.2.2

- Add `include_rds` argument to `axecute()` to export log as rds file
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to upversion to 0.3.0

Copy link
Collaborator

Choose a reason for hiding this comment

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

@parmsam-pfizer can you update NEWS to include this under 0.3.0 and resolve the merge conflict

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Thanks!

@bms63 bms63 linked an issue Jun 26, 2023 that may be closed by this pull request
@bms63 bms63 merged commit feeaeac into pharmaverse:dev Jul 6, 2023
5 of 6 checks passed
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.

Feature Request: Add ability to easily subset/filter log files
4 participants