From 5a2b61b348725f77de3ac2a606b595c9e4d8398d Mon Sep 17 00:00:00 2001 From: Ladislav Sulak Date: Tue, 22 Aug 2023 12:19:48 +0200 Subject: [PATCH] #25: just making it more English and consistent --- .../za/co/absa/atum/agent/AtumAgent.scala | 17 ++++++++------- .../za/co/absa/atum/agent/AtumContext.scala | 21 ++++++------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/agent/src/main/scala/za/co/absa/atum/agent/AtumAgent.scala b/agent/src/main/scala/za/co/absa/atum/agent/AtumAgent.scala index f7a65f2c6..418e1142f 100644 --- a/agent/src/main/scala/za/co/absa/atum/agent/AtumAgent.scala +++ b/agent/src/main/scala/za/co/absa/atum/agent/AtumAgent.scala @@ -24,26 +24,27 @@ import za.co.absa.atum.agent.model.{AtumPartitions, MeasureResult} object AtumAgent { /** - * Sends the `MeasureResult` and extra data from a given `AtumContext` to the AtumService API. + * Sends a single `MeasureResult` to the AtumService API along with an extra data from a given `AtumContext`. * @param checkpointKey * @param atumContext * @param measureResult */ - def publish(checkpointKey: String, atumContext: AtumContext, measureResult: MeasureResult): Unit = println( - Seq(checkpointKey, atumContext, measureResult).mkString(" || ") - ) + def publish(checkpointKey: String, atumContext: AtumContext, measureResult: MeasureResult): Unit = + println( + s"Enqueued measurement: ${Seq(checkpointKey, atumContext, measureResult).mkString(" || ")}" + ) /** - * Sends a single `MeasureResult` to the AtumService API. With not AtumContext involve. + * Sends a single `MeasureResult` to the AtumService API. It doesn't involve AtumContext. * * @param checkpointKey * @param measureResult */ - def measurePublish(checkpointKey: String, measure: MeasureResult): Unit = - println(s"Enqueued measurement: $checkpointKey, " + (measure)) + def measurePublish(checkpointKey: String, measureResult: MeasureResult): Unit = + println(s"Enqueued measurement: $checkpointKey || $measureResult") /** - * Provides an AtumContext given a `AtumPartitions` instance. Retrieves the data from Atum Service API. + * Provides an AtumContext given a `AtumPartitions` instance. Retrieves the data from AtumService API. * @param atumPartitions * @return */ diff --git a/agent/src/main/scala/za/co/absa/atum/agent/AtumContext.scala b/agent/src/main/scala/za/co/absa/atum/agent/AtumContext.scala index f5f2bfe90..193e995ce 100644 --- a/agent/src/main/scala/za/co/absa/atum/agent/AtumContext.scala +++ b/agent/src/main/scala/za/co/absa/atum/agent/AtumContext.scala @@ -24,26 +24,18 @@ import za.co.absa.atum.agent.model.{AtumPartitions, MeasureResult, Measurement} * @param measurements: A sequences of measurements. */ -case class AtumContext(measurements: Set[Measurement] = Set(), atumPartitions: AtumPartitions = AtumPartitions()) { +case class AtumContext(measurements: Set[Measurement] = Set.empty, atumPartitions: AtumPartitions = AtumPartitions()) { - def withMeasuresReplaced( - byMeasure: Measurement - ): AtumContext = + def withMeasuresReplaced(byMeasure: Measurement): AtumContext = this.copy(measurements = Set(byMeasure)) - def withMeasuresReplaced( - byMeasures: Iterable[Measurement] - ): AtumContext = + def withMeasuresReplaced(byMeasures: Iterable[Measurement]): AtumContext = this.copy(measurements = byMeasures.toSet) - def withMeasuresAdded( - measure: Measurement - ): AtumContext = + def withMeasuresAdded(measure: Measurement): AtumContext = this.copy(measurements = measurements + measure) - def withMeasuresAdded( - measures: Iterable[Measurement] - ): AtumContext = + def withMeasuresAdded(measures: Iterable[Measurement]): AtumContext = this.copy(measurements = measurements ++ measures) def withMeasureRemoved(measurement: Measurement): AtumContext = @@ -55,12 +47,11 @@ object AtumContext { implicit class DatasetWrapper(df: DataFrame) { /** - * Executes the measure directly with not AtumContext. + * Executes the measure directly (without AtumContext). * @param measure the measure to be calculated * @return */ def executeMeasure(checkpointName: String, measure: Measurement): DataFrame = { - val result = MeasureResult(measure, measure.function(df)) AtumAgent.measurePublish(checkpointName, result) df