-
Notifications
You must be signed in to change notification settings - Fork 272
feat(amazonq): Adding UTG build and execute logic back for internal Amazon customers. #5396
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
Changes from all commits
24a0832
4168e78
b5de261
9cf1786
ca2c128
9151dce
b5792bc
5231789
9e323fe
3601d49
fc8d07b
d195b1a
b5f6ce1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "feature", | ||
"description" : "Add back build and execute for Internal Amazon Customers." | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ import software.aws.toolkits.jetbrains.services.amazonqCodeTest.model.PreviousUT | |
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.model.ShortAnswer | ||
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.BuildAndExecuteProgressStatus | ||
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.session.Session | ||
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.utils.combineBuildAndExecuteLogFiles | ||
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.calculateTotalLatency | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.CodeTestException | ||
import software.aws.toolkits.jetbrains.services.codewhisperer.codetest.fileTooLarge | ||
|
@@ -63,6 +62,7 @@ import java.nio.file.Path | |
import java.nio.file.Paths | ||
import java.time.Duration | ||
import java.time.Instant | ||
import java.util.UUID | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
import java.util.zip.ZipInputStream | ||
|
||
|
@@ -89,12 +89,24 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
val session = codeTestChatHelper.getActiveSession() | ||
session.isGeneratingTests = true | ||
session.iteration++ | ||
if (session.testGenerationJobGroupName.isNullOrEmpty()) { | ||
session.testGenerationJobGroupName = UUID.randomUUID().toString() | ||
} | ||
val final = session.testGenerationJobGroupName | ||
Randall-Jiang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (session.iteration == 1) { | ||
Randall-Jiang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
codeTestChatHelper.updateUI( | ||
promptInputDisabledState = true, | ||
promptInputProgress = testGenProgressField(0), | ||
) | ||
} else { | ||
codeTestChatHelper.updateUI( | ||
promptInputDisabledState = true, | ||
promptInputProgress = buildAndExecuteProgrogressField, | ||
) | ||
} | ||
|
||
// Set the Progress bar to "Generating unit tests..." | ||
codeTestChatHelper.updateUI( | ||
promptInputDisabledState = true, | ||
promptInputProgress = testGenProgressField(0), | ||
) | ||
|
||
val codeTestResponseContext = createUploadUrl(codeTestChatHelper, previousIterationContext) | ||
session.srcPayloadSize = codeTestResponseContext.payloadContext.srcPayloadSize | ||
|
@@ -137,7 +149,8 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
) | ||
.build() | ||
), | ||
userInput = prompt | ||
userInput = prompt, | ||
testGenerationJobGroupName = final | ||
) | ||
delay(200) | ||
response?.testGenerationJob() != null | ||
|
@@ -198,6 +211,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
// Setting default value to 0 if the value is null or invalid | ||
session.numberOfUnitTestCasesGenerated = shortAnswer.numberOfTestMethods | ||
session.testFileRelativePathToProjectRoot = getTestFilePathRelativeToRoot(shortAnswer) | ||
session.shortAnswer = shortAnswer | ||
|
||
// update test summary card in success case | ||
if (previousIterationContext == null) { | ||
|
@@ -261,7 +275,11 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
} | ||
codeTestChatHelper.updateUI( | ||
promptInputDisabledState = true, | ||
promptInputProgress = testGenProgressField(progressRate), | ||
promptInputProgress = if (session.iteration == 1) { | ||
testGenProgressField(0) | ||
} else { | ||
buildAndExecuteProgrogressField | ||
} | ||
) | ||
} | ||
|
||
|
@@ -469,10 +487,8 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
previousIterationContext.selectedFile | ||
} | ||
|
||
val combinedBuildAndExecuteLogFile = combineBuildAndExecuteLogFiles( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove |
||
previousIterationContext?.buildLogFile, | ||
previousIterationContext?.testLogFile | ||
) | ||
val combinedBuildAndExecuteLogFile = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. variable declaration is not needed here, if required can we change variable name to buildLogFile etc.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I keeped this in case we need excute in the future, will do it in the next pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved |
||
previousIterationContext?.buildLogFile | ||
val codeTestSessionConfig = CodeTestSessionConfig(file, project, combinedBuildAndExecuteLogFile) | ||
codeTestChatHelper.getActiveSession().projectRoot = codeTestSessionConfig.projectRoot.path | ||
|
||
|
@@ -481,8 +497,13 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
return codeWhispererCodeTestSession.run(codeTestChatHelper, previousIterationContext) | ||
} | ||
|
||
private fun startTestGeneration(uploadId: String, targetCode: List<TargetCode>, userInput: String): StartTestGenerationResponse = | ||
CodeWhispererClientAdaptor.getInstance(project).startTestGeneration(uploadId, targetCode, userInput) | ||
private fun startTestGeneration( | ||
uploadId: String, | ||
targetCode: List<TargetCode>, | ||
userInput: String, | ||
testGenerationJobGroupName: String, | ||
): StartTestGenerationResponse = | ||
CodeWhispererClientAdaptor.getInstance(project).startTestGeneration(uploadId, targetCode, userInput, testGenerationJobGroupName) | ||
|
||
private fun getTestGenerationStatus(jobId: String, jobGroupName: String): GetTestGenerationResponse = | ||
CodeWhispererClientAdaptor.getInstance(project).getTestGeneration(jobId, jobGroupName) | ||
|
@@ -566,25 +587,44 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin | |
canBeVoted = false | ||
) | ||
) | ||
if (session.iteration == 1) { | ||
AmazonqTelemetry.utgGenerateTests( | ||
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId, | ||
hasUserPromptSupplied = session.hasUserPromptSupplied, | ||
isFileInWorkspace = true, | ||
isSupportedLanguage = true, | ||
credentialStartUrl = getStartUrl(project), | ||
jobGroup = session.testGenerationJobGroupName, | ||
jobId = session.testGenerationJob, | ||
result = if (e.message == message("testgen.message.cancelled")) MetricResult.Cancelled else MetricResult.Failed, | ||
Check warningCode scanning / QDJVMC Usage of redundant or deprecated syntax or deprecated symbols
'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
|
||
reason = (e as CodeTestException).code ?: "DefaultError", | ||
reasonDesc = if (e.message == message("testgen.message.cancelled")) "${e.code}: ${e.message}" else e.message, | ||
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration), | ||
isCodeBlockSelected = session.isCodeBlockSelected, | ||
artifactsUploadDuration = session.artifactUploadDuration, | ||
buildPayloadBytes = session.srcPayloadSize, | ||
buildZipFileBytes = session.srcZipFileSize, | ||
requestId = session.startTestGenerationRequestId | ||
) | ||
} else { | ||
AmazonqTelemetry.unitTestGeneration( | ||
|
||
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId, | ||
hasUserPromptSupplied = session.hasUserPromptSupplied, | ||
isSupportedLanguage = true, | ||
credentialStartUrl = getStartUrl(project), | ||
jobGroup = session.testGenerationJobGroupName, | ||
jobId = session.testGenerationJob, | ||
result = if (e.message == message("testgen.message.cancelled")) MetricResult.Cancelled else MetricResult.Failed, | ||
reason = (e as CodeTestException).code ?: "DefaultError", | ||
reasonDesc = if (e.message == message("testgen.message.cancelled")) "${e.code}: ${e.message}" else e.message, | ||
Check warningCode scanning / QDJVMC Usage of redundant or deprecated syntax or deprecated symbols
'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
|
||
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration), | ||
isCodeBlockSelected = session.isCodeBlockSelected, | ||
artifactsUploadDuration = session.artifactUploadDuration, | ||
buildZipFileBytes = session.srcZipFileSize, | ||
requestId = session.startTestGenerationRequestId | ||
) | ||
} | ||
|
||
AmazonqTelemetry.utgGenerateTests( | ||
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId, | ||
hasUserPromptSupplied = session.hasUserPromptSupplied, | ||
isFileInWorkspace = true, | ||
isSupportedLanguage = true, | ||
credentialStartUrl = getStartUrl(project), | ||
jobGroup = session.testGenerationJobGroupName, | ||
jobId = session.testGenerationJob, | ||
result = if (e.message == message("testgen.message.cancelled")) MetricResult.Cancelled else MetricResult.Failed, | ||
reason = (e as CodeTestException).code ?: "DefaultError", | ||
reasonDesc = if (e.message == message("testgen.message.cancelled")) "${e.code}: ${e.message}" else e.message, | ||
perfClientLatency = (Instant.now().toEpochMilli() - session.startTimeOfTestGeneration), | ||
isCodeBlockSelected = session.isCodeBlockSelected, | ||
artifactsUploadDuration = session.artifactUploadDuration, | ||
buildPayloadBytes = session.srcPayloadSize, | ||
buildZipFileBytes = session.srcZipFileSize, | ||
requestId = session.startTestGenerationRequestId | ||
) | ||
session.isGeneratingTests = false | ||
} finally { | ||
// Reset the flow if there is any error | ||
|
Uh oh!
There was an error while loading. Please reload this page.