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

Expression Length Error in touchstone::benchmark_run #153

Open
DorisAmoakohene opened this issue Nov 25, 2024 · 0 comments
Open

Expression Length Error in touchstone::benchmark_run #153

DorisAmoakohene opened this issue Nov 25, 2024 · 0 comments

Comments

@DorisAmoakohene
Copy link

I'm encountering an error while trying to benchmark using the touchstone::benchmark_run function. The error states:

Expression to benchmark cannot have length greater than one.

> touchstone::use_touchstone()
✔ Populated file script.R in touchstone/.
✔ Populated file header.R in touchstone/.
✔ Populated file footer.R in touchstone/.
✔ Populated file config.json in touchstone/.
✔ Populated file .gitignore in touchstone/.
✔ Populated file touchstone-receive.yaml in .github/workflows/.
✔ Populated file touchstone-comment.yaml in .github/workflows/.
✔ Added touchstone to .Rbuildignore.
• Replace the mtcars sample code in `touchstone/script.R` with code from your package
you want to benchmark.
ℹ You can modify the PR comment, see `?touchstone::pr_comment`.
• Commit and push to GitHub to the default branch to activate the workflow, then make
a pull request to trigger your first benchmark run.
> touchstone::benchmark_run(
+ random_test = data.table::setDT(replicate(1000, 1, simplify = FALSE)),
+ n = 1,
+ branch = "master"  # Specify your correct branch here
+ )
ℹ touchstone not activated. Most likely, you want to run `touchstone::activate()` and the below error should go away.
Error in `branch_get_or_fail()`:
! If you don't specify the argument `branch(s)`, you must set the environment
  variable `GITHUB_BASE_REF` to tell touchstone which branches you want to benchmark
  against each other.
ℹ See `?touchstone::run_script`.
Run `rlang::last_trace()` to see where the error occurred.
> touchstone::activate()
✔ Environment ready to interactively execute your touchstone script.
ℹ Use `touchstone::deactivate()` to restore original environment.
> touchstone::benchmark_run(
+ expr_before_benchmark = {
+ library(data.table)
+ set.seed(42)
+ },
+ test_with_seed = data.table::setDT(replicate(1000, 1, simplify = FALSE)),
+ n = 2
+ )
ℹ `activate()` has overriden n = 2 with 1 since `rlang::is_interactive ()` is `TRUE`.
ℹ Running 2 iterations of benchmark: test_with_seed.
✔ Temporarily checked out branch "master".
✔ Ran 1 iteration of branch "master".
✔ Switched back to branch "master".
Error in `purrr::pmap()`:
ℹ In index: 2.
Caused by error in `local_git_checkout()`:
! Branch "main" does not exist, create it and add commits before you can
  switch on it.
Run `rlang::last_trace()` to see where the error occurred.
✔ Switched back to branch "master".

I followed the steps to set up the workflow, but the error persists.

Expected Behavior:
The benchmark should execute without error, producing results for the specified workflow.

Set the working directory:

setwd("C:/Users/amoak/OneDrive - Northern Arizona University/MSINF2024Year2fALL/Thesis_SEM1/data.table")

touchstone::use_touchstone()
touchstone::benchmark_run(
  random_test = data.table::setDT(replicate(1000, 1, simplify = FALSE)),
  n = 1,
  branch = "master" 
)

Activate:

touchstone::activate()
touchstone::benchmark_run(
  expr_before_benchmark = {
    library(data.table)
    set.seed(42)
  },
  test_with_seed = data.table::setDT(replicate(1000, 1, simplify = FALSE)),
  n = 2
)
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

No branches or pull requests

1 participant