Skip to content

Commit cbd8ad6

Browse files
author
David Hasani
committed
poll correctly
1 parent 7b8e2ff commit cbd8ad6

File tree

8 files changed

+30
-14
lines changed

8 files changed

+30
-14
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerSession.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ import java.util.concurrent.atomic.AtomicBoolean
7272
import javax.net.ssl.SSLHandshakeException
7373

7474
const val MAX_ZIP_SIZE = 2000000000 // 2GB
75-
const val EXPLAINABILITY_V1 = "EXPLAINABILITY_V1"
76-
const val SELECTIVE_TRANSFORMATION_V2 = "SELECTIVE_TRANSFORMATION_V2"
7775

7876
// constants for handling SDKClientException
7977
const val CONNECTION_REFUSED_ERROR: String = "Connection refused"
@@ -554,6 +552,8 @@ class CodeModernizerSession(
554552

555553
else -> {
556554
LOG.error(e) { e.message.toString() }
555+
LOG.info { "Stopping transformation job [$jobId] due to unexpected error." }
556+
stopTransformation(jobId.id)
557557
CodeModernizerJobCompletedResult.RetryableFailure(
558558
jobId,
559559
message("codemodernizer.notification.info.modernize_failed.connection_failed", e.message.orEmpty()),

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.ArtifactHandler
3232
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeModernizerManager
3333
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeModernizerManager.Companion.LOG
3434
import software.aws.toolkits.jetbrains.services.codemodernizer.CodeTransformTelemetryManager
35-
import software.aws.toolkits.jetbrains.services.codemodernizer.EXPLAINABILITY_V1
3635
import software.aws.toolkits.jetbrains.services.codemodernizer.HilTelemetryMetaData
3736
import software.aws.toolkits.jetbrains.services.codemodernizer.InboundAppMessagesHandler
38-
import software.aws.toolkits.jetbrains.services.codemodernizer.SELECTIVE_TRANSFORMATION_V2
3937
import software.aws.toolkits.jetbrains.services.codemodernizer.client.GumbyClient
4038
import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformActionMessage
4139
import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformCommand
@@ -103,6 +101,9 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransfo
103101
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CustomerSelection
104102
import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadArtifactResult
105103
import software.aws.toolkits.jetbrains.services.codemodernizer.model.DownloadFailureReason
104+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.EXPLAINABILITY_V1
105+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.IDE
106+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.SELECTIVE_TRANSFORMATION_V2
106107
import software.aws.toolkits.jetbrains.services.codemodernizer.model.InvalidTelemetryReason
107108
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
108109
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_RUN_UNIT_TESTS
@@ -418,7 +419,7 @@ class CodeTransformChatController(
418419
codeModernizerManager.codeTransformationSession?.let {
419420
it.sessionContext.customBuildCommand = customBuildCommand
420421
}
421-
val transformCapabilities = listOf(EXPLAINABILITY_V1, CLIENT_SIDE_BUILD, SELECTIVE_TRANSFORMATION_V2)
422+
val transformCapabilities = listOf(EXPLAINABILITY_V1, CLIENT_SIDE_BUILD, SELECTIVE_TRANSFORMATION_V2, IDE)
422423
codeModernizerManager.codeTransformationSession?.let {
423424
it.sessionContext.transformCapabilities = transformCapabilities
424425
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const val UPLOAD_ZIP_MANIFEST_VERSION = "1.0"
5050
const val HIL_1P_UPGRADE_CAPABILITY = "HIL_1pDependency_VersionUpgrade"
5151
const val EXPLAINABILITY_V1 = "EXPLAINABILITY_V1"
5252
const val SELECTIVE_TRANSFORMATION_V2 = "SELECTIVE_TRANSFORMATION_V2"
53+
const val IDE = "IDE"
5354
const val CLIENT_SIDE_BUILD = "CLIENT_SIDE_BUILD"
5455
const val MAVEN_CONFIGURATION_FILE_NAME = "pom.xml"
5556
const val MAVEN_BUILD_RUN_UNIT_TESTS = "clean test"

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/ZipManifest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ data class ZipManifest(
88
val dependenciesRoot: String = ZIP_DEPENDENCIES_PATH,
99
val version: String = UPLOAD_ZIP_MANIFEST_VERSION,
1010
val hilCapabilities: List<String> = listOf(HIL_1P_UPGRADE_CAPABILITY),
11-
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1, CLIENT_SIDE_BUILD, SELECTIVE_TRANSFORMATION_V2),
11+
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1, CLIENT_SIDE_BUILD, SELECTIVE_TRANSFORMATION_V2, IDE),
1212
val customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS,
1313
val requestedConversions: RequestedConversions? = null, // only used for SQL conversions for now
1414
var dependencyUpgradeConfigFile: String? = null,

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/state/CodeModernizerState.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import com.intellij.openapi.components.BaseState
77
import com.intellij.openapi.project.Project
88
import com.intellij.openapi.projectRoots.JavaSdkVersion
99
import com.intellij.util.xmlb.annotations.Property
10-
import software.aws.toolkits.jetbrains.services.codemodernizer.EXPLAINABILITY_V1
10+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CLIENT_SIDE_BUILD
1111
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerSessionContext
12+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.EXPLAINABILITY_V1
13+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.IDE
1214
import software.aws.toolkits.jetbrains.services.codemodernizer.model.JobId
1315
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_RUN_UNIT_TESTS
16+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.SELECTIVE_TRANSFORMATION_V2
1417
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.toVirtualFile
1518

1619
enum class JobDetails {
@@ -67,7 +70,7 @@ class CodeModernizerState : BaseState() {
6770
configurationFile,
6871
sourceJavaSdkVersion,
6972
targetJavaSdkVersion,
70-
listOf(EXPLAINABILITY_V1), // default to one diff
73+
listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2, CLIENT_SIDE_BUILD, IDE),
7174
lastJobContext[JobDetails.CUSTOM_BUILD_COMMAND] ?: MAVEN_BUILD_RUN_UNIT_TESTS // default to running unit tests
7275
)
7376
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformApiUtils.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ suspend fun JobId.pollTransformationStatusAndPlan(
8686
var transformationResponse: GetTransformationResponse? = null
8787
var transformationPlan: TransformationPlan? = null
8888
var didSleepOnce = false
89+
var hasSeenTransforming = false
8990
val maxRefreshes = 10
9091
var numRefreshes = 0
9192

@@ -114,12 +115,15 @@ suspend fun JobId.pollTransformationStatusAndPlan(
114115
if (isDisposed.get()) throw AlreadyDisposedException("The invoker is disposed.")
115116
transformationResponse = clientAdaptor.getCodeModernizationJob(this.id)
116117
val newStatus = transformationResponse?.transformationJob()?.status() ?: throw RuntimeException("Unable to get job status")
118+
if (newStatus == TransformationStatus.TRANSFORMING) {
119+
hasSeenTransforming = true
120+
}
117121
var newPlan: TransformationPlan? = null
118122
if (newStatus in STATES_WHERE_PLAN_EXIST && transformType != CodeTransformType.SQL_CONVERSION) { // no plan for SQL conversions
119123
delay(sleepDurationMillis)
120124
newPlan = clientAdaptor.getCodeModernizationPlan(this).transformationPlan()
121125
}
122-
if (newStatus == TransformationStatus.TRANSFORMING && newPlan != null) {
126+
if (hasSeenTransforming && newPlan != null) {
123127
attemptLocalBuild(newPlan, this, project)
124128
}
125129
if (newStatus != state) {

plugins/amazonq/codetransform/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codemodernizer/CodeWhispererCodeModernizerSessionTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ import software.amazon.awssdk.services.codewhispererruntime.model.Transformation
4949
import software.amazon.awssdk.services.codewhispererruntime.model.UploadContext
5050
import software.amazon.awssdk.services.ssooidc.model.SsoOidcException
5151
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
52+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CLIENT_SIDE_BUILD
5253
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerJobCompletedResult
5354
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerSessionContext
5455
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerStartJobResult
5556
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformHilDownloadArtifact
5657
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformType
58+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.EXPLAINABILITY_V1
59+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.IDE
5760
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MAVEN_BUILD_SKIP_UNIT_TESTS
5861
import software.aws.toolkits.jetbrains.services.codemodernizer.model.MavenCopyCommandsResult
62+
import software.aws.toolkits.jetbrains.services.codemodernizer.model.SELECTIVE_TRANSFORMATION_V2
5963
import software.aws.toolkits.jetbrains.services.codemodernizer.model.UploadFailureReason
6064
import software.aws.toolkits.jetbrains.services.codemodernizer.model.ZipCreationResult
6165
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
@@ -146,7 +150,7 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
146150
root.children[0],
147151
JavaSdkVersion.JDK_1_8,
148152
JavaSdkVersion.JDK_11,
149-
listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2),
153+
listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2, CLIENT_SIDE_BUILD, IDE),
150154
MAVEN_BUILD_SKIP_UNIT_TESTS
151155
)
152156
val mockFile = mock(File::class.java)
@@ -164,7 +168,10 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
164168
Path("manifest.json") -> {
165169
assertThat(fileContent).isNotNull()
166170
assertThat(fileContent).contains(MAVEN_BUILD_SKIP_UNIT_TESTS)
171+
assertThat(fileContent).contains(EXPLAINABILITY_V1)
167172
assertThat(fileContent).contains(SELECTIVE_TRANSFORMATION_V2)
173+
assertThat(fileContent).contains(CLIENT_SIDE_BUILD)
174+
assertThat(fileContent).contains(IDE)
168175
assertThat(fileContent).contains("\"noInteractiveMode\":true")
169176
}
170177
Path("sources/src/tmp.txt") -> assertThat(fileContent).isEqualTo(fileText)

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ codemodernizer.chat.message.changes_applied=I applied the changes to your projec
647647
codemodernizer.chat.message.choose_objective=I can help you with the following tasks:\n- Upgrade your Java 8, Java 11, and Java 17 codebases to Java 17 or Java 21.\n- Upgrade Java 17 or Java 21 code with up-to-date libraries and other dependencies.\n- Convert embedded SQL code for Oracle to PostgreSQL database migrations in AWS DMS.\n\nWhat would you like to do? You can enter "language upgrade" or "sql conversion".
648648
codemodernizer.chat.message.choose_objective_placeholder=Enter "language upgrade" or "sql conversion"
649649
codemodernizer.chat.message.custom_dependency_upgrades_continue=Ok, I will continue the transformation without additional dependency upgrade information.
650-
codemodernizer.chat.message.custom_dependency_upgrades_prompt=Would you like to provide a dependency upgrade file? You can specify first and third party dependencies and their versions in a YAML file, and I will upgrade them during the transformation. For an example dependency upgrade file, see the [documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-transformation.html#dependency-upgrade-file).
650+
codemodernizer.chat.message.custom_dependency_upgrades_prompt=Would you like to provide a dependency upgrade file? You can specify first-party dependencies to upgrade in a YAML file, and I will upgrade them during the JDK upgrade (for example, Java 8 to 17). You can initiate a separate transformation (17 to 17 or 21 to 21) after the initial JDK upgrade to transform third-party dependencies.\n\nWithout a YAML file, I can perform a minimum JDK upgrade, and then you can initiate a separate transformation to upgrade all third-party dependencies as part of a maximum transformation. For an example dependency upgrade file, see the [documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-transformation.html#dependency-upgrade-file).
651651
codemodernizer.chat.message.custom_dependency_upgrades_invalid=I wasn't able to parse the dependency upgrade file. Check that it's configured properly and try again. For an example of the required dependency upgrade file format, see the [documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-transformation.html#dependency-upgrade-file).
652652
codemodernizer.chat.message.custom_dependency_upgrades_valid=The dependency upgrade file looks good. I will use this information to upgrade the dependencies you specified.
653653
codemodernizer.chat.message.download_failed_client_instructions_expired=Your transformation is not available anymore. Your code and transformation summary are deleted 24 hours after the transformation completes. Please try starting the transformation again.
@@ -684,8 +684,8 @@ codemodernizer.chat.message.result.fail=Sorry, I ran into an issue during the tr
684684
codemodernizer.chat.message.result.fail_initial_build=I am having trouble building your project in the secure build environment and couldn't complete the transformation.
685685
codemodernizer.chat.message.result.fail_initial_build_no_build_log=I am having trouble building your project in the secure build environment: {0}.
686686
codemodernizer.chat.message.result.fail_with_known_reason=Sorry, I couldn''t complete the transformation. {0}
687-
codemodernizer.chat.message.result.partially_success=I transformed part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation. After successfully building in Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
688-
codemodernizer.chat.message.result.success=I successfully completed your transformation. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the changes I am proposing. After successfully building in Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
687+
codemodernizer.chat.message.result.partially_success=I transformed part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation. After successfully transforming to Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
688+
codemodernizer.chat.message.result.success=I successfully completed your transformation. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the changes I am proposing. After successfully transforming to Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
689689
codemodernizer.chat.message.result.zip_too_large=Sorry, your project size exceeds the Amazon Q Code Transformation upload limit of 2GB.
690690
codemodernizer.chat.message.resume_ongoing=I'm still transforming your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your module. To monitor progress, go to the Transformation Hub.
691691
codemodernizer.chat.message.skip_tests=I will build generated code in your local environment, not on the server side. For information on how I scan code to reduce security risks associated with building the code in your local environment, see the [Amazon Q Developer documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-transformation.html#java-local-builds).\n\nI will build your project using `mvn clean test` by default. If you would like me to build your project without running unit tests, I will use `mvn clean test-compile`.
@@ -706,7 +706,7 @@ codemodernizer.chat.message.upload_failed_other=Sorry, I was unable to upload yo
706706
codemodernizer.chat.message.upload_failed_ssl_error=Sorry, I was unable to upload your project. This might have been caused by your IDE not trusting the certificate of your HTTP proxy. Ensure all certificates for your proxy client have been configured in your IDE, and then retry transformation.
707707
codemodernizer.chat.message.upload_failed_url_expired=Sorry, I couldn't upload your project to begin the transformation. The Amazon S3 pre-signed URL used to upload your code expired after 30 minutes. This might have been caused by delays introduced by intermediate services in your network infrastructure.\n\nCheck your network configuration for services that might be causing delays. If the issue persists, you might need to allow list the following Amazon S3 bucket: 'amazonq-code-transformation-us-east-1-c6160f047e0.s3.amazonaws.com'.
708708
codemodernizer.chat.message.validation.check_eligible_modules=Checking for eligible modules...
709-
codemodernizer.chat.message.validation.check_passed=I can upgrade your Java module. To start the transformation, I need some information from you. Choose the module you want to upgrade and the target code version to upgrade to. Then, choose **Confirm**.\n\nIf you do not see the module you want to transform, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and language level. In the Modules tab, set the correct module JDK and language level.\n\nAfter successfully building in Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
709+
codemodernizer.chat.message.validation.check_passed=I can upgrade your Java module. To start the transformation, I need some information from you. Choose the module you want to upgrade and the target code version to upgrade to. Then, choose **Confirm**.\n\nIf you do not see the module you want to transform, you might need to configure your project so that I can find it. Go to File and choose Project Structure. In the Projects tab, set the correct project JDK and language level. In the Modules tab, set the correct module JDK and language level.\n\nAfter successfully transforming to Java 17 or 21, an additional transformation is required to upgrade your libraries and dependencies. Choose the same source code version and target code version (for example, 17 to 17) to do this.
710710
codemodernizer.chat.message.validation.error.downgrade_attempt=I can't transform a project from Java 21 to Java 17, but I can upgrade Java 21 code with up-to-date libraries and other dependencies. Try again with a supported language upgrade.
711711
codemodernizer.chat.message.validation.error.invalid_sct=It looks like the .sct file you provided isn't valid. Make sure that you've uploaded the .zip file you retrieved from your schema conversion in AWS DMS.
712712
codemodernizer.chat.message.validation.error.invalid_source_db=I can only convert SQL for migrations from an Oracle source database. The provided .sct file indicates another source database for this migration.

0 commit comments

Comments
 (0)