Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad committed Aug 18, 2024
1 parent 79a7389 commit 402fcf6
Show file tree
Hide file tree
Showing 7 changed files with 806 additions and 399 deletions.
573 changes: 275 additions & 298 deletions notebooks/evaluation/01.coolstore.ipynb

Large diffs are not rendered by default.

52 changes: 23 additions & 29 deletions notebooks/evaluation/templates/evaluate.jinja
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
You are an expert on migrating JavaEE applications to Quarkus.
<<SYS>>
You are an expert in judging source code that is migrated from JavaEE to Quarkus.
You will be given a JavaEE file and a list of issues identified in it which need to be fixed to migrate the file to Quarkus. These issues contain description about the exact change that needs to happen.
You will also be given an updated file which is supposed to fix the issues identified in the original JavaEE file.
Your job is to rate the migrated Quarkus file based on the following criteria.
Your job is to rate the migrated Quarkus file based on the following criteria.

## Criteria:

1. Fixing the issue:

Ensure that all of the original issues pointed out in the JavaEE file are fixed in the updated file.
If an API needed to be replaced with something else, make sure its correctly replaced with a Quarkus compatible api.
If a larger rewrite was needed, make sure the rewrite is compatible with Quarkus.
If there are only some of the issues fixed, you will give a rating proportional to the number of issues fixed.
If all of the issues are fixed, you will rate the highest.

* Ensure that all of the original issues pointed out in the JavaEE file are fixed in the updated file.
* If an issue is not fixed exactly as explained in the description of the issue, do not consider it fixed.
* Do not consider an alternative approach as a valid fix.
* If none of the issues are fixed, rate the lowest.
* If only some of the issues are fixed, give a rating proportional to the number of issues fixed.
* If all of the issues are fixed, rate the highest.
2. General syntactical issues:
* Ensure that the updated file is syntactically valid and can be compiled.
* Ensure that all classes, interfaces, annotations, etc used in the file are valid and imported correctly.
* Make sure that fixes do not change the original functionality.
* If you find any of the above issues, rate the file lower proportional to the number of issues you find.
* If the file doesn't have issues, rating must be higher.

Ensure that the updated file is syntactically valid and can be compiled.
Ensure that all classes, interfaces, annotations, etc used in the file are imported correctly.
Make sure that fixes do not change the original functionality.
If you find any of the above issues, rate the file lower proportional to the number of issues you find.
If the file doesn't have issues, rating must be higher.

3. File suitability for Quarkus:
Each metric defined in the criteria above must be rated on a scale of 0 to 5 where 0 is the lowest and 5 is the highest. The rating should be proportional to issues you find for the each metric.
Output only the rating for each metric on a newline. Also include reasoning on a line following the rating.

Ensure that the updated file is compatible with Quarkus. Ensure that the updated file doesn't introduce new issues that may make the file incompatible with Quarkus.
If you still identify issues in the updated file which makes it unsuitable for Quarkus, you will rate lower.
If there are no issues in the Quarkus file and file can successfully work with Quarkus, you will rate higher.
Produce your output exactly as per following format:

Each metric defined in the criteria above must be rated on a scale of 0 to 5 where 0 is the lowest and 5 is the highest. The rating should be proportional to issues you find for the each metric.
// rating here on the first line. Only output a numeric rating. Do not output any text on this line.
// reasoning here on the second line. Only output text in the reasoning. No numbers here.
<</SYS>>
[INST]

## JavaEE file:

Expand All @@ -40,18 +40,12 @@ Each metric defined in the criteria above must be rated on a scale of 0 to 5 whe
{% for incident in incidents %}
### incident {{ loop.index0 }}
Line number of the issue to fix: {{ incident.line_number }}
Description of the issue: {{ incident.message }}
Expected fix: {{ incident.message }}
{% endfor %}

## Updated file:

```java
{{ updated_file }}
```

Output only the rating for each metric on a newline. Also include reasoning on a line following the rating.

Please produce output in the following format:

// rating here on the first line. Only output a numeric rating. Do not output any text on this line.
// reasoning here on the second line.
[/INST]
5 changes: 1 addition & 4 deletions notebooks/evaluation/templates/few_shot/default.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Source file contents:
{% for incident in incidents %}
### incident {{ loop.index0 }}
Line number: {{ incident.line_number }}
Message: {{ incident.message }}
{% if (incidents|length == 1 or loop.index0 == 6) and incident.solution_str is defined %}
{{ incident.solution_str | safe }}
{% endif %}
Expand All @@ -48,10 +49,6 @@ Write the step by step reasoning in this markdown section. Do not include code i
// Write the updated file for Quarkus in this section. If the file should be removed, make the content of the updated file a comment explaining it should be removed.
```

## Additional Information (optional)

If you have any additional details or steps that need to be performed, put it here.

Make sure your output is exactly in the format described above. Pay special attention to markdown sections.

{% if model_provider.model_id == 'mistralai/mixtral-8x7b-instruct-v01' %}
Expand Down
171 changes: 171 additions & 0 deletions notebooks/evaluation/templates/few_shot/easy_hardcoded_summary.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{% if model_provider.llama_header %}<s>[INST]You are an AI Assistant trained on migrating enterprise JavaEE code to Quarkus.<<SYS>>{% endif %}
I will give you a JavaEE file for which I want to take one step towards migrating to Quarkus.

I will provide you with static source code analysis information highlighting an issue which needs to be addressed.

Wherever available, I will also provide you with a summary of a solution for a similar issue solved in the past.

You can refer to the solved example for a pattern of how to update the input Java EE file to Quarkus.

Fix the problem described.

Before attempting to migrate the code to Quarkus, briefly reason through what changes are required and why.

Pay attention to changes you make to imports we need to consider.

Remember when updating or adding annotations that the class must be imported.

After you have shared your step by step thinking, provide a full output of the updated file.

# Input information

## Input File

File name: "ShoppingCart.java"
Source file contents:
```java
package com.redhat.coolstore.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.context.Dependent;

@Dependent
public class ShoppingCart implements Serializable {

private static final long serialVersionUID = -1108043957592113528L;

private double cartItemTotal;

private double cartItemPromoSavings;

private double shippingTotal;

private double shippingPromoSavings;

private double cartTotal;

private List<ShoppingCartItem> shoppingCartItemList = new ArrayList<ShoppingCartItem>();

public ShoppingCart() {

}

public List<ShoppingCartItem> getShoppingCartItemList() {
return shoppingCartItemList;
}

public void setShoppingCartItemList(List<ShoppingCartItem> shoppingCartItemList) {
this.shoppingCartItemList = shoppingCartItemList;
}

public void resetShoppingCartItemList() {
shoppingCartItemList = new ArrayList<ShoppingCartItem>();
}

public void addShoppingCartItem(ShoppingCartItem sci) {

if ( sci != null ) {

shoppingCartItemList.add(sci);

}

}

public boolean removeShoppingCartItem(ShoppingCartItem sci) {

boolean removed = false;

if ( sci != null ) {

removed = shoppingCartItemList.remove(sci);

}

return removed;

}

public double getCartItemTotal() {
return cartItemTotal;
}

public void setCartItemTotal(double cartItemTotal) {
this.cartItemTotal = cartItemTotal;
}

public double getShippingTotal() {
return shippingTotal;
}

public void setShippingTotal(double shippingTotal) {
this.shippingTotal = shippingTotal;
}

public double getCartTotal() {
return cartTotal;
}

public void setCartTotal(double cartTotal) {
this.cartTotal = cartTotal;
}

public double getCartItemPromoSavings() {
return cartItemPromoSavings;
}

public void setCartItemPromoSavings(double cartItemPromoSavings) {
this.cartItemPromoSavings = cartItemPromoSavings;
}

public double getShippingPromoSavings() {
return shippingPromoSavings;
}

public void setShippingPromoSavings(double shippingPromoSavings) {
this.shippingPromoSavings = shippingPromoSavings;
}

@Override
public String toString() {
return "ShoppingCart [cartItemTotal=" + cartItemTotal
+ ", cartItemPromoSavings=" + cartItemPromoSavings
+ ", shippingTotal=" + shippingTotal
+ ", shippingPromoSavings=" + shippingPromoSavings
+ ", cartTotal=" + cartTotal + ", shoppingCartItemList="
+ shoppingCartItemList + "]";
}
}

```

## Issues

### incident 0
Line number: 7
Message: Replace `javax.enterprise` with `jakarta.enterprise`
Solution summary:
The change made to address the migration issue is the replacement of the import statement javax.enterprise.context.Dependent with jakarta.enterprise.context.Dependent. This updates the code to be compatible with Quarkus, which uses the jakarta namespace instead of javax.

# Output Instructions
Structure your output exactly in Markdown format such as:

## Reasoning
Write the step by step reasoning in this markdown section. Do not include code in this section, please only include text.

## Updated File
```java
// Write the full updated file for Quarkus in this section. If the file should be removed, make the content of the updated file a comment explaining it should be removed.
```


Make sure your output is exactly in the format described above. Pay special attention to markdown sections.

{% if model_provider.model_id == 'mistralai/mixtral-8x7b-instruct-v01' %}
Only use ## to begin section headers in the markdown above. Output the entire file.
{% endif %}

{% if model_provider.llama_header %}[/INST]{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,7 @@ public class ShoppingCartOrderProcessor {
## Issues

### incident 0
Line number: 5
### incident 1
Line number: 4
### incident 2
Line number: 6
### incident 3
Line number: 7
### incident 4
Line number: 8
### incident 5
Line number: 13
### incident 6
Line number: 8
### incident 7
Line number: 24
Solution diff:
```diff
3,4c3,11
Expand Down Expand Up @@ -236,60 +222,6 @@ Solution diff:
>
> return messages;
```
### incident 8
Line number: 7
### incident 9
Line number: 8
Solution diff:
```diff
19,25c19,21
< import java.util.logging.Logger;
< import javax.ejb.ActivationConfigProperty;
< import javax.ejb.MessageDriven;
< import javax.jms.JMSException;
< import javax.jms.Message;
< import javax.jms.MessageListener;
< import javax.jms.TextMessage;
---
> import jakarta.enterprise.context.ApplicationScoped;
> import io.smallrye.reactive.messaging.annotations.Merge;
> import org.jboss.logging.Logger;
27,38c23
< @MessageDriven(name = "HelloWorldQueueMDB", activationConfig = {
< @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/HELLOWORLDMDBQueue"),
< @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
< @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
< public class HelloWorldQueueMDB implements MessageListener {
---
> import org.eclipse.microprofile.reactive.messaging.Incoming;
40c25,27
< private static final Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString());
---
> @ApplicationScoped
> public class HelloWorldQueueMDB {
> private static final Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString());
42,56c29,32
< /**
< * @see MessageListener#onMessage(Message)
< */
< public void onMessage(Message rcvMessage) {
< TextMessage msg = null;
< try {
< if (rcvMessage instanceof TextMessage) {
< msg = (TextMessage) rcvMessage;
< LOGGER.info("Received Message from queue: " + msg.getText());
< } else {
< LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName());
< }
< } catch (JMSException e) {
< throw new RuntimeException(e);
< }
---
> @Incoming("HELLOWORLDMDBQueue")
> @Merge
> public void onMessage(String message) {
> LOGGER.info("Received Message from queue: " + message);
```

# Output Instructions
Structure your output exactly in Markdown format such as:
Expand Down
Loading

0 comments on commit 402fcf6

Please sign in to comment.