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

Import nbrOfWorkers() from {future} into NAMESPACE #253

Merged
merged 1 commit into from
May 29, 2024

Conversation

jdblischak
Copy link
Collaborator

While evaluating #251 and #252, I discovered that the function nbrOfWorkers() is missing from the package NAMESPACE. Below is a minimal reprex to demonstrate the problem:

library("simtrial")
packageVersion("simtrial")
## [1] ‘0.4.1.4’
future::plan("multisession", workers = 2)
sim_fixed_n(n_sim = 10)
## Error in nbrOfWorkers() : could not find function "nbrOfWorkers"

This NAMESPACE problem was missed by R CMD check because I wrongly added "nbrOfWorkers" to utils::globalVariables() in #114, assuming it was a variable defined in this package.

"nbrOfWorkers",

After removing it from utils::globalVariables(), R CMD check properly identifies the problem:

N  checking R code for possible problems (6.5s)
   sim_fixed_n: no visible global function definition for 'nbrOfWorkers'
   sim_gs_n: no visible global function definition for 'nbrOfWorkers'
   Undefined global functions or variables:
     nbrOfWorkers

And after importing nbrOfWorkers() into the package namespace, the example above now works:

# after
library("simtrial")
packageVersion("simtrial")
## [1] ‘0.4.1.5’
future::plan("multisession", workers = 2)
sim_fixed_n(n_sim = 10)
# works

xref: #110, #249

@jdblischak jdblischak requested a review from cmansch May 29, 2024 18:12
@jdblischak jdblischak self-assigned this May 29, 2024
Copy link
Collaborator

@cmansch cmansch left a comment

Choose a reason for hiding this comment

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

Good catch.

@LittleBeannie LittleBeannie merged commit fedf01d into Merck:main May 29, 2024
7 checks passed
@jdblischak jdblischak deleted the nbrOfWorkers branch May 29, 2024 20:00
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.

4 participants