Skip to content

Commit 053a5bd

Browse files
committed
fix(amazonq): fix to move isSagemaker to env
1 parent b3ad9a8 commit 053a5bd

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

packages/core/src/shared/extensionUtilities.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getLogger } from './logger/logger'
1111
import { VSCODE_EXTENSION_ID, extensionAlphaVersion } from './extensions'
1212
import { Ec2MetadataClient } from './clients/ec2MetadataClient'
1313
import { DefaultEc2MetadataClient } from './clients/ec2MetadataClient'
14-
import { extensionVersion, getCodeCatalystDevEnvId } from './vscode/env'
14+
import { extensionVersion, getCodeCatalystDevEnvId, hasSageMakerEnvVars } from './vscode/env'
1515
import globals from './extensionGlobals'
1616
import { once } from './utilities/functionUtils'
1717
import {
@@ -170,26 +170,14 @@ export function isCloud9(flavor: 'classic' | 'codecatalyst' | 'any' = 'any'): bo
170170
return (flavor === 'classic' && !codecat) || (flavor === 'codecatalyst' && codecat)
171171
}
172172

173-
/**
174-
* Checks if the current environment has SageMaker-specific environment variables
175-
* @returns true if SageMaker environment variables are detected
176-
*/
177-
function hasSageMakerEnvVars(): boolean {
178-
return (
179-
process.env.SAGEMAKER_APP_TYPE !== undefined ||
180-
process.env.SAGEMAKER_INTERNAL_IMAGE_URI !== undefined ||
181-
process.env.STUDIO_LOGGING_DIR?.includes('/var/log/studio') === true
182-
)
183-
}
184-
185173
/**
186174
*
187175
* @param appName to identify the proper SM instance
188176
* @returns true if the current system is SageMaker(SMAI or SMUS)
189177
*/
190178
export function isSageMaker(appName: 'SMAI' | 'SMUS' = 'SMAI'): boolean {
191179
// Check for SageMaker-specific environment variables first
192-
if (hasSageMakerEnvVars() || process.env.SERVICE_NAME === sageMakerUnifiedStudio) {
180+
if (hasSageMakerEnvVars()) {
193181
getLogger().debug('SageMaker environment detected via environment variables')
194182
return true
195183
}

packages/core/src/shared/vscode/env.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,25 @@ export function isRemoteWorkspace(): boolean {
124124
return vscode.env.remoteName === 'ssh-remote'
125125
}
126126

127+
/**
128+
* Checks if the current environment has SageMaker-specific environment variables
129+
* @returns true if SageMaker environment variables are detected
130+
*/
131+
export function hasSageMakerEnvVars(): boolean {
132+
// Check both old and new environment variable names
133+
// SageMaker is renaming their environment variables in their Docker images
134+
return (
135+
// Original environment variables
136+
process.env.SAGEMAKER_APP_TYPE !== undefined ||
137+
process.env.SAGEMAKER_INTERNAL_IMAGE_URI !== undefined ||
138+
process.env.STUDIO_LOGGING_DIR?.includes('/var/log/studio') === true ||
139+
// New environment variables (update these with the actual new names)
140+
process.env.SM_APP_TYPE !== undefined ||
141+
process.env.SM_INTERNAL_IMAGE_URI !== undefined ||
142+
process.env.SERVICE_NAME === 'SageMakerUnifiedStudio'
143+
)
144+
}
145+
127146
/**
128147
* Checks if the current environment is running on Amazon Linux 2.
129148
*
@@ -135,11 +154,7 @@ export function isRemoteWorkspace(): boolean {
135154
export function isAmazonLinux2() {
136155
// First check if we're in a SageMaker environment, which should not be treated as AL2
137156
// even if the underlying host is AL2
138-
if (
139-
process.env.SAGEMAKER_APP_TYPE ||
140-
process.env.SERVICE_NAME === 'SageMakerUnifiedStudio' ||
141-
process.env.SAGEMAKER_INTERNAL_IMAGE_URI
142-
) {
157+
if (hasSageMakerEnvVars()) {
143158
return false
144159
}
145160

0 commit comments

Comments
 (0)