Skip to content

Commit 3a39b10

Browse files
authored
feat(amazonq): add job ID to Transformation Hub aws#6154
## Problem Users find it difficult to locate the job ID in the "job history" tab of the Transformation Hub. ## Solution Put the job ID in the main tab of the Transformation Hub as soon as it's available. Also, delete some unused / unneeded functionality.
1 parent ffd94b4 commit 3a39b10

File tree

8 files changed

+56
-90
lines changed

8 files changed

+56
-90
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": "Amazon Q Code Transformation: show job ID in Transformation Hub"
4+
}

packages/core/src/amazonqGumby/activation.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { transformByQState } from '../codewhisperer/models/model'
1616
import { ProposedTransformationExplorer } from '../codewhisperer/service/transformByQ/transformationResultsViewProvider'
1717
import { CodeTransformTelemetryState } from './telemetry/codeTransformTelemetryState'
1818
import { telemetry } from '../shared/telemetry/telemetry'
19-
import { CancelActionPositions } from './telemetry/codeTransformTelemetry'
2019
import { setContext } from '../shared'
2120

2221
export async function activate(context: ExtContext) {
@@ -50,9 +49,9 @@ export async function activate(context: ExtContext) {
5049
context.extensionContext.subscriptions.push(
5150
vscode.window.registerWebviewViewProvider('aws.amazonq.transformationHub', transformationHubViewProvider),
5251

53-
Commands.register('aws.amazonq.stopTransformationInHub', async (cancelSrc: CancelActionPositions) => {
52+
Commands.register('aws.amazonq.stopTransformationInHub', async () => {
5453
if (transformByQState.isRunning()) {
55-
await stopTransformByQ(transformByQState.getJobId(), cancelSrc)
54+
await stopTransformByQ(transformByQState.getJobId())
5655
await postTransformationJob()
5756
await cleanupTransformationJob()
5857
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export class GumbyController {
384384
this.messenger.sendJobSubmittedMessage(message.tabID)
385385
break
386386
case ButtonActions.STOP_TRANSFORMATION_JOB:
387-
await stopTransformByQ(transformByQState.getJobId(), CancelActionPositions.Chat)
387+
await stopTransformByQ(transformByQState.getJobId())
388388
await postTransformationJob()
389389
await cleanupTransformationJob()
390390
break
@@ -466,10 +466,6 @@ export class GumbyController {
466466
message.tabID
467467
)
468468

469-
if (fromJDKVersion === JDKVersion.UNSUPPORTED) {
470-
this.messenger.sendUnrecoverableErrorResponse('unsupported-source-jdk-version', message.tabID)
471-
return
472-
}
473469
await processLanguageUpgradeTransformFormInput(pathToProject, fromJDKVersion, toJDKVersion)
474470
await this.messenger.sendSkipTestsPrompt(message.tabID)
475471
})

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export type UnrecoverableErrorType =
4545
| 'no-maven-java-project-found'
4646
| 'could-not-compile-project'
4747
| 'invalid-java-home'
48-
| 'unsupported-source-jdk-version'
4948
| 'upload-to-s3-failed'
5049
| 'job-start-failed'
5150
| 'unsupported-source-db'
@@ -234,10 +233,6 @@ export class Messenger {
234233
value: JDKVersion.JDK17,
235234
label: JDKVersion.JDK17,
236235
},
237-
{
238-
value: JDKVersion.UNSUPPORTED,
239-
label: 'Other',
240-
},
241236
],
242237
})
243238

@@ -473,9 +468,6 @@ export class Messenger {
473468
case 'invalid-java-home':
474469
message = CodeWhispererConstants.noJavaHomeFoundChatMessage
475470
break
476-
case 'unsupported-source-jdk-version':
477-
message = CodeWhispererConstants.unsupportedJavaVersionChatMessage
478-
break
479471
case 'unsupported-source-db':
480472
message = CodeWhispererConstants.invalidMetadataFileUnsupportedSourceDB
481473
break

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

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ import {
4949
prepareProjectDependencies,
5050
runMavenDependencyUpdateCommands,
5151
} from '../service/transformByQ/transformMavenHandler'
52-
import { CodeTransformCancelSrcComponents, telemetry } from '../../shared/telemetry/telemetry'
52+
import { telemetry } from '../../shared/telemetry/telemetry'
5353
import { CodeTransformTelemetryState } from '../../amazonqGumby/telemetry/codeTransformTelemetryState'
54-
import { CancelActionPositions, calculateTotalLatency } from '../../amazonqGumby/telemetry/codeTransformTelemetry'
54+
import { calculateTotalLatency } from '../../amazonqGumby/telemetry/codeTransformTelemetry'
5555
import { MetadataResult } from '../../shared/telemetry/telemetryClient'
5656
import { submitFeedback } from '../../feedback/vue/submitFeedback'
5757
import { placeholder } from '../../shared/vscode/commands2'
@@ -919,55 +919,51 @@ export async function cleanupTransformationJob() {
919919
CodeTransformTelemetryState.instance.resetCodeTransformMetaDataField()
920920
}
921921

922-
export async function stopTransformByQ(
923-
jobId: string,
924-
cancelSrc: CancelActionPositions = CancelActionPositions.BottomHubPanel
925-
) {
926-
if (transformByQState.isRunning()) {
927-
getLogger().info('CodeTransformation: User requested to stop transformation. Stopping transformation.')
928-
transformByQState.setToCancelled()
929-
transformByQState.setPolledJobStatus('CANCELLED')
930-
await setContext('gumby.isStopButtonAvailable', false)
931-
try {
932-
await stopJob(jobId)
933-
void vscode.window
934-
.showErrorMessage(
935-
CodeWhispererConstants.jobCancelledNotification,
936-
CodeWhispererConstants.amazonQFeedbackText
937-
)
938-
.then((choice) => {
939-
if (choice === CodeWhispererConstants.amazonQFeedbackText) {
940-
void submitFeedback(
941-
placeholder,
942-
CodeWhispererConstants.amazonQFeedbackKey,
943-
getFeedbackCommentData()
944-
)
945-
}
946-
})
947-
} catch (err) {
948-
void vscode.window
949-
.showErrorMessage(
950-
CodeWhispererConstants.errorStoppingJobNotification,
951-
CodeWhispererConstants.amazonQFeedbackText
952-
)
953-
.then((choice) => {
954-
if (choice === CodeWhispererConstants.amazonQFeedbackText) {
955-
void submitFeedback(
956-
placeholder,
957-
CodeWhispererConstants.amazonQFeedbackKey,
958-
getFeedbackCommentData()
959-
)
960-
}
961-
})
962-
getLogger().error(`CodeTransformation: Error stopping transformation ${err}`)
963-
} finally {
964-
telemetry.codeTransform_jobIsCancelledByUser.emit({
965-
codeTransformCancelSrcComponents: cancelSrc as CodeTransformCancelSrcComponents,
966-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
967-
result: MetadataResult.Pass,
968-
})
922+
export async function stopTransformByQ(jobId: string) {
923+
await telemetry.codeTransform_jobIsCancelledByUser.run(async () => {
924+
telemetry.record({
925+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
926+
})
927+
if (transformByQState.isRunning()) {
928+
getLogger().info('CodeTransformation: User requested to stop transformation. Stopping transformation.')
929+
transformByQState.setToCancelled()
930+
transformByQState.setPolledJobStatus('CANCELLED')
931+
await setContext('gumby.isStopButtonAvailable', false)
932+
try {
933+
await stopJob(jobId)
934+
void vscode.window
935+
.showErrorMessage(
936+
CodeWhispererConstants.jobCancelledNotification,
937+
CodeWhispererConstants.amazonQFeedbackText
938+
)
939+
.then((choice) => {
940+
if (choice === CodeWhispererConstants.amazonQFeedbackText) {
941+
void submitFeedback(
942+
placeholder,
943+
CodeWhispererConstants.amazonQFeedbackKey,
944+
getFeedbackCommentData()
945+
)
946+
}
947+
})
948+
} catch (err) {
949+
void vscode.window
950+
.showErrorMessage(
951+
CodeWhispererConstants.errorStoppingJobNotification,
952+
CodeWhispererConstants.amazonQFeedbackText
953+
)
954+
.then((choice) => {
955+
if (choice === CodeWhispererConstants.amazonQFeedbackText) {
956+
void submitFeedback(
957+
placeholder,
958+
CodeWhispererConstants.amazonQFeedbackKey,
959+
getFeedbackCommentData()
960+
)
961+
}
962+
})
963+
getLogger().error(`CodeTransformation: Error stopping transformation ${err}`)
964+
}
969965
}
970-
}
966+
})
971967
}
972968

973969
async function setContextVariables() {

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ export const maxBufferSize = 1024 * 1024 * 8 // this is 8MB; the default max buf
417417

418418
export const transformationJobPollingIntervalSeconds = 5
419419

420-
export const transformationJobTimeoutSeconds = 3 * 60 * 60 // 3 hours, to match backend
421-
422420
export const defaultLanguage = 'Java'
423421

424422
export const contentChecksumType = 'SHA_256'
@@ -578,8 +576,6 @@ export const buildSucceededNotification =
578576
export const absolutePathDetectedMessage = (numPaths: number, buildFile: string, listOfPaths: string) =>
579577
`I detected ${numPaths} potential absolute file path(s) in your ${buildFile} file: **${listOfPaths}**. Absolute file paths might cause issues when I build your code. Any errors will show up in the build log.`
580578

581-
export const unsupportedJavaVersionChatMessage = `I can only upgrade Java 8, Java 11, or Java 17 projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
582-
583579
export const selectSQLMetadataFileHelpMessage =
584580
'Okay, I can convert the embedded SQL code for your Oracle to PostgreSQL transformation. To get started, upload the zipped metadata file from your schema conversion in AWS Data Migration Service (DMS). To retrieve the metadata file:\n1. Open your database migration project in the AWS DMS console.\n2. Open the schema conversion and choose **Convert the embedded SQL in your application**.\n3. Choose the link to Amazon S3 console.\n\nYou can download the metadata file from the {schema-conversion-project}/ directory. For more info, refer to the [documentation](https://docs.aws.amazon.com/dms/latest/userguide/schema-conversion-save-apply.html#schema-conversion-save).'
585581

@@ -610,18 +606,6 @@ export const failedToStartJobTooManyJobsChatMessage =
610606
export const failedToStartJobTooManyJobsNotification =
611607
'Amazon Q could not begin the transformation. You have too many active transformations running. Please try again after your other transformations have completed.'
612608

613-
export const failedToStartJobMonthlyLimitNotification =
614-
'Amazon Q cannot transform your project because it will exceed the free tier limit of 2000 lines of code per month. Try transforming a smaller project.'
615-
616-
export const failedToStartJobMonthlyLimitChatMessage =
617-
'I am sorry, I cannot transform your project because it will exceed the free tier limit of 2000 lines of code per month. You can try again with a smaller project.'
618-
619-
export const failedToStartJobLinesLimitNotification =
620-
'Your project exceeds the free tier limit of 1000 lines of code per transformation. Try transforming a smaller project.'
621-
622-
export const failedToStartJobLinesLimitChatMessage =
623-
'I am sorry, your project exceeds the free tier limit of 1000 lines of code per transformation. You can try again with a smaller project.'
624-
625609
export const failedToUploadProjectChatMessage =
626610
"Sorry, I couldn't upload your project. Please try starting the transformation again."
627611

@@ -674,9 +658,7 @@ export const jobPartiallyCompletedNotification = (multipleDiffsString: string) =
674658
return `Amazon Q transformed part of your code. ${multipleDiffsString} The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
675659
}
676660

677-
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. I couldn\'t find a pom.xml file in any of your open projects, nor could I find any embedded SQL statements. Currently, I can upgrade Java 8 or Java 11 projects built on Maven, or Oracle SQL to PostgreSQL statements in Java projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
678-
679-
export const noPomXmlFoundNotification = `None of your open modules are supported for code transformation with Amazon Q. A pom.xml is required for transformation.`
661+
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. I couldn\'t find a pom.xml file in any of your open projects, nor could I find any embedded SQL statements. Currently, I can upgrade Java 8, 11, or 17 projects built on Maven, or Oracle SQL to PostgreSQL statements in Java projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
680662

681663
export const noJavaHomeFoundChatMessage = `Sorry, I couldn\'t locate your Java installation. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
682664

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ export async function getTransformationSteps(jobId: string, handleThrottleFlag:
627627

628628
export async function pollTransformationJob(jobId: string, validStates: string[]) {
629629
let status: string = ''
630-
let timer: number = 0
631630
while (true) {
632631
throwIfCancelled()
633632
try {
@@ -680,10 +679,6 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
680679
throw new JobStoppedError(response.$response.requestId)
681680
}
682681
await sleep(CodeWhispererConstants.transformationJobPollingIntervalSeconds * 1000)
683-
timer += CodeWhispererConstants.transformationJobPollingIntervalSeconds
684-
if (timer > CodeWhispererConstants.transformationJobTimeoutSeconds) {
685-
throw new Error('Job timed out')
686-
}
687682
} catch (e: any) {
688683
let errorMessage = (e as Error).message
689684
errorMessage += ` -- ${transformByQState.getJobFailureMetadata()}`

packages/core/src/codewhisperer/service/transformByQ/transformationHubViewProvider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,11 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
375375
const isTransformFailed = jobPlanProgress['transformCode'] === StepProgress.Failed
376376
const progress = this.getTransformationStepProgressMarkup(planSteps, isTransformFailed)
377377
const latestGenericStepDetails = this.getLatestGenericStepDetails(transformByQState.getPolledJobStatus())
378+
const jobId = transformByQState.getJobId()
378379
progressHtml = `
379380
<div id="progress" class="column">
380381
<p><b>Transformation Progress</b> <span id="runningTime"></span></p>
382+
<p>${jobId ? `Job ID: ${jobId}` : ''}</p>
381383
${waitingMarkup}
382384
${buildMarkup}
383385
${planMarkup}

0 commit comments

Comments
 (0)