Skip to content

Commit b7ef764

Browse files
author
David Hasani
committed
run maven JAR
1 parent 0999e72 commit b7ef764

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
@@ -129,8 +129,6 @@ describe('Amazon Q Code Transformation', function () {
129129
waitIntervalInMs: 1000,
130130
})
131131

132-
// TO-DO: add this back when releasing CSB
133-
/*
134132
const customDependencyVersionPrompt = tab.getChatItems().pop()
135133
assert.strictEqual(
136134
customDependencyVersionPrompt?.body?.includes('You can optionally upload a YAML file'),
@@ -143,15 +141,14 @@ describe('Amazon Q Code Transformation', function () {
143141
waitTimeoutInMs: 5000,
144142
waitIntervalInMs: 1000,
145143
})
146-
*/
147144

148145
const sourceJdkPathPrompt = tab.getChatItems().pop()
149146
assert.strictEqual(sourceJdkPathPrompt?.body?.includes('Enter the path to JDK 8'), true)
150147

151148
tab.addChatMessage({ prompt: '/dummy/path/to/jdk8' })
152149

153150
// 2 additional chat messages get sent after JDK path submitted; wait for both of them
154-
await tab.waitForEvent(() => tab.getChatItems().length > 10, {
151+
await tab.waitForEvent(() => tab.getChatItems().length > 15, {
155152
waitTimeoutInMs: 5000,
156153
waitIntervalInMs: 1000,
157154
})
@@ -173,7 +170,7 @@ describe('Amazon Q Code Transformation', function () {
173170
text: 'View summary',
174171
})
175172

176-
await tab.waitForEvent(() => tab.getChatItems().length > 11, {
173+
await tab.waitForEvent(() => tab.getChatItems().length > 18, {
177174
waitTimeoutInMs: 5000,
178175
waitIntervalInMs: 1000,
179176
})
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
@@ -437,9 +426,7 @@ export class GumbyController {
437426
userChoice: skipTestsSelection,
438427
})
439428
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
440-
this.promptJavaHome('source', message.tabID)
441-
// TO-DO: delete line above and uncomment line below when releasing CSB
442-
// await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
429+
await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
443430
})
444431
}
445432

@@ -465,16 +452,9 @@ export class GumbyController {
465452
const fromJDKVersion: JDKVersion = message.formSelectedValues['GumbyTransformJdkFromForm']
466453

467454
telemetry.record({
468-
// TODO: remove JavaSource/TargetVersionsAllowed when BI is updated to use source/target
469-
codeTransformJavaSourceVersionsAllowed: JDKToTelemetryValue(
470-
fromJDKVersion
471-
) as CodeTransformJavaSourceVersionsAllowed,
472-
codeTransformJavaTargetVersionsAllowed: JDKToTelemetryValue(
473-
toJDKVersion
474-
) as CodeTransformJavaTargetVersionsAllowed,
475455
source: fromJDKVersion,
476456
target: toJDKVersion,
477-
codeTransformProjectId: pathToProject === undefined ? telemetryUndefined : getStringHash(pathToProject),
457+
codeTransformProjectId: pathToProject === undefined ? undefined : getStringHash(pathToProject),
478458
userChoice: 'Confirm-Java',
479459
})
480460

@@ -503,7 +483,7 @@ export class GumbyController {
503483
const schema: string = message.formSelectedValues['GumbyTransformSQLSchemaForm']
504484

505485
telemetry.record({
506-
codeTransformProjectId: pathToProject === undefined ? telemetryUndefined : getStringHash(pathToProject),
486+
codeTransformProjectId: pathToProject === undefined ? undefined : getStringHash(pathToProject),
507487
source: transformByQState.getSourceDB(),
508488
target: transformByQState.getTargetDB(),
509489
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
@@ -410,7 +410,7 @@ export class Messenger {
410410
message = CodeWhispererConstants.noPomXmlFoundChatMessage
411411
break
412412
case 'could-not-compile-project':
413-
message = CodeWhispererConstants.cleanInstallErrorChatMessage
413+
message = CodeWhispererConstants.cleanTestCompileErrorChatMessage
414414
break
415415
case 'invalid-java-home':
416416
message = CodeWhispererConstants.noJavaHomeFoundChatMessage
@@ -731,7 +731,7 @@ ${codeSnippet}
731731
tabID
732732
)
733733
)
734-
const sampleYAML = `name: "custom-dependency-management"
734+
const sampleYAML = `name: dependency-upgrade
735735
description: "Custom dependency version management for Java migration from JDK 8/11/17 to JDK 17/21"
736736
737737
dependencyManagement:
@@ -744,7 +744,7 @@ dependencyManagement:
744744
targetVersion: "3.0.0"
745745
originType: "THIRD_PARTY"
746746
plugins:
747-
- identifier: "com.example.plugin"
747+
- identifier: "com.example:plugin"
748748
targetVersion: "1.2.0"
749749
versionProperty: "plugin.version" # Optional`
750750

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
@@ -262,7 +262,7 @@ export class DefaultCodeWhispererClient {
262262
/**
263263
* @description Use this function to get the status of the code transformation. We should
264264
* be polling this function periodically to get updated results. When this function
265-
* returns COMPLETED we know the transformation is done.
265+
* returns PARTIALLY_COMPLETED or COMPLETED we know the transformation is done.
266266
*/
267267
public async codeModernizerGetCodeTransformation(
268268
request: CodeWhispererUserClient.GetTransformationRequest
@@ -272,15 +272,15 @@ export class DefaultCodeWhispererClient {
272272
}
273273

274274
/**
275-
* @description After the job has been PAUSED we need to get user intervention. Once that user
276-
* intervention has been handled we can resume the transformation job.
275+
* @description During client-side build, or after the job has been PAUSED we need to get user intervention.
276+
* Once that user action has been handled we can resume the transformation job.
277277
* @params transformationJobId - String id returned from StartCodeTransformationResponse
278278
* @params userActionStatus - String to determine what action the user took, if any.
279279
*/
280280
public async codeModernizerResumeTransformation(
281281
request: CodeWhispererUserClient.ResumeTransformationRequest
282282
): Promise<PromiseResult<CodeWhispererUserClient.ResumeTransformationResponse, AWSError>> {
283-
return (await this.createUserSdkClient()).resumeTransformation(request).promise()
283+
return (await this.createUserSdkClient(8)).resumeTransformation(request).promise()
284284
}
285285

286286
/**

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,
@@ -43,7 +43,6 @@ import {
4343
validateOpenProjects,
4444
} from '../service/transformByQ/transformProjectValidationHandler'
4545
import {
46-
getVersionData,
4746
prepareProjectDependencies,
4847
runMavenDependencyUpdateCommands,
4948
} from '../service/transformByQ/transformMavenHandler'
@@ -82,7 +81,7 @@ import { AuthUtil } from '../util/authUtil'
8281

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

@@ -112,8 +111,8 @@ export async function compileProject() {
112111
try {
113112
const dependenciesFolder: FolderInfo = getDependenciesFolderInfo()
114113
transformByQState.setDependencyFolderInfo(dependenciesFolder)
115-
const modulePath = transformByQState.getProjectPath()
116-
await prepareProjectDependencies(dependenciesFolder, modulePath)
114+
const projectPath = transformByQState.getProjectPath()
115+
await prepareProjectDependencies(dependenciesFolder.path, projectPath)
117116
} catch (err) {
118117
// open build-logs.txt file to show user error logs
119118
await writeAndShowBuildLogs(true)
@@ -175,18 +174,15 @@ export async function humanInTheLoopRetryLogic(jobId: string, profile: RegionPro
175174
if (status === 'PAUSED') {
176175
const hilStatusFailure = await initiateHumanInTheLoopPrompt(jobId)
177176
if (hilStatusFailure) {
178-
// We rejected the changes and resumed the job and should
179-
// try to resume normal polling asynchronously
177+
// resume polling
180178
void humanInTheLoopRetryLogic(jobId, profile)
181179
}
182180
} else {
183181
await finalizeTransformByQ(status)
184182
}
185183
} catch (error) {
186184
status = 'FAILED'
187-
// TODO if we encounter error in HIL, do we stop job?
188185
await finalizeTransformByQ(status)
189-
// bubble up error to callee function
190186
throw error
191187
}
192188
}
@@ -225,11 +221,9 @@ export async function preTransformationUploadCode() {
225221

226222
const payloadFilePath = zipCodeResult.tempFilePath
227223
const zipSize = zipCodeResult.fileSize
228-
const dependenciesCopied = zipCodeResult.dependenciesCopied
229224

230225
telemetry.record({
231226
codeTransformTotalByteSize: zipSize,
232-
codeTransformDependenciesCopied: dependenciesCopied,
233227
})
234228

235229
transformByQState.setPayloadFilePath(payloadFilePath)
@@ -408,7 +402,7 @@ export async function finishHumanInTheLoop(selectedDependency?: string) {
408402

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

507-
await sleep(2000) // sleep before polling job to prevent ThrottlingException
499+
await sleep(5000) // sleep before polling job status to prevent ThrottlingException
508500
throwIfCancelled()
509501

510502
return jobId
@@ -523,9 +515,7 @@ export async function pollTransformationStatusUntilPlanReady(jobId: string, prof
523515
transformByQState.setJobFailureErrorChatMessage(CodeWhispererConstants.failedToCompleteJobChatMessage)
524516
}
525517

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

692-
if (transformByQState.getTransformationType() !== TransformationType.SQL_CONVERSION) {
693-
// the below is only applicable when user is doing a Java 8/11 language upgrade
694-
const versionInfo = await getVersionData()
695-
const mavenVersionInfoMessage = `${versionInfo[0]} (${transformByQState.getMavenName()})`
696-
const javaVersionInfoMessage = `${versionInfo[1]} (${transformByQState.getMavenName()})`
697-
698-
telemetry.codeTransform_totalRunTime.emit({
699-
buildSystemVersion: mavenVersionInfoMessage,
700-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
701-
codeTransformJobId: transformByQState.getJobId(),
702-
codeTransformResultStatusMessage: resultStatusMessage,
703-
codeTransformRunTimeLatency: durationInMs,
704-
codeTransformLocalJavaVersion: javaVersionInfoMessage,
705-
result: resultStatusMessage === TransformByQStatus.Succeeded ? MetadataResult.Pass : MetadataResult.Fail,
706-
reason: `${resultStatusMessage}-${chatMessage}`,
707-
})
708-
}
682+
telemetry.codeTransform_totalRunTime.emit({
683+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
684+
codeTransformJobId: transformByQState.getJobId(),
685+
codeTransformResultStatusMessage: resultStatusMessage,
686+
codeTransformRunTimeLatency: durationInMs,
687+
result:
688+
transformByQState.isSucceeded() || transformByQState.isPartiallySucceeded()
689+
? MetadataResult.Pass
690+
: MetadataResult.Fail,
691+
})
709692

710693
if (transformByQState.isSucceeded()) {
711694
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification, {
@@ -728,9 +711,14 @@ export async function postTransformationJob() {
728711
})
729712
}
730713

731-
if (transformByQState.getPayloadFilePath() !== '') {
714+
if (transformByQState.getPayloadFilePath()) {
732715
// delete original upload ZIP at very end of transformation
733-
fs.rmSync(transformByQState.getPayloadFilePath(), { recursive: true, force: true })
716+
fs.rmSync(transformByQState.getPayloadFilePath(), { force: true })
717+
}
718+
// delete temporary build logs file
719+
const logFilePath = path.join(os.tmpdir(), 'build-logs.txt')
720+
if (fs.existsSync(logFilePath)) {
721+
fs.rmSync(logFilePath, { force: true })
734722
}
735723

736724
// attempt download for user
@@ -748,12 +736,9 @@ export async function transformationJobErrorHandler(error: any) {
748736
// jobFailureErrorNotification should always be defined here
749737
let displayedErrorMessage =
750738
transformByQState.getJobFailureErrorNotification() ?? CodeWhispererConstants.failedToCompleteJobNotification
751-
if (transformByQState.getJobFailureMetadata() !== '') {
752-
displayedErrorMessage += ` ${transformByQState.getJobFailureMetadata()}`
753-
transformByQState.setJobFailureErrorChatMessage(
754-
`${transformByQState.getJobFailureErrorChatMessage()} ${transformByQState.getJobFailureMetadata()}`
755-
)
756-
}
739+
transformByQState.setJobFailureErrorChatMessage(
740+
transformByQState.getJobFailureErrorChatMessage() ?? CodeWhispererConstants.failedToCompleteJobChatMessage
741+
)
757742
void vscode.window
758743
.showErrorMessage(displayedErrorMessage, CodeWhispererConstants.amazonQFeedbackText)
759744
.then((choice) => {

0 commit comments

Comments
 (0)