Skip to content

Commit

Permalink
don't show buildCode step for SQL conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hasani committed Oct 14, 2024
1 parent f42e697 commit fedd525
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,12 @@ ${codeSnippet}
id: ButtonActions.SELECT_SQL_CONVERSION_METADATA_FILE,
})

buttons.push({
keepCardAfterClick: false,
text: 'Cancel',
id: ButtonActions.CANCEL_TRANSFORMATION_FORM,
})

this.dispatcher.sendChatMessage(
new ChatMessage(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export async function processSQLConversionTransformFormInput(pathToProject: stri
transformByQState.setProjectName(path.basename(pathToProject))
transformByQState.setProjectPath(pathToProject)
transformByQState.setSchema(schema)
transformByQState.setSourceJDKVersion(JDKVersion.JDK8) // use dummy value of JDK8 so that startJob API can be called
// targetJDKVersion defaults to JDK17, the only supported version, which is fine
}

export async function validateSQLMetadataFile(fileContents: string, message: any) {
Expand Down Expand Up @@ -136,7 +138,7 @@ export async function validateSQLMetadataFile(fileContents: string, message: any
serverNodeLocations.forEach((serverNodeLocation: any) => {
const schemaNodes = serverNodeLocation['FullNameNodeInfoList'][0]['nameParts'][0][
'FullNameNodeInfo'
].filter((node: any) => node['$']['typeNode'] === 'schema')
].filter((node: any) => node['$']['typeNode'].toLowerCase() === 'schema')
schemaNodes.forEach((node: any) => {
schemaNames.add(node['$']['nameNode'].toUpperCase())
})
Expand Down
10 changes: 1 addition & 9 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,10 @@ export const selectSQLMetadataFileHelpMessage =

export const invalidMetadataFileUnsupportedSourceDB = `Sorry, your .sct metadata file appears to be invalid; the source DB must be Oracle.`

export const invalidMetadataFileUnsupportedTargetDB = `Sorry, your .sct metadata file appears to be invalid; the target DB must be Aurora Postgresql or Amazon RDS for Postgresql.`
export const invalidMetadataFileUnsupportedTargetDB = `Sorry, your .sct metadata file appears to be invalid; the target DB must be Aurora PostgreSQL or Amazon RDS for PostgreSQL.`

export const invalidMetadataFileErrorParsing = 'Sorry, the .sct metadata file you provided appears to be invalid.'

export const oracleVendor = 'Oracle'

export const otherVendor = 'Other'

export const auroraTargetVendor = 'Amazon Aurora PostgreSQL'

export const rdsTargetVendor = 'Amazon RDS for PostgreSQL'

export const failedToStartJobChatMessage =
"Sorry, I couldn't begin the transformation. Please try starting the transformation again."

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ export class TransformByQState {
this.sourceDB = undefined
this.targetDB = undefined
this.sourceServerName = ''
this.schema = ''
this.schemaOptions.clear()
this.errorLog = ''
this.customBuildCommand = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ export async function uploadPayload(payloadFileName: string, uploadContext?: Upl
transformByQState.setJobId(encodeHTML(response.uploadId))
}
jobPlanProgress['uploadCode'] = StepProgress.Succeeded
if (transformByQState.getSchema()) {
// if doing a SQL conversion, we don't build the code, so mark this step as succeeded immediately so that next step renders
jobPlanProgress['buildCode'] = StepProgress.Succeeded
}
updateJobHistory()
return response.uploadId
}
Expand Down Expand Up @@ -402,17 +406,16 @@ export async function zipCode({ dependenciesFolder, humanInTheLoopFlag, projectP
export async function startJob(uploadId: string) {
const sourceLanguageVersion = `JAVA_${transformByQState.getSourceJDKVersion()}`
const targetLanguageVersion = `JAVA_${transformByQState.getTargetJDKVersion()}`
// TO-DO: figure out what to set source and target language version too, along with transformation type
try {
const response = await codeWhisperer.codeWhispererClient.codeModernizerStartCodeTransformation({
workspaceState: {
uploadId: uploadId,
programmingLanguage: { languageName: CodeWhispererConstants.defaultLanguage.toLowerCase() },
},
transformationSpec: {
transformationType: CodeWhispererConstants.transformationType,
source: { language: sourceLanguageVersion },
target: { language: targetLanguageVersion },
transformationType: CodeWhispererConstants.transformationType, // shared b/w language upgrades & sql conversions for now
source: { language: sourceLanguageVersion }, // dummy value of JDK8 used for SQL conversions just so that this API can be called
target: { language: targetLanguageVersion }, // always JDK17
},
})
if (response.$response.requestId) {
Expand Down Expand Up @@ -619,6 +622,7 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
transformationJobId: jobId,
})
status = response.transformationJob.status!
// if doing a SQL conversion, we don't build the code, so mark this step as succeeded immediately so that next step gets rendered
if (CodeWhispererConstants.validStatesForBuildSucceeded.includes(status)) {
jobPlanProgress['buildCode'] = StepProgress.Succeeded
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,13 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
return CodeWhispererConstants.filesUploadedMessage
case 'PREPARING':
case 'PREPARED':
return CodeWhispererConstants.buildingCodeMessage.replace(
'JAVA_VERSION_HERE',
transformByQState.getSourceJDKVersion() ?? ''
)
// for SQL conversions, skip to planningMessage since we don't build the code
return transformByQState.getSchema()
? CodeWhispererConstants.planningMessage
: CodeWhispererConstants.buildingCodeMessage.replace(
'JAVA_VERSION_HERE',
transformByQState.getSourceJDKVersion() ?? ''
)
case 'PLANNING':
case 'PLANNED':
return CodeWhispererConstants.planningMessage
Expand Down Expand Up @@ -331,7 +334,7 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
activeStepId === 0
)
const buildMarkup =
activeStepId >= 1 && !transformByQState.getMetadataPathSQL() // for SQL conversions, don't show buildCode step
activeStepId >= 1 && !transformByQState.getSchema() // for SQL conversions, don't show buildCode step
? simpleStep(
this.getProgressIconMarkup(jobPlanProgress['buildCode']),
CodeWhispererConstants.buildCodeStepMessage,
Expand Down

0 comments on commit fedd525

Please sign in to comment.