Skip to content

Commit

Permalink
Sensitivity job also runs slow run API
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Dec 9, 2023
1 parent 680a71f commit ab82a44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 2 additions & 10 deletions src/main/ApiDataModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ package com.github.statnett.loadflowservice

import com.powsybl.iidm.network.Network
import com.powsybl.security.SecurityAnalysisResult
<<<<<<< HEAD
=======
import com.powsybl.security.json.SecurityAnalysisJsonModule
import com.powsybl.sensitivity.SensitivityAnalysisResult
import kotlinx.serialization.KSerializer
>>>>>>> 1732bb9 (WIP: Serialize sensitivity analysis result)
import kotlinx.serialization.Serializable

/**
Expand Down Expand Up @@ -75,15 +70,12 @@ data class LoadFlowServiceSecurityAnalysisResult(
@Serializable(with = SecurityAnalysisResultSerializer::class)
val securityAnalysisResult: SecurityAnalysisResult,
val report: String
<<<<<<< HEAD
) : ComputationResult()
=======
)


@Serializable
data class LoadFlowServiceSensitivityAnalysisResult(
@Serializable(with = SensitivityAnalysisResultSerializer::class)
val sensitivityAnalysisResult: SensitivityAnalysisResult,
val report: String
)
>>>>>>> 1732bb9 (WIP: Serialize sensitivity analysis result)
): ComputationResult()
14 changes: 8 additions & 6 deletions src/main/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ fun Application.module() {

sensParamCnt.parameters.setLoadFlowParameters(loadParamCnt.parameters)
val network = networkFromFirstFile(files)
val result = runSensitivityAnalysis(
network,
sensFactorCnt.factors,
sensParamCnt.parameters,
contingencyCnt.contingencies
)
val result = createTask(taskManager) {
runSensitivityAnalysis(
network,
sensFactorCnt.factors,
sensParamCnt.parameters,
contingencyCnt.contingencies
)
}
call.respond(result)
}

Expand Down
12 changes: 9 additions & 3 deletions src/test/AppTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,15 @@ class ApplicationTest {
formData = sensitivityFormData.formData(config)
)
assertEquals(HttpStatusCode.OK, response.status)
val body = response.bodyAsText()
assertTrue(body.contains("2"))
val result = Json.decodeFromString<LoadFlowServiceSensitivityAnalysisResult>(response.body())

val taskInfo = Json.decodeFromString<TaskInfo>(response.body())

val runResult = retryOnError(50, 10) {
client.get(taskInfo.resultUrl)
}
assertEquals(HttpStatusCode.OK, runResult.status)

val result = json.decodeFromString<LoadFlowServiceSensitivityAnalysisResult>(runResult.body())

// There are two contingencies so when we have contingencies there should be three results
// Otherwise one
Expand Down

0 comments on commit ab82a44

Please sign in to comment.