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

how to log unapproved package and function use #51

Merged

Conversation

nicholas-masel
Copy link
Collaborator

I created a basic vignette to explain how to use timber to log the unapproved use along with a simple example. I'm happy for this to go somewhere other than a vignette too. Regardless, the content is here though and ready for review.

There is one function embedded in the vignette that we might want to export. @kodesiba You mentioned maybe storing in some sort of utils. Check out the vignette for more context for .x and .y arguments.

build_approved <- function(.x, .y){
   
  all <- tibble::tibble(function_name = getNamespaceExports(.x),
                        library = paste0("package:", .x))

  if (.y[1] %in% c("All", "all")){
    all
  } else{
    all[all$function_name %in% .y,]
  }
  
}

I also don't want this to hold up anything, so if this isn't key, we can save for later.

@nicholas-masel nicholas-masel linked an issue Apr 29, 2022 that may be closed by this pull request
@nicholas-masel
Copy link
Collaborator Author

Ok, so everything failed :(

I'm using getNamespaceExports() to get all of the functions for a package, which requires the package to be installed.

In the example, I think I can just swap out the use of haven to some other package we import and hopefully that will work.

@nicholas-masel
Copy link
Collaborator Author

I'm stumped as to why axecute is failing in ubuntu dev.

Here is the error:

Error: --- re-building ‘approved.Rmd’ using rmarkdown
Quitting from lines 100-101 (approved.Rmd) 
Error: Error: processing vignette 'approved.Rmd' failed with diagnostics:
'length = 3' in coercion to 'logical(1)'
--- failed re-building ‘approved.Rmd’
--- re-building ‘timber.Rmd’ using rmarkdown
--- finished re-building ‘timber.Rmd’

Here is line 100-101:

axecute(file.path(dir,"mpg.R"))

@kodesiba
Copy link
Collaborator

kodesiba commented May 5, 2022

@nicholas-masel if you pull down dev into your branch you will get the update. It was the sessioninfo issue that I just merged into dev

@nicholas-masel
Copy link
Collaborator Author

@nicholas-masel if you pull down dev into your branch you will get the update. It was the sessioninfo issue that I just merged into dev

Thanks @kodesiba! That did the trick.

@kodesiba
Copy link
Collaborator

kodesiba commented May 9, 2022

@nicholas-masel I really like how you used the different chunks in the vignette to show the user what they need to see and also make everything work. I showed this to @thomasp-b when he and I talked about the table vignette and this is a great strategy for making vignettes for {timber} in a way that is super informative and also intuitive to the user. While I think the whole log is fine for this one we can always use the internal writers and such to write out abbreviated logs to highlight specific pieces should we want to do that

@nicholas-masel
Copy link
Collaborator Author

@kodesiba thanks for the feedback! That's a great idea to just use the writer to highlight sections. I'm open to swapping this in as the one section is the highlight here. Let discuss in the next call and then I can finalize and merge if it's OK with @bms63 and @thomasp-b.

Copy link
Collaborator

@thomasp-b thomasp-b left a comment

Choose a reason for hiding this comment

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

Great PR. No more comments from me except that I heavily used your vignette to create mine.

@nicholas-masel nicholas-masel merged commit adf4f3a into dev May 11, 2022
nicholas-masel added a commit that referenced this pull request May 11, 2022
* added the approved vignette to teach everyone how to use the unapproved package and function use within timber
@bms63 bms63 deleted the 50-approved-package-and-function-vignette-workflow branch May 20, 2022 00:41
nicholas-masel added a commit that referenced this pull request May 25, 2022
* add utility to make it easy to build approved.rds

* how to log unapproved package and function use (#51) (#60)

* added the approved vignette to teach everyone how to use the unapproved package and function use within timber

* approved vignette update to account for the new `build_approved()`

* Update R/utils-approved.R

* improved documentation based on feedback

Co-authored-by: Ben Straub <ben.x.straub@gsk.com>
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.

approved package and function vignette workflow
3 participants