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

Diff-Merge not very reliable - Sweep enhancements #435

Closed
jbellic opened this issue Jan 7, 2024 · 16 comments
Closed

Diff-Merge not very reliable - Sweep enhancements #435

jbellic opened this issue Jan 7, 2024 · 16 comments
Labels
bug Something isn't working fixed

Comments

@jbellic
Copy link

jbellic commented Jan 7, 2024

Hi,

had the opportunity to tryout some experiments on a Java Repository.
On a 800+ lines class unfortunately Aider failed to perform a clean merge, which triggered multiple attempts until failure.
Trying out Sweep yielded better performance for the same test case and the Diff-Output was kinda valid (although I didn't like the overall performance, missed crucial imports for proposed change).

Question: Do you plan to enhance aider's merging capabilities with the weaknesses mentioned here?
https://docs.sweep.dev/blogs/gpt-4-modification

Thanks for your efforts.

@paul-gauthier
Copy link
Collaborator

Thanks for trying aider and filing this issue.

What aider version, model, and edit-format settings were you using?

I would love any concrete examples you have of editing failures. To be most useful, I need as much of the following as you are able to provide.

  • A copy of all the "announcement" lines when you run aider which reports all key settings.
  • A copy of the diffs which failed to apply. You can find these in .aider.chat.history.md.
  • A copy of the source file that was being updated, or at least the chunk that is mentioned in the failing diffs.

@paul-gauthier paul-gauthier added the question Further information is requested label Jan 8, 2024
@jbellic
Copy link
Author

jbellic commented Jan 8, 2024

Using latest version (updated a couple of minutes ago).

Code to change:

` @SneakyThrows
private EbProductFetchResult fetchEbProductsByWebDiverAndJsoup(Integer currentSellCount) {

    Set<String> ebProductUrls = fetchEbProductUrls();
    ebProductUrls.addAll(fetchEbProductUrls2());
    log.info("fetched eb product urls after first method run: {}", ebProductUrls.size());

    while (ebProductUrls.size() < currentSellCount) {
        ebProductUrls.addAll(fetchEbProductUrls());
        if (ebProductUrls.size() < currentSellCount) {
            ebProductUrls.addAll(fetchEbProductUrls2());
        }
        currentSellCount = fetchCurrentSellCount();
        log.info("re-fetched eb product urls count: {}", ebProductUrls.size());
    }
    Set<EbProduct> ebProducts = ConcurrentHashMap.newKeySet();

    Set<String> missingTitleOrShortDescriptionUrls = new HashSet<>();
    Set<String> missingEans = new HashSet<>();

    // todo: set back to 8 after having proxies
    ForkJoinPool forkJoinPool = new ForkJoinPool(1);
    forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
            .forEach(listingUrl ->
            {
                try {
                    Document listingDocument = null;
                    while (listingDocument == null) {
                        try {
                            listingDocument = connectJsoup(listingUrl);
                        } catch (Exception ignored) {
                        }
                    }

                    Element descriptionIframe = listingDocument.getElementById("desc_ifr");` 
					
					
				....
				....
				....
	forkJoinPool.shutdown();
    forkJoinPool.awaitTermination(TIMEOUT_MINUTES, TimeUnit.MINUTES);

Aider logs:

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java

replace ForkJoinPool usage with ExecutorService. Don't forget about imports.

--- src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
+++ src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool forkJoinPool = new ForkJoinPool(1);
    
  •    forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(1);
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
               .forEach(listingUrl ->
               {
                   try {
    

@@ ... @@

  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

Malformed response #1, retrying...
UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

--- src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
+++ src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool forkJoinPool = new ForkJoinPool(1);
    
  •    forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(1);
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
               .forEach(listingUrl ->
               {
                   try {
    

@@ ... @@

  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

Please note that the diff provided is based on the assumption that the original file contains the usage of ForkJoinPool which is being replaced with ExecutorService. If the original file does not containForkJoinPool, please provide the correct context or the specific part of the code that needs to be changed.

Committing src\main\java\com\example\rdw\service\sync\eb\service\EbService.java before applying edits.
Commit 54dbfc4 Refactored parallel processing to use ExecutorService instead of ForkJoinPool.
Malformed response #2, retrying...
UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 5 exact lines in a row:

        ForkJoinPool forkJoinPool = new ForkJoinPool(1);
        forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
                .forEach(listingUrl ->
                {
                    try {

--- src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
+++ src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool forkJoinPool = new ForkJoinPool(1);
    
  •    forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(1);
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
               .forEach(listingUrl ->
               {
                   try {
    

@@ ... @@

  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

Please ensure that the provided code snippet is the correct context from the file EbService.java. If the file does not contain the lines mentioned in the diff, the patch will not apply. If
the context is incorrect, please provide the correct lines where ForkJoinPool is used, and I will create a new diff.

Committing src\main\java\com\example\rdw\service\sync\eb\service\EbService.java before applying edits.
Commit fdc23bc Shutdown executor service gracefully in EbService.
Malformed response #3, aborting.
UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 5 exact lines in a row:

        ForkJoinPool forkJoinPool = new ForkJoinPool(1);
        forkJoinPool.submit(() -> ebProductUrls.stream().parallel()
                .forEach(listingUrl ->
                {
                    try {

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
src\main\java\com\example\rdw\service\sync\eb\service\EbService.java

@paul-gauthier
Copy link
Collaborator

Thanks for the detail. Am I correct that you were using the gpt-4-1106-preview model?

Does your file src\main\java\com\example\rdw\service\sync\eb\service\EbService.java start with some import lines? Are you able to share the first few lines of the file with me?

I ask because it is having trouble applying this diff, which looks to me like it would be trying to modify the imports at the top if your file.

 @@ ... @@
 -import java.util.concurrent.ForkJoinPool;
 +import java.util.concurrent.ExecutorService;
 +import java.util.concurrent.Executors;

@jbellic
Copy link
Author

jbellic commented Jan 8, 2024

Yes, using gpt-4-1106-preview.

Imports:

`
package com.example.rdw.service.sync.eb.service;

import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.html.parser.HTMLParserListener;
import com.gargoylesoftware.htmlunit.javascript.SilentJavaScriptErrorListener;
import com.example.rdw.service.common.shopify.domain.ShopifyProductRepresentation;
import com.example.rdw.service.common.shopify.domain.ShopifyProductRequest;
import com.example.rdw.service.common.shopify.domain.ShopifyProductResponse;
import com.example.rdw.service.common.shopify.service.ShopifyService;
import com.example.rdw.service.sync.eb.domain.EbProduct;
import com.example.rdw.service.sync.eb.domain.EbProductFetchResult;
import com.example.rdw.service.sync.notification.service.NotificationService;
import com.example.rdw.service.sync.proxy.service.ProxyService;
import com.example.rdw.service.sync.template.service.TemplateService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.jsoup.select.Evaluator;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.core.annotation.Order;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.;
import java.time.ZonedDateTime;
import java.util.
;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@SuppressWarnings({"SpellCheckingInspection", "ResultOfMethodCallIgnored"})
@log4j2
@service
@order()
@requiredargsconstructor
public class EbProductSyncService {

private static final Integer TIMEOUT_MINUTES = 15;

private final WebDriverService webDriverService;

`

@jbellic
Copy link
Author

jbellic commented Jan 8, 2024

Do you in general plan to implement the enhancements sweep has done because of the identified weaknesses?

@paul-gauthier
Copy link
Collaborator

Thanks for the detailed debugging info. It helped uncover a small bug, which has been fixed. The change is available in the main branch. You can get it by installing the latest version from github:

python -m pip install --upgrade git+https://github.com/paul-gauthier/aider.git

If you have a chance to try it, let me know if it works better for you.

@paul-gauthier paul-gauthier added bug Something isn't working fixed and removed question Further information is requested labels Jan 9, 2024
@jbellic
Copy link
Author

jbellic commented Jan 9, 2024

Unfortunately no luck (same model + prompt)
λ aider --4-turbo
Aider v0.21.1-dev
Model: gpt-4-1106-preview using udiff edit format
Git repo: .git with 1 files
Repo-map: using 1024 tokens

src\main\java\com\example\raederwerk\service\sync\eb\service\EbService.java

replace ForkJoinPool usage with ExecutorService. Don't forget about imports.

--- src\main\java\com\example\raederwerk\service\sync\eb\service\EbService.java
+++ src\main\java\com\example\raederwerk\service\sync\eb\service\EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    
  •    customThreadPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
    

@@ ... @@

  •    customThreadPool.shutdown();
    
  •    try {
    
  •        if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            customThreadPool.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        customThreadPool.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    
  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

This diff replaces the usage of ForkJoinPool with ExecutorService and updates the relevant code to use the ExecutorService methods for submitting tasks and shutting down the executor. The import
statement for ForkJoinPool is also removed and replaced with the appropriate imports for ExecutorService and Executors.

Committing src\main\java\com\example\rdw\service\sync\eb\service\EbService.java before applying edits.
Commit 57805ab Shutdown executor service gracefully in EbService.
Malformed response #1, retrying...
UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

        ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
        customThreadPool.submit(() -> ebProductUrls.stream().parallel()

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 9 exact lines in a row:

        customThreadPool.shutdown();
        try {
            if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
                customThreadPool.shutdownNow();
            }
        } catch (InterruptedException ex) {
            customThreadPool.shutdownNow();
            Thread.currentThread().interrupt();
        }

--- src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
+++ src\main\java\com\example\rdw\service\sync\eb\service\EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    
  •    customThreadPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
    

@@ ... @@

  •    customThreadPool.shutdown();
    
  •    try {
    
  •        if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            customThreadPool.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        customThreadPool.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    
  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

This diff replaces the usage of ForkJoinPool with ExecutorService and updates the relevant code to use the ExecutorService methods for submitting tasks and shutting down the executor. The import
statement for ForkJoinPool is also removed and replaced with the appropriate imports for ExecutorService and Executors.

Malformed response #2, retrying...
UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 2 exact lines in a row:

        ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
        customThreadPool.submit(() -> ebProductUrls.stream().parallel()

UnifiedDiffNoMatch: hunk failed to apply!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src\main\java\com\example\rdw\service\sync\eb\service\EbService.java!

src\main\java\com\example\rdw\service\sync\eb\service\EbService.java does not contain these 9 exact lines in a row:

        customThreadPool.shutdown();
        try {
            if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
                customThreadPool.shutdownNow();
            }
        } catch (InterruptedException ex) {
            customThreadPool.shutdownNow();
            Thread.currentThread().interrupt();
        }

I apologize for the confusion. Let's try again with the correct diff. I will now provide a diff that should apply cleanly to the current contents of the file EbService.java.

--- src/main/java/com/example/rdw/service/sync/eb/service/EbService.java
+++ src/main/java/com/example/rdw/service/sync/eb/service/EbService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;

@@ ... @@

  •    ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
    
  •    customThreadPool.submit(() -> ebProductUrls.stream().parallel()
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
    
  •    executorService.submit(() -> ebProductUrls.stream().parallel()
    

@@ ... @@

  •    customThreadPool.shutdown();
    
  •    try {
    
  •        if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            customThreadPool.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        customThreadPool.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    
  •    executorService.shutdown();
    
  •    try {
    
  •        if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
    
  •            executorService.shutdownNow();
    
  •        }
    
  •    } catch (InterruptedException ex) {
    
  •        executorService.shutdownNow();
    
  •        Thread.currentThread().interrupt();
    
  •    }
    

This diff replaces the usage of ForkJoinPool with ExecutorService and updates the relevant code to use the ExecutorService methods for submitting tasks and shutting down the executor. The import
statement for ForkJoinPool is also removed and replaced with the appropriate imports for ExecutorService and Executors.

Malformed response #3, aborting.
UnifiedDiffNoMatch: hunk failed to apply!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src/main/java/com/example/rdw/service/sync/eb/service/EbService.java!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain these 2 exact lines in a row:

import java.util.concurrent.ForkJoinPool;

UnifiedDiffNoMatch: hunk failed to apply!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src/main/java/com/example/rdw/service/sync/eb/service/EbService.java!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain these 2 exact lines in a row:

        ForkJoinPool customThreadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
        customThreadPool.submit(() -> ebProductUrls.stream().parallel()

UnifiedDiffNoMatch: hunk failed to apply!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in src/main/java/com/example/rdw/service/sync/eb/service/EbService.java!

src/main/java/com/example/rdw/service/sync/eb/service/EbService.java does not contain these 9 exact lines in a row:

        customThreadPool.shutdown();
        try {
            if (!customThreadPool.awaitTermination(60, TimeUnit.SECONDS)) {
                customThreadPool.shutdownNow();
            }
        } catch (InterruptedException ex) {
            customThreadPool.shutdownNow();
            Thread.currentThread().interrupt();
        }

@paul-gauthier
Copy link
Collaborator

Thanks for trying the new version. It looks like your code had some of the changes from previous attempts already present in the file. You can see where aider is committing those dirty changes before applying the diffs from GPT when it outputs these lines in the logs you provided:

Committing src\main\java\com\example\rdw\service\sync\eb\service\EbService.java before applying edits.
Commit 57805ab Shutdown executor service gracefully in EbService.

So the code in your file had already been mostly modified to "replace ForkJoinPool usage with ExecutorService." When you asked GPT to do that again, with the extra request to "Don't forget about imports" that confused GPT. The import changes were already in the file.

Maybe revert the file to the state before any of the ExecutorService changes and try again?

Is this a real coding problem you are trying to work on? Or just some kind of a test?

@jbellic
Copy link
Author

jbellic commented Jan 9, 2024

Good catch, after reverting it worked. It's a real coding scenario, even a very simple one.
I will do some more testing and will send final feedback.

Thank you very much.

@jbellic
Copy link
Author

jbellic commented Jan 21, 2024

Seems like it's still having issue with the same method when the method is inside a source code file with many lines ~1000loc
Extracting method manually and re-running works. Maybe it makes sense to implement an isolation mechanism to temporarily write only affected methods/functions and then running.

Other issue is following:

Added MyService.java to the chat.


com/test/abc/service/sync/eb/service/MyService.java
+++
com/test/abc/service/sync/eb/service/MyService.java
@@ ... @@
-import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
@@ ... @@

  •    ForkJoinPool forkJoinPool = new ForkJoinPool(1);                     
    
  •    forkJoinPool.submit(() -> ebayProductUrls.stream().parallel()        
    
  •    ExecutorService executorService = Executors.newFixedThreadPool(1);   
    
  •    List<Callable<Void>> tasks = productUrls.stream().map(listingUrl 
    

-> (Callable) () -> {
try {
Document listingDocument = null;
while (listingDocument == null) {
try {
@@ ... @@
}
}
}

  •            return null;                                                 
           } catch (Exception e) {                                          
               log.error(e.getMessage(), e);                                
               notificationService.notifySyncError("error in fetching
    

products by webDriver: " + e.getMessage());
}

  •    }).collect(Collectors.toList());                                     
    
  •    executorService.invokeAll(tasks);                                    
    
  •    executorService.shutdown();                                          
    
  •    executorService.awaitTermination(TIMEOUT_MINUTES, TimeUnit.MINUTES); 
    
  •    })).get();                                                           
    
  •    forkJoinPool.shutdown();                                             
    
  •    forkJoinPool.awaitTermination(TIMEOUT_MINUTES, TimeUnit.MINUTES);    
    

This diff replaces the usage of ForkJoinPool with ExecutorService and adjusts
the code to submit tasks to the executor service, wait for their completion,
and handle their termination. The import statements are also updated to include
ExecutorService and Executors and remove ForkJoinPool.
Allow creation of new file
com/test/abc/service/sync/eb/service/MyService.java?
no
Skipping edits to
com/test/abc/service/sync/eb/service/MyService.java

Process finished with exit code 0

Seems like it's mixing up with the added File path and automatically refusing to edit (using scripted version)

@paul-gauthier
Copy link
Collaborator

What does "using scripted version" mean?

@jbellic
Copy link
Author

jbellic commented Jan 23, 2024

Not using it via CLI but directly instantiated within a python script.

@paul-gauthier
Copy link
Collaborator

It's going to be pretty tricky for me to help debug scripted invocations of aider. It's likely that you're using it in a way that is fairly different from the intended chat use case.

@paul-gauthier
Copy link
Collaborator

I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.

@linhcentrio
Copy link

Malformed response #3, aborting.
UnifiedDiffNoMatch: hunk failed to apply!

app-huggingface.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in app-huggingface.py!

app-huggingface.py does not contain these 14 exact lines in a row:

    def load_model_list(self):
        pipeline_dict = dict()
        for style, cfg in self.style_configs.items():
            dreambooth_path = cfg.get('dreambooth', 'none')
            if dreambooth_path and dreambooth_path.upper() != 'NONE':
                dreambooth_path = osp.join(DreamBooth_LoRA_PATH, dreambooth_path)
            lora_path = cfg.get('lora', None)
            if lora_path is not None:
                lora_path = osp.join(DreamBooth_LoRA_PATH, lora_path)
            lora_alpha = cfg.get('lora_alpha', 0.0)
            vae_path = cfg.get('vae', None)
            if vae_path is not None:
                vae_path = osp.join(VAE_PATH, vae_path)
            ...

@paul-gauthier
Copy link
Collaborator

@linhcentrio there's a FAQ entry that might contain helpful information:

https://aider.chat/docs/faq.html#aider-isnt-editing-my-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants