Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/core/src/codewhisperer/service/testGenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { randomUUID } from '../../shared/crypto'
import { sleep } from '../../shared/utilities/timeoutUtils'
import { tempDirPath } from '../../shared/filesystemUtilities'
import fs from '../../shared/fs/fs'
import { AuthUtil } from '../util/authUtil'

// TODO: Get TestFileName and Framework and to error message
export function throwIfCancelled() {
Expand Down Expand Up @@ -310,7 +311,8 @@ export async function downloadResultArchive(
},
},
},
pathToArchive
pathToArchive,
AuthUtil.instance.regionProfileManager.activeRegionProfile
)
} catch (e: any) {
downloadErrorMessage = (e as Error).message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { encodeHTML } from '../../../shared/utilities/textUtilities'
import { convertToTimeString } from '../../../shared/datetime'
import { getAuthType } from '../../../auth/utils'
import { UserWrittenCodeTracker } from '../../tracker/userWrittenCodeTracker'
import { AuthUtil } from '../../util/authUtil'

export function getSha256(buffer: Buffer) {
const hasher = crypto.createHash('sha256')
Expand Down Expand Up @@ -759,7 +760,8 @@ export async function downloadResultArchive(
exportId: jobId,
exportIntent: ExportIntent.TRANSFORMATION,
},
pathToArchive
pathToArchive,
AuthUtil.instance.regionProfileManager.activeRegionProfile
)
} catch (e: any) {
getLogger().error(`CodeTransformation: ExportResultArchive error = %O`, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSess
import { setContext } from '../../../shared/vscode/setContext'
import * as codeWhisperer from '../../client/codewhisperer'
import { UserWrittenCodeTracker } from '../../tracker/userWrittenCodeTracker'
import { AuthUtil } from '../../util/authUtil'

export abstract class ProposedChangeNode {
abstract readonly resourcePath: string
Expand Down Expand Up @@ -403,7 +404,8 @@ export class ProposedTransformationExplorer {
exportId: transformByQState.getJobId(),
exportIntent: ExportIntent.TRANSFORMATION,
},
pathToArchive
pathToArchive,
AuthUtil.instance.regionProfileManager.activeRegionProfile
)

getLogger().info('CodeTransformation: downloaded results successfully')
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/shared/utilities/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { CodeWhispererStreaming, ExportResultArchiveCommandInput } from '@amzn/codewhisperer-streaming'
import { ToolkitError } from '../errors'
import fs from '../fs/fs'
import { RegionProfile } from '../../codewhisperer/models/model'

/**
* This class represents the structure of the archive returned by the ExportResultArchive endpoint
Expand All @@ -21,9 +22,10 @@ export class ExportResultArchiveStructure {
export async function downloadExportResultArchive(
cwStreamingClient: CodeWhispererStreaming,
exportResultArchiveArgs: ExportResultArchiveCommandInput,
toPath: string
toPath: string,
profile: RegionProfile | undefined
) {
const result = await cwStreamingClient.exportResultArchive(exportResultArchiveArgs)
const result = await cwStreamingClient.exportResultArchive({ ...exportResultArchiveArgs, profileArn: profile?.arn })

const buffer = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { fs, getRandomString } from '../../shared'
import { createTestWorkspace } from '../../test/testUtil'
import { getEqualOSTestOptions, performanceTest } from '../../shared/performance/performance'
import { downloadExportResultArchive } from '../../shared/utilities/download'
import { RegionProfile } from '../../codewhisperer'

interface SetupResult {
workspace: WorkspaceFolder
exportCommandInput: ExportResultArchiveCommandInput
writeFileStub: sinon.SinonStub
cwStreaming: any
profile: RegionProfile
}

interface FakeCommandOutput {
Expand All @@ -42,7 +44,8 @@ async function setup(pieces: number, pieceSize: number): Promise<SetupResult> {
const cwStreaming = { exportResultArchive: () => generateCommandOutput(pieces, pieceSize) }

const writeFileStub = sinon.stub(fs, 'writeFile')
return { workspace, exportCommandInput, writeFileStub, cwStreaming }
const profile: RegionProfile = { name: 'foo', region: 'us-east-1', arn: 'foo-arn', description: '' }
return { workspace, exportCommandInput, writeFileStub, cwStreaming, profile }
}

function perfTest(pieces: number, pieceSize: number, label: string) {
Expand All @@ -56,11 +59,18 @@ function perfTest(pieces: number, pieceSize: number, label: string) {
function () {
return {
setup: async () => await setup(pieces, pieceSize),
execute: async ({ workspace, cwStreaming, exportCommandInput, writeFileStub }: SetupResult) => {
execute: async ({
workspace,
cwStreaming,
exportCommandInput,
writeFileStub,
profile,
}: SetupResult) => {
await downloadExportResultArchive(
cwStreaming,
exportCommandInput,
path.join(workspace.uri.fsPath, 'result')
path.join(workspace.uri.fsPath, 'result'),
profile
)
},
verify: async (setup: SetupResult) => {
Expand Down
Loading