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

different-issue-to-markdown aiders attempty #367

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
aider-instructions.md
issue.md
combined-instructions.md
coverage.rds
coverage-report.html
cobertura.xml
Expand Down
27 changes: 15 additions & 12 deletions .github/workflows/aider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@ jobs:
- name: Install Package
run: make install

- name: Get Issue Content
id: get-issue
uses: actions-cool/issues-helper@v3
- name: Convert Issue to Markdown
uses: eunjae-lee/issue-to-markdown@v1
with:
actions: 'get-issue'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.inputs.issue_number }}
dest: 'tmp'
extension: '.md'
slug_as_folder_name: false
label: ''
inject_title: true
inject_created_at: false
inject_updated_at: false
authors: zachmayer

- name: Prepare Instructions
run: |
cat aider-instructions.md "tmp/${{ github.event.inputs.issue_number }}/index.md" > combined_instructions.md
rm -rf tmp/

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -64,11 +74,6 @@ jobs:
- name: Install Aider
run: pip install -U aider-chat

- name: Prepare Instructions
run: |
printf '%s' "${{ steps.get-issue.outputs.issue-body }}" > issue.md
cat aider-instructions.md issue.md > combined_instructions.md

- name: Run Aider
run: |
aider \
Expand All @@ -91,5 +96,3 @@ jobs:
title: "fix: Automated fixes for issue #${{ github.event.inputs.issue_number }}"
body: |
This PR contains automated fixes for issue #${{ github.event.inputs.issue_number }} using aider.

Original issue: ${{ steps.get-issue.outputs.issue-title }}
8 changes: 6 additions & 2 deletions R/caretList.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ caretList <- function(
tuneList = NULL,
metric = NULL,
continue_on_fail = FALSE,
trim = TRUE) {
trim = TRUE,
sort_preds = TRUE) {
# Checks
if (is.null(tuneList) && is.null(methodList)) {
stop("Please either define a methodList or tuneList", call. = FALSE)
Expand Down Expand Up @@ -79,7 +80,10 @@ caretList <- function(
global_args[["metric"]] <- metric

# Loop through the tuneLists and fit caret models with those specs
modelList <- lapply(tuneList, caretTrain, global_args = global_args, continue_on_fail = continue_on_fail, trim = trim)
modelList <- lapply(tuneList, caretTrain,
global_args = global_args,
continue_on_fail = continue_on_fail, trim = trim, sort_preds = sort_preds
)
names(modelList) <- names(tuneList)
nulls <- vapply(modelList, is.null, logical(1L))
modelList <- modelList[!nulls]
Expand Down
13 changes: 8 additions & 5 deletions R/caretPredict.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ caretPredict <- function(object, newdata = NULL, excluded_class_id = 1L, ...) {
#' If `TRUE`, the function will remove some elements that are not needed from the output model.
#' @return The output of the `train` function.
#' @keywords internal
caretTrain <- function(local_args, global_args, continue_on_fail = FALSE, trim = TRUE) {
caretTrain <- function(local_args, global_args, continue_on_fail = FALSE, trim = TRUE, sort_preds = TRUE) {
# Combine args
# I think my handling here is correct (update globals with locals, which allows locals be partial)
# but it would be nice to have some tests
Expand All @@ -100,7 +100,7 @@ caretTrain <- function(local_args, global_args, continue_on_fail = FALSE, trim =

# Only save stacked predictions for the best model
if ("pred" %in% names(model)) {
model[["pred"]] <- extractBestPreds(model)
model[["pred"]] <- extractBestPreds(model, sort_preds = sort_preds)
}

if (trim) {
Expand Down Expand Up @@ -147,9 +147,10 @@ aggregate_mean_or_first <- function(x) {
#' @title Extract the best predictions from a train object
#' @description Extract the best predictions from a train object.
#' @param x a train object
#' @param sort_preds logical, should predictions be sorted by rowIndex. Default TRUE.
#' @return a data.table::data.table with predictions
#' @keywords internal
extractBestPreds <- function(x) {
extractBestPreds <- function(x, sort_preds = TRUE) {
stopifnot(methods::is(x, "train"))
if (is.null(x$pred)) {
stop("No predictions saved during training. Please set savePredictions = 'final' in trainControl", call. = FALSE)
Expand All @@ -173,8 +174,10 @@ extractBestPreds <- function(x) {
data.table::setkeyv(pred, keys)
pred <- pred[, lapply(.SD, aggregate_mean_or_first), by = keys]

# Order results consistently
data.table::setorderv(pred, keys)
# Order results consistently if requested
if (sort_preds) {
data.table::setorderv(pred, keys)
}

# Return
pred
Expand Down
Loading