<commit_before>package de.frosner.broccoli.instances

import java.nio.file.FileSystems
import javax.inject.Singleton

import com.google.inject.{AbstractModule, Provides}
import de.frosner.broccoli.instances.conf.InstanceConfiguration
import net.codingwell.scalaguice.ScalaModule
import play.api.{Configuration, Logger}
import play.api.inject.ApplicationLifecycle
import play.api.libs.ws.WSClient

import scala.concurrent.Future
import scala.util.{Failure, Success, Try}

/**
  * Provide Instance and InstanceStorage configuration from the Play configuration
  */
class InstanceModule extends AbstractModule with ScalaModule {
  private val log = Logger(getClass)

  override def configure(): Unit = {}

  @Provides
  @Singleton
  def provideInstanceConfiguration(config: Configuration): InstanceConfiguration =
    InstanceConfiguration.fromConfig(config.underlying.getConfig("broccoli.instances"))

  @Provides
  @Singleton
  def provideInstanceStorage(instanceConfig: InstanceConfiguration,
                             ws: WSClient,
                             applicationLifecycle: ApplicationLifecycle): InstanceStorage = {
    val maybeInstanceStorage = instanceConfig.storageConfiguration.storageType match {
      case StorageType.FileSystem => {
        val config = instanceConfig.storageConfiguration.fsConfig
        val path = FileSystems.getDefault.getPath(config.url).toAbsolutePath
        Try(FileSystemInstanceStorage(path.toFile))
      }
      case StorageType.CouchDB => {
        val config = instanceConfig.storageConfiguration.couchDBConfig
        Try(CouchDBInstanceStorage(config.url, config.dbName, ws))
      }
    }

    val instanceStorage = maybeInstanceStorage match {
      case Success(storage) => storage
      case Failure(throwable) =>
        log.error(s"Cannot start instance storage: $throwable")
        throw throwable
    }
<commit_msg>#17 Remove redundant Try in InstanceModule.provideInstanceStorage method<commit_after>package de.frosner.broccoli.instances

import java.nio.file.FileSystems
import javax.inject.Singleton

import com.google.inject.{AbstractModule, Provides}
import de.frosner.broccoli.instances.conf.InstanceConfiguration
import net.codingwell.scalaguice.ScalaModule
import play.api.{Configuration, Logger}
import play.api.inject.ApplicationLifecycle
import play.api.libs.ws.WSClient

import scala.concurrent.Future
import scala.util.{Failure, Success, Try}

/**
  * Provide Instance and InstanceStorage configuration from the Play configuration
  */
class InstanceModule extends AbstractModule with ScalaModule {
  private val log = Logger(getClass)

  override def configure(): Unit = {}

  @Provides
  @Singleton
  def provideInstanceConfiguration(config: Configuration): InstanceConfiguration =
    InstanceConfiguration.fromConfig(config.underlying.getConfig("broccoli.instances"))

  @Provides
  @Singleton
  def provideInstanceStorage(instanceConfig: InstanceConfiguration,
                             ws: WSClient,
                             applicationLifecycle: ApplicationLifecycle): InstanceStorage = {
    val instanceStorage = instanceConfig.storageConfiguration.storageType match {
      case StorageType.FileSystem => {
        val config = instanceConfig.storageConfiguration.fsConfig
        val path = FileSystems.getDefault.getPath(config.url).toAbsolutePath
        FileSystemInstanceStorage(path.toFile)
      }
      case StorageType.CouchDB => {
        val config = instanceConfig.storageConfiguration.couchDBConfig
        CouchDBInstanceStorage(config.url, config.dbName, ws)
      }
    }

{'fraction_non_alphanumeric': 0.07756696428571429, 'fraction_numerical': 0.0005580357142857143, 'mean_word_length': 4.02805049088359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2145316', 'n_tokens_mistral': 930, 'n_tokens_neox': 918, 'n_words': 196}