From 8a90ee1d895022960a59dfba86bf360ec8e9a9cb Mon Sep 17 00:00:00 2001 From: Zach Deane-Mayer <581590+zachmayer@users.noreply.github.com> Date: Sat, 14 Dec 2024 09:27:20 -0500 Subject: [PATCH] update instructions (#370) --- .github/workflows/openhands-resolver.yml | 3 +- .openhands_instructions | 72 ++++++++++++++++++------ 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/.github/workflows/openhands-resolver.yml b/.github/workflows/openhands-resolver.yml index 2ce242a..d8522b8 100644 --- a/.github/workflows/openhands-resolver.yml +++ b/.github/workflows/openhands-resolver.yml @@ -8,7 +8,7 @@ on: max_iterations: required: false type: number - default: 50 + default: 100 macro: required: false type: string @@ -195,6 +195,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::roxygen2 + - run: make install - name: Install OpenHands env: diff --git a/.openhands_instructions b/.openhands_instructions index 5c162fa..b816b8f 100644 --- a/.openhands_instructions +++ b/.openhands_instructions @@ -1,5 +1,7 @@ # R Code Style Guide and Development Instructions +## Overall guidance + Your dev environment is *fully setup*. You do not need to install any packages. They are all installed for you. Write the *minimal* code neccicary to solve the problem: @@ -8,23 +10,20 @@ Write the *minimal* code neccicary to solve the problem: - Branching logic is bad - Convoluted error handling or edge case handling is bad - Use the fewest lines of code possible to solve the problem - -## Code Style - -- Use base R and core packages rather than tidyverse -- Prefer data.table over data.frame for data manipulation -- Use :: operator for package functions (e.g., data.table::data.table). - - Do not use `library` or `require`. Import packages with :: -- Avoid for loops - use vectorized operations -- Use vapply instead of sapply -- Keep functions small and focused -- Write self-documenting code, minimize comments -- Follow strict R code style guidelines -- Write clean, lint-free, readable code -- Do not use error handling -- Do not use tryCatch / on.exit / try / withCallingHandlers / etc. -- Do not write excessive if/then/else statements -- Don't install or use new packages. You should already have everything you need. +- Use the make commands in the Development to make sure your code works + - If these commands do not pass, you are not done with your work +- Once lint/tests etc pass and you feel your work is complete, update [NEWS.md](NEWS.md) with a short description of your changes for the release log. +- Before you do any work, make a plan! + - Your plan should be detailed, feel free to use a lot of tokens + - Use tags for your plan + - After you make a plan, score it with tags + - 0-100 on the likelihood that it fuffils the request + - 0-100 on complexity + - If the plan does not score above 80 on fulfills request, make a new plan + - If the plan does not score above 50 on complexity, make a new plan + - Repeat and until you have a good plan + - Finally, use a tag to review your plan + - Once you've got a tag, you are ready to start working on the request. ## Development Workflow @@ -46,6 +45,38 @@ You shouldn't need to run the other make commands. If you update the README.rmd Do not run `make install`, `make update-test-fixtures`, `make release`, `make check-rev-dep`, `make check-win`, `make check-rhub`, `make check-many-preds`, `make check`, `make preview-site`, `make dev-guide`. If needed a human will run these commands. +## Code Style + +- Use base R and core packages rather than tidyverse +- Prefer data.table over data.frame for data manipulation +- Use :: operator for package functions (e.g., data.table::data.table). + - Do not use `library` or `require`. Import packages with :: +- Avoid for loops - use vectorized operations +- Use vapply instead of sapply +- Keep functions small and focused +- Write self-documenting code, minimize comments +- Follow strict R code style guidelines +- Write clean, lint-free, readable code +- Do not use error handling +- Do not use tryCatch / on.exit / try / withCallingHandlers / etc. +- Do not write excessive if/then/else statements +- Don't install or use new packages. You should already have everything you need. +- Write clean, modular code +- Use Roxygen2 to document your code +- Write at least one unit test for your work +- Don't add new packages. If you need to install an R package, something is wrong. +- Prefer S3 classes over S4 and R5 classes when creating new classes +- Avoid tidyverse packages unless absolutely necessary +- ggplot2 and reshape2 are acceptable exceptions +- Always use ggplot2 for plotting +- Always use data.table::data.table for data manipulation +- Avoid base data.frame and plyr completely +- Prefer glmnet or xgboost for modeling tasks +- Avoid for loops and sapply loops where possible +- Look for built-in vectorized functions before writing loops +- Consider vectorized operations from approved packages only if built-in functions aren't available +- make sure all files end in newlines + ## Package Structure - Put R code in R/ @@ -62,7 +93,6 @@ Do not run `make install`, `make update-test-fixtures`, `make release`, `make ch - Be sure to test error conditions, especially cases that should throw errors - Use testthat framework - ## Getting Help These file contain information that will help you understand the code structure and workflow: @@ -71,3 +101,9 @@ These file contain information that will help you understand the code structure - [Makefile](Makefile) - The Makefile. Contains many useful commands, but heed the instructions in this file: you won't need to use most of those make commands. - [.openhands_instructions](.openhands_instructions) - This file. Contains instructions for you as a developer. - [project-tree.txt](project-tree.txt) - A nice clean package directory, ignoring files you dont need to edit. Use this file to navigate the package and understand which files you need to edit. Feel free to re-make this file with `make project-tree.txt` if you've made file or directory changes to see what's changed. +- Feel free to use `git` commands to see what's changed recently. Don't forget you are non-interactive so you need to run non-interactive commands like `git status` or `git diff` with `-c` or `--no-pager` flags. E.g.: + - `git log --no-merges --pretty=format:"%H|%an|%ad|%s" --date=iso -n 10` to see recent commits + - `git rev-parse HEAD` to see the current commit hash + - `git diff-tree --no-commit-id --name-only -r HEAD` to see the files that have changed in the last commit + - `git log -1 --pretty=%B` to see the commit message of the last commit + - `git diff --name-only HEAD~1 HEAD` List files changed between two commits