Skip to content

Commit

Permalink
Combine TextKey and TextApiLocation into TextEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartleeks committed Nov 2, 2021
1 parent 0a4b026 commit 5f8ac34
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
import org.apache.spark.sql.functions.col
import org.apache.spark.sql.{DataFrame, Row}

trait TextKey {
trait TextEndpoint {
lazy val textKey = sys.env.getOrElse("TEXT_API_KEY", Secrets.CognitiveApiKey)
}
trait TextApiLocation {
lazy val textApiLocation = sys.env.getOrElse("TEXT_API_LOCATION", "eastus")
}

class LanguageDetectorSuite extends TransformerFuzzing[LanguageDetectorV2] with TextKey with TextApiLocation {
class LanguageDetectorSuite extends TransformerFuzzing[LanguageDetectorV2] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -73,7 +71,7 @@ class LanguageDetectorSuite extends TransformerFuzzing[LanguageDetectorV2] with
override def reader: MLReadable[_] = LanguageDetectorV2
}

class LanguageDetectorV3Suite extends TransformerFuzzing[LanguageDetector] with TextKey with TextApiLocation {
class LanguageDetectorV3Suite extends TransformerFuzzing[LanguageDetector] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -105,7 +103,7 @@ class LanguageDetectorV3Suite extends TransformerFuzzing[LanguageDetector] with
override def reader: MLReadable[_] = LanguageDetector
}

class EntityDetectorSuite extends TransformerFuzzing[EntityDetectorV2] with TextKey with TextApiLocation {
class EntityDetectorSuite extends TransformerFuzzing[EntityDetectorV2] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -135,7 +133,7 @@ class EntityDetectorSuite extends TransformerFuzzing[EntityDetectorV2] with Text
override def reader: MLReadable[_] = EntityDetectorV2
}

class EntityDetectorSuiteV3 extends TransformerFuzzing[EntityDetector] with TextKey {
class EntityDetectorSuiteV3 extends TransformerFuzzing[EntityDetector] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -166,7 +164,7 @@ class EntityDetectorSuiteV3 extends TransformerFuzzing[EntityDetector] with Text
override def reader: MLReadable[_] = EntityDetector
}

trait TextSentimentBaseSuite extends TestBase with TextKey with TextApiLocation {
trait TextSentimentBaseSuite extends TestBase with TextEndpoint {
import spark.implicits._

lazy val df: DataFrame = Seq(
Expand Down Expand Up @@ -254,7 +252,7 @@ class TextSentimentSuite extends TransformerFuzzing[TextSentimentV2] with TextSe
override def reader: MLReadable[_] = TextSentimentV2
}

class KeyPhraseExtractorSuite extends TransformerFuzzing[KeyPhraseExtractorV2] with TextKey with TextApiLocation {
class KeyPhraseExtractorSuite extends TransformerFuzzing[KeyPhraseExtractorV2] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -288,7 +286,7 @@ class KeyPhraseExtractorSuite extends TransformerFuzzing[KeyPhraseExtractorV2] w
override def reader: MLReadable[_] = KeyPhraseExtractorV2
}

class KeyPhraseExtractorV3Suite extends TransformerFuzzing[KeyPhraseExtractor] with TextKey with TextApiLocation {
class KeyPhraseExtractorV3Suite extends TransformerFuzzing[KeyPhraseExtractor] with TextEndpoint {

import spark.implicits._

Expand Down Expand Up @@ -322,7 +320,7 @@ class KeyPhraseExtractorV3Suite extends TransformerFuzzing[KeyPhraseExtractor] w
override def reader: MLReadable[_] = KeyPhraseExtractor
}

class NERSuite extends TransformerFuzzing[NERV2] with TextKey with TextApiLocation {
class NERSuite extends TransformerFuzzing[NERV2] with TextEndpoint {
import spark.implicits._

lazy val df: DataFrame = Seq(
Expand Down Expand Up @@ -361,7 +359,7 @@ class NERSuite extends TransformerFuzzing[NERV2] with TextKey with TextApiLocati
override def reader: MLReadable[_] = NERV2
}

class NERSuiteV3 extends TransformerFuzzing[NER] with TextKey with TextApiLocation {
class NERSuiteV3 extends TransformerFuzzing[NER] with TextEndpoint {
import spark.implicits._

lazy val df: DataFrame = Seq(
Expand Down Expand Up @@ -400,7 +398,7 @@ class NERSuiteV3 extends TransformerFuzzing[NER] with TextKey with TextApiLocati
override def reader: MLReadable[_] = NER
}

class PIISuiteV3 extends TransformerFuzzing[PII] with TextKey with TextApiLocation {
class PIISuiteV3 extends TransformerFuzzing[PII] with TextEndpoint {
import spark.implicits._

lazy val df: DataFrame = Seq(
Expand Down

0 comments on commit 5f8ac34

Please sign in to comment.