Skip to content

Enables utbot-analytics module in utbot-intellij module #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 24, 2022
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
Prev Previous commit
Next Next commit
Added an initial solution
  • Loading branch information
amandelpie committed Aug 12, 2022
commit 1fcda19da6eb0c7d1deee2c151f47b2c41ea7561
12 changes: 12 additions & 0 deletions utbot-analytics/src/main/kotlin/org/utbot/AnalyticsSetUp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.utbot

import org.utbot.analytics.EngineAnalyticsContext
import org.utbot.predictors.StateRewardPredictorFactoryImpl

class AnalyticsSetUp {
companion object {
init {
EngineAnalyticsContext.stateRewardPredictorFactory[1] = StateRewardPredictorFactoryImpl()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.utbot.engine.selectors.NNRewardGuidedSelectorWithRecalculationFactory
import org.utbot.engine.selectors.NNRewardGuidedSelectorWithoutRecalculationFactory
import org.utbot.framework.NNRewardGuidedSelectorType
import org.utbot.framework.UtSettings
import java.util.PriorityQueue

/**
* Class that stores all objects that need for work analytics module during symbolic execution
Expand All @@ -28,9 +29,13 @@ object EngineAnalyticsContext {
NNRewardGuidedSelectorType.WITH_RECALCULATION -> NNRewardGuidedSelectorWithRecalculationFactory()
}

var stateRewardPredictorFactory: StateRewardPredictorFactory = object : StateRewardPredictorFactory {
override fun invoke(): StateRewardPredictor {
error("NNStateRewardPredictor factory wasn't provided")
var stateRewardPredictorFactory: MutableMap<Int, StateRewardPredictorFactory> = mutableMapOf()

init {
stateRewardPredictorFactory[0] = object : StateRewardPredictorFactory {
override fun invoke(): StateRewardPredictor {
error("NNStateRewardPredictor factory wasn't provided")
}
}
}
}
2 changes: 1 addition & 1 deletion utbot-intellij/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {

implementation(project(":utbot-framework")) { exclude group: 'org.slf4j', module: 'slf4j-api' }
implementation(project(":utbot-fuzzers"))
api project(':utbot-analytics') // TODO???
implementation project(':utbot-analytics')
testImplementation 'org.mock-server:mockserver-netty:5.4.1'
testImplementation(project(":utbot-sample"))
testApi(project(":utbot-framework"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.intellij.testIntegration.TestIntegrationUtils
import com.intellij.util.concurrency.AppExecutorUtil
import mu.KotlinLogging
import org.jetbrains.kotlin.idea.util.module
import org.utbot.AnalyticsSetUp
import org.utbot.analytics.EngineAnalyticsContext
import org.utbot.analytics.Predictors
import org.utbot.engine.util.mockListeners.ForceMockListener
Expand All @@ -51,16 +52,13 @@ import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import org.utbot.common.filterWhen
import org.utbot.engine.util.mockListeners.ForceStaticMockListener
import org.utbot.features.FeatureExtractorFactoryImpl
import org.utbot.features.FeatureProcessorWithStatesRepetitionFactory
import org.utbot.framework.PathSelectorType
import org.utbot.framework.plugin.api.testFlow
import org.utbot.intellij.plugin.settings.Settings
import org.utbot.intellij.plugin.ui.utils.isGradle
import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots
import org.utbot.intellij.plugin.util.isAbstract
import org.utbot.intellij.plugin.ui.utils.testModules
import org.utbot.predictors.StateRewardPredictorFactoryImpl
import kotlin.reflect.KClass
import kotlin.reflect.full.functions

Expand Down Expand Up @@ -263,11 +261,12 @@ object UtTestsDialogProcessor {
}

private fun configureML() {
EngineAnalyticsContext.featureProcessorFactory = FeatureProcessorWithStatesRepetitionFactory()
EngineAnalyticsContext.featureExtractorFactory = FeatureExtractorFactoryImpl()
EngineAnalyticsContext.stateRewardPredictorFactory = StateRewardPredictorFactoryImpl()
// EngineAnalyticsContext.featureProcessorFactory = FeatureProcessorWithStatesRepetitionFactory()
// EngineAnalyticsContext.featureExtractorFactory = FeatureExtractorFactoryImpl()
// EngineAnalyticsContext.stateRewardPredictorFactory = StateRewardPredictorFactoryImpl()
//AnalyticsSetUp
if (UtSettings.pathSelectorType == PathSelectorType.NN_REWARD_GUIDED_SELECTOR) {
Predictors.stateRewardPredictor = EngineAnalyticsContext.stateRewardPredictorFactory()
Predictors.stateRewardPredictor = EngineAnalyticsContext.stateRewardPredictorFactory[1]!!.invoke()
}

logger.info { "PathSelectorType: ${UtSettings.pathSelectorType}" }
Expand Down