-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.kt
35 lines (29 loc) · 1.01 KB
/
Main.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.mlp.fitaction
import com.mlp.sdk.MlpExecutionContext.Companion.systemContext
import com.mlp.sdk.MlpServiceSDK
import com.mlp.sdk.utils.JSON.parse
enum class Mode {
single,
multi
}
data class InitConfigData(val mode: Mode = Mode.single)
data class FitDatasetData(val map: Map<String, String>)
data class FitConfigData(val upper: Boolean)
data class PredictRequestData(val text: String)
data class PredictResponseData(val text: String)
fun main() {
val initConfig = parse<InitConfigData>(systemContext.environment["SERVICE_CONFIG"] ?: """{"mode":"single"}""")
val service =
when (initConfig.mode) {
Mode.single -> SingleFit(systemContext)
Mode.multi ->
if (systemContext.environment["MLP_STORAGE_DIR"].isNullOrEmpty()) {
FitService(systemContext)
} else {
PredictService(systemContext)
}
}
val mlp = MlpServiceSDK(service)
mlp.start()
mlp.blockUntilShutdown()
}