Skip to content

Commit fd3eeee

Browse files
author
David Hasani
committed
run maven JAR
1 parent 0651afd commit fd3eeee

File tree

16 files changed

+131
-300
lines changed

16 files changed

+131
-300
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "/transform: run all builds client-side"
4+
}

packages/amazonq/test/e2e/amazonq/transformByQ.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ describe('Amazon Q Code Transformation', function () {
150150
waitIntervalInMs: 1000,
151151
})
152152

153-
// TO-DO: add this back when releasing CSB
154-
/*
155153
const customDependencyVersionPrompt = tab.getChatItems().pop()
156154
assert.strictEqual(
157155
customDependencyVersionPrompt?.body?.includes('You can optionally upload a YAML file'),
@@ -164,15 +162,14 @@ describe('Amazon Q Code Transformation', function () {
164162
waitTimeoutInMs: 5000,
165163
waitIntervalInMs: 1000,
166164
})
167-
*/
168165

169166
const sourceJdkPathPrompt = tab.getChatItems().pop()
170167
assert.strictEqual(sourceJdkPathPrompt?.body?.includes('Enter the path to JDK 8'), true)
171168

172169
tab.addChatMessage({ prompt: '/dummy/path/to/jdk8' })
173170

174171
// 2 additional chat messages get sent after JDK path submitted; wait for both of them
175-
await tab.waitForEvent(() => tab.getChatItems().length > 13, {
172+
await tab.waitForEvent(() => tab.getChatItems().length > 15, {
176173
waitTimeoutInMs: 5000,
177174
waitIntervalInMs: 1000,
178175
})
@@ -194,7 +191,7 @@ describe('Amazon Q Code Transformation', function () {
194191
text: 'View summary',
195192
})
196193

197-
await tab.waitForEvent(() => tab.getChatItems().length > 14, {
194+
await tab.waitForEvent(() => tab.getChatItems().length > 16, {
198195
waitTimeoutInMs: 5000,
199196
waitIntervalInMs: 1000,
200197
})
145 KB
Binary file not shown.

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ import {
4141
} from '../../errors'
4242
import * as CodeWhispererConstants from '../../../codewhisperer/models/constants'
4343
import MessengerUtils, { ButtonActions, GumbyCommands } from './messenger/messengerUtils'
44-
import { CancelActionPositions, JDKToTelemetryValue, telemetryUndefined } from '../../telemetry/codeTransformTelemetry'
44+
import { CancelActionPositions } from '../../telemetry/codeTransformTelemetry'
4545
import { openUrl } from '../../../shared/utilities/vsCodeUtils'
46-
import {
47-
telemetry,
48-
CodeTransformJavaTargetVersionsAllowed,
49-
CodeTransformJavaSourceVersionsAllowed,
50-
} from '../../../shared/telemetry/telemetry'
46+
import { telemetry } from '../../../shared/telemetry/telemetry'
5147
import { CodeTransformTelemetryState } from '../../telemetry/codeTransformTelemetryState'
5248
import DependencyVersions from '../../models/dependencies'
5349
import { getStringHash } from '../../../shared/utilities/textUtilities'
@@ -308,7 +304,6 @@ export class GumbyController {
308304
}
309305

310306
private async validateLanguageUpgradeProjects(message: any) {
311-
let telemetryJavaVersion = JDKToTelemetryValue(JDKVersion.UNSUPPORTED) as CodeTransformJavaSourceVersionsAllowed
312307
try {
313308
const validProjects = await telemetry.codeTransform_validateProject.run(async () => {
314309
telemetry.record({
@@ -317,12 +312,6 @@ export class GumbyController {
317312
})
318313

319314
const validProjects = await getValidLanguageUpgradeCandidateProjects()
320-
if (validProjects.length > 0) {
321-
// validProjects[0].JDKVersion will be undefined if javap errors out or no .class files found, so call it UNSUPPORTED
322-
const javaVersion = validProjects[0].JDKVersion ?? JDKVersion.UNSUPPORTED
323-
telemetryJavaVersion = JDKToTelemetryValue(javaVersion) as CodeTransformJavaSourceVersionsAllowed
324-
}
325-
telemetry.record({ codeTransformLocalJavaVersion: telemetryJavaVersion })
326315
return validProjects
327316
})
328317
return validProjects
@@ -460,9 +449,7 @@ export class GumbyController {
460449
})
461450

462451
this.messenger.sendOneOrMultipleDiffsMessage(oneOrMultipleDiffsSelection, message.tabID)
463-
this.promptJavaHome('source', message.tabID)
464-
// TO-DO: delete line above and uncomment line below when releasing CSB
465-
// await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
452+
await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
466453
})
467454
}
468455

@@ -488,16 +475,9 @@ export class GumbyController {
488475
const fromJDKVersion: JDKVersion = message.formSelectedValues['GumbyTransformJdkFromForm']
489476

490477
telemetry.record({
491-
// TODO: remove JavaSource/TargetVersionsAllowed when BI is updated to use source/target
492-
codeTransformJavaSourceVersionsAllowed: JDKToTelemetryValue(
493-
fromJDKVersion
494-
) as CodeTransformJavaSourceVersionsAllowed,
495-
codeTransformJavaTargetVersionsAllowed: JDKToTelemetryValue(
496-
toJDKVersion
497-
) as CodeTransformJavaTargetVersionsAllowed,
498478
source: fromJDKVersion,
499479
target: toJDKVersion,
500-
codeTransformProjectId: pathToProject === undefined ? telemetryUndefined : getStringHash(pathToProject),
480+
codeTransformProjectId: pathToProject === undefined ? undefined : getStringHash(pathToProject),
501481
userChoice: 'Confirm-Java',
502482
})
503483

@@ -526,7 +506,7 @@ export class GumbyController {
526506
const schema: string = message.formSelectedValues['GumbyTransformSQLSchemaForm']
527507

528508
telemetry.record({
529-
codeTransformProjectId: pathToProject === undefined ? telemetryUndefined : getStringHash(pathToProject),
509+
codeTransformProjectId: pathToProject === undefined ? undefined : getStringHash(pathToProject),
530510
source: transformByQState.getSourceDB(),
531511
target: transformByQState.getTargetDB(),
532512
userChoice: 'Confirm-SQL',

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class Messenger {
451451
message = CodeWhispererConstants.noPomXmlFoundChatMessage
452452
break
453453
case 'could-not-compile-project':
454-
message = CodeWhispererConstants.cleanInstallErrorChatMessage
454+
message = CodeWhispererConstants.cleanTestCompileErrorChatMessage
455455
break
456456
case 'invalid-java-home':
457457
message = CodeWhispererConstants.noJavaHomeFoundChatMessage
@@ -779,7 +779,7 @@ ${codeSnippet}
779779
tabID
780780
)
781781
)
782-
const sampleYAML = `name: "custom-dependency-management"
782+
const sampleYAML = `name: dependency-upgrade
783783
description: "Custom dependency version management for Java migration from JDK 8/11/17 to JDK 17/21"
784784
785785
dependencyManagement:
@@ -792,7 +792,7 @@ dependencyManagement:
792792
targetVersion: "3.0.0"
793793
originType: "THIRD_PARTY"
794794
plugins:
795-
- identifier: "com.example.plugin"
795+
- identifier: "com.example:plugin"
796796
targetVersion: "1.2.0"
797797
versionProperty: "plugin.version" # Optional`
798798

packages/core/src/amazonqGumby/errors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ export class NoMavenJavaProjectsFoundError extends ToolkitError {
3030
}
3131
}
3232

33-
export class ZipExceedsSizeLimitError extends ToolkitError {
34-
constructor() {
35-
super('Zip file exceeds size limit', { code: 'ZipFileExceedsSizeLimit' })
36-
}
37-
}
38-
3933
export class AlternateDependencyVersionsNotFoundError extends Error {
4034
constructor() {
4135
super('No available versions for dependency update')

packages/core/src/codewhisperer/client/codewhisperer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class DefaultCodeWhispererClient {
286286
/**
287287
* @description Use this function to get the status of the code transformation. We should
288288
* be polling this function periodically to get updated results. When this function
289-
* returns COMPLETED we know the transformation is done.
289+
* returns PARTIALLY_COMPLETED or COMPLETED we know the transformation is done.
290290
*/
291291
public async codeModernizerGetCodeTransformation(
292292
request: CodeWhispererUserClient.GetTransformationRequest
@@ -296,15 +296,15 @@ export class DefaultCodeWhispererClient {
296296
}
297297

298298
/**
299-
* @description After the job has been PAUSED we need to get user intervention. Once that user
300-
* intervention has been handled we can resume the transformation job.
299+
* @description During client-side build, or after the job has been PAUSED we need to get user intervention.
300+
* Once that user action has been handled we can resume the transformation job.
301301
* @params transformationJobId - String id returned from StartCodeTransformationResponse
302302
* @params userActionStatus - String to determine what action the user took, if any.
303303
*/
304304
public async codeModernizerResumeTransformation(
305305
request: CodeWhispererUserClient.ResumeTransformationRequest
306306
): Promise<PromiseResult<CodeWhispererUserClient.ResumeTransformationResponse, AWSError>> {
307-
return (await this.createUserSdkClient()).resumeTransformation(request).promise()
307+
return (await this.createUserSdkClient(8)).resumeTransformation(request).promise()
308308
}
309309

310310
/**

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as vscode from 'vscode'
77
import * as fs from 'fs' // eslint-disable-line no-restricted-imports
8+
import os from 'os'
89
import path from 'path'
910
import { getLogger } from '../../shared/logger/logger'
1011
import * as CodeWhispererConstants from '../models/constants'
@@ -16,7 +17,6 @@ import {
1617
jobPlanProgress,
1718
FolderInfo,
1819
ZipManifest,
19-
TransformByQStatus,
2020
TransformationType,
2121
TransformationCandidateProject,
2222
RegionProfile,
@@ -44,7 +44,6 @@ import {
4444
validateOpenProjects,
4545
} from '../service/transformByQ/transformProjectValidationHandler'
4646
import {
47-
getVersionData,
4847
prepareProjectDependencies,
4948
runMavenDependencyUpdateCommands,
5049
} from '../service/transformByQ/transformMavenHandler'
@@ -83,7 +82,7 @@ import { AuthUtil } from '../util/authUtil'
8382

8483
export function getFeedbackCommentData() {
8584
const jobId = transformByQState.getJobId()
86-
const s = `Q CodeTransform jobId: ${jobId ? jobId : 'none'}`
85+
const s = `Q CodeTransformation jobId: ${jobId ? jobId : 'none'}`
8786
return s
8887
}
8988

@@ -113,8 +112,8 @@ export async function compileProject() {
113112
try {
114113
const dependenciesFolder: FolderInfo = getDependenciesFolderInfo()
115114
transformByQState.setDependencyFolderInfo(dependenciesFolder)
116-
const modulePath = transformByQState.getProjectPath()
117-
await prepareProjectDependencies(dependenciesFolder, modulePath)
115+
const projectPath = transformByQState.getProjectPath()
116+
await prepareProjectDependencies(dependenciesFolder.path, projectPath)
118117
} catch (err) {
119118
// open build-logs.txt file to show user error logs
120119
await writeAndShowBuildLogs(true)
@@ -176,18 +175,15 @@ export async function humanInTheLoopRetryLogic(jobId: string, profile: RegionPro
176175
if (status === 'PAUSED') {
177176
const hilStatusFailure = await initiateHumanInTheLoopPrompt(jobId)
178177
if (hilStatusFailure) {
179-
// We rejected the changes and resumed the job and should
180-
// try to resume normal polling asynchronously
178+
// resume polling
181179
void humanInTheLoopRetryLogic(jobId, profile)
182180
}
183181
} else {
184182
await finalizeTransformByQ(status)
185183
}
186184
} catch (error) {
187185
status = 'FAILED'
188-
// TODO if we encounter error in HIL, do we stop job?
189186
await finalizeTransformByQ(status)
190-
// bubble up error to callee function
191187
throw error
192188
}
193189
}
@@ -226,11 +222,9 @@ export async function preTransformationUploadCode() {
226222

227223
const payloadFilePath = zipCodeResult.tempFilePath
228224
const zipSize = zipCodeResult.fileSize
229-
const dependenciesCopied = zipCodeResult.dependenciesCopied
230225

231226
telemetry.record({
232227
codeTransformTotalByteSize: zipSize,
233-
codeTransformDependenciesCopied: dependenciesCopied,
234228
})
235229

236230
transformByQState.setPayloadFilePath(payloadFilePath)
@@ -409,7 +403,7 @@ export async function finishHumanInTheLoop(selectedDependency?: string) {
409403

410404
// 7) We need to take that output of maven and use CreateUploadUrl
411405
const uploadFolderInfo = humanInTheLoopManager.getUploadFolderInfo()
412-
await prepareProjectDependencies(uploadFolderInfo, uploadFolderInfo.path)
406+
await prepareProjectDependencies(uploadFolderInfo.path, uploadFolderInfo.path)
413407
// zipCode side effects deletes the uploadFolderInfo right away
414408
const uploadResult = await zipCode({
415409
dependenciesFolder: uploadFolderInfo,
@@ -450,13 +444,11 @@ export async function finishHumanInTheLoop(selectedDependency?: string) {
450444
await terminateHILEarly(jobId)
451445
void humanInTheLoopRetryLogic(jobId, profile)
452446
} finally {
453-
// Always delete the dependency directories
454447
telemetry.codeTransform_humanInTheLoop.emit({
455448
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
456449
codeTransformJobId: jobId,
457450
codeTransformMetadata: CodeTransformTelemetryState.instance.getCodeTransformMetaDataString(),
458451
result: hilResult,
459-
// TODO: make a generic reason field for telemetry logging so we don't log sensitive PII data
460452
reason: hilResult === MetadataResult.Fail ? 'Runtime error occurred' : undefined,
461453
})
462454
await HumanInTheLoopManager.instance.cleanUpArtifacts()
@@ -505,7 +497,7 @@ export async function startTransformationJob(
505497
throw new JobStartError()
506498
}
507499

508-
await sleep(2000) // sleep before polling job to prevent ThrottlingException
500+
await sleep(5000) // sleep before polling job status to prevent ThrottlingException
509501
throwIfCancelled()
510502

511503
return jobId
@@ -524,9 +516,7 @@ export async function pollTransformationStatusUntilPlanReady(jobId: string, prof
524516
transformByQState.setJobFailureErrorChatMessage(CodeWhispererConstants.failedToCompleteJobChatMessage)
525517
}
526518

527-
// Since we don't yet have a good way of knowing what the error was,
528-
// we try to fetch any build failure artifacts that may exist so that we can optionally
529-
// show them to the user if they exist.
519+
// try to download pre-build error logs if available
530520
let pathToLog = ''
531521
try {
532522
const tempToolkitFolder = await makeTemporaryToolkitFolder()
@@ -713,23 +703,16 @@ export async function postTransformationJob() {
713703
const durationInMs = calculateTotalLatency(CodeTransformTelemetryState.instance.getStartTime())
714704
const resultStatusMessage = transformByQState.getStatus()
715705

716-
if (transformByQState.getTransformationType() !== TransformationType.SQL_CONVERSION) {
717-
// the below is only applicable when user is doing a Java 8/11 language upgrade
718-
const versionInfo = await getVersionData()
719-
const mavenVersionInfoMessage = `${versionInfo[0]} (${transformByQState.getMavenName()})`
720-
const javaVersionInfoMessage = `${versionInfo[1]} (${transformByQState.getMavenName()})`
721-
722-
telemetry.codeTransform_totalRunTime.emit({
723-
buildSystemVersion: mavenVersionInfoMessage,
724-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
725-
codeTransformJobId: transformByQState.getJobId(),
726-
codeTransformResultStatusMessage: resultStatusMessage,
727-
codeTransformRunTimeLatency: durationInMs,
728-
codeTransformLocalJavaVersion: javaVersionInfoMessage,
729-
result: resultStatusMessage === TransformByQStatus.Succeeded ? MetadataResult.Pass : MetadataResult.Fail,
730-
reason: `${resultStatusMessage}-${chatMessage}`,
731-
})
732-
}
706+
telemetry.codeTransform_totalRunTime.emit({
707+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
708+
codeTransformJobId: transformByQState.getJobId(),
709+
codeTransformResultStatusMessage: resultStatusMessage,
710+
codeTransformRunTimeLatency: durationInMs,
711+
result:
712+
transformByQState.isSucceeded() || transformByQState.isPartiallySucceeded()
713+
? MetadataResult.Pass
714+
: MetadataResult.Fail,
715+
})
733716

734717
if (transformByQState.isSucceeded()) {
735718
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
@@ -752,9 +735,14 @@ export async function postTransformationJob() {
752735
})
753736
}
754737

755-
if (transformByQState.getPayloadFilePath() !== '') {
738+
if (transformByQState.getPayloadFilePath()) {
756739
// delete original upload ZIP at very end of transformation
757-
fs.rmSync(transformByQState.getPayloadFilePath(), { recursive: true, force: true })
740+
fs.rmSync(transformByQState.getPayloadFilePath(), { force: true })
741+
}
742+
// delete temporary build logs file
743+
const logFilePath = path.join(os.tmpdir(), 'build-logs.txt')
744+
if (fs.existsSync(logFilePath)) {
745+
fs.rmSync(logFilePath, { force: true })
758746
}
759747

760748
// attempt download for user
@@ -772,12 +760,9 @@ export async function transformationJobErrorHandler(error: any) {
772760
// jobFailureErrorNotification should always be defined here
773761
let displayedErrorMessage =
774762
transformByQState.getJobFailureErrorNotification() ?? CodeWhispererConstants.failedToCompleteJobNotification
775-
if (transformByQState.getJobFailureMetadata() !== '') {
776-
displayedErrorMessage += ` ${transformByQState.getJobFailureMetadata()}`
777-
transformByQState.setJobFailureErrorChatMessage(
778-
`${transformByQState.getJobFailureErrorChatMessage()} ${transformByQState.getJobFailureMetadata()}`
779-
)
780-
}
763+
transformByQState.setJobFailureErrorChatMessage(
764+
transformByQState.getJobFailureErrorChatMessage() ?? CodeWhispererConstants.failedToCompleteJobChatMessage
765+
)
781766
void vscode.window
782767
.showErrorMessage(displayedErrorMessage, CodeWhispererConstants.amazonQFeedbackText)
783768
.then((choice) => {

0 commit comments

Comments
 (0)