Skip to content

Commit

Permalink
update instructions (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmayer authored Dec 14, 2024
1 parent 2d811c5 commit 8a90ee1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/openhands-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
max_iterations:
required: false
type: number
default: 50
default: 100
macro:
required: false
type: string
Expand Down Expand Up @@ -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:
Expand Down
72 changes: 54 additions & 18 deletions .openhands_instructions
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 <planning> tags for your plan
- After you make a plan, score it with <plan-score> 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 <planning> and <plan-score> until you have a good plan
- Finally, use a <reflection> tag to review your plan
- Once you've got a <reflection> tag, you are ready to start working on the request.

## Development Workflow

Expand All @@ -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/
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 8a90ee1

Please sign in to comment.