Skip to content
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

examples standalone in repo #106

Merged
merged 23 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ece7aaf
#99 core examples in a subfolder - todo readme. (s3 examples not done…
dk1844 Jul 30, 2021
cdce13f
#99 core examples in a subfolder - s3 examples self-standing, too.
dk1844 Jul 30, 2021
335d801
#99 core examples in a subfolder - spark 3 update: spark.close
dk1844 Jul 30, 2021
fb4107d
#99 core examples in a subfolder - s3 examples self-standing with sca…
dk1844 Jul 30, 2021
fda91e8
#99 atum core examples README.md
dk1844 Aug 2, 2021
3db0c56
Merge branch 'release/4.0.0' into feature/99-examples-standalone-in-repo
dk1844 Aug 2, 2021
01d83fa
#99 atum sdk s3 extension examples README.md, typos for core examples…
dk1844 Aug 2, 2021
0f70984
#99 examples runner, too.
dk1844 Aug 2, 2021
2d27880
#99 examples runner, attempt - with working directory
dk1844 Aug 2, 2021
72ef1c3
#99 examples runner update, scalatest pom update
dk1844 Aug 2, 2021
f6ea32e
#99 encoding added to example projects
dk1844 Aug 2, 2021
a4ba9f7
#99 eventually is back for compile scope - to demonstrate sample meas…
dk1844 Aug 2, 2021
a5ad850
#99 span scale factor = 10 for GH action
dk1844 Aug 2, 2021
f119266
#99 eventually inflated times
dk1844 Aug 2, 2021
6a01998
#99 eventually back to 10 secs, spark.disableControlMeasuresTracking(…
dk1844 Aug 2, 2021
03a2edf
Merge branch 'release/4.0.0' into feature/99-examples-standalone-in-repo
dk1844 Aug 5, 2021
eea931a
Update examples/atum-examples/README.md
dk1844 Aug 12, 2021
0a7fdaa
#99 copyright year update
dk1844 Aug 12, 2021
a5aa8af
#99 explicit plugin versions moved to properties (build plugin maven.…
dk1844 Aug 12, 2021
bfc7390
Merge branch 'release/4.0.0' into feature/99-examples-standalone-in-repo
dk1844 Aug 12, 2021
ac3e167
#99 license_check.yml reverted
dk1844 Aug 12, 2021
7889ee6
#99 SampleMeasurementsIntegrationSuite companion object moved in fron…
dk1844 Aug 12, 2021
ea27482
#99 reverting an accidental removal of crossbuild for Scala 2.12 + Sp…
dk1844 Aug 13, 2021
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
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ jobs:
- name: Build and unit test
if: ${{ ! contains( github.event.pull_request.labels.*.name, 'NoTestNeeded') }}
run: mvn clean install --no-transfer-progress -Pspark-${{ matrix.spark }} -Dspan.scale.factor=10
- name: Build and unit test Atum Examples Scala ${{ matrix.scala }} and Spark ${{ matrix.spark }}
working-directory: ./examples/atum-examples
if: ${{ ! contains( github.event.pull_request.labels.*.name, 'NoTestNeeded') }}
run: |
mvn scala-cross-build:change-version -Pscala-${{ matrix.scala }}
mvn clean install --no-transfer-progress -Pspark-${{ matrix.spark }} -Dspan.scale.factor=10
Zejnilovic marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ dependency-reduced-pom.xml

_testOutput
myTestCheckpoints
examples/data/output

# switch to regexp syntax.
# syntax: regexp
# ^\.pc/
/examples-s3-sdk-extension/data/output_s3/

# examples:
examples/atum-examples/data/output
examples/s3-sdk-extension-examples/data/output_s3/



pom.xml.bkp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import za.co.absa.atum.utils.{BuildProperties, FileUtils, SerializationUtils, Sp

import scala.concurrent.duration.DurationInt

object SampleMeasurementsIntegrationSuite {

private case class TestBuildProperties(projectName: String, buildVersion: String) extends BuildProperties

}

class SampleMeasurementsIntegrationSuite extends AnyFlatSpec with Matchers with Eventually with SparkTestBase
with BeforeAndAfterAll with OptionValues {

Expand Down Expand Up @@ -123,9 +129,3 @@ class SampleMeasurementsIntegrationSuite extends AnyFlatSpec with Matchers with
spark.disableControlMeasuresTracking()
}
}

object SampleMeasurementsIntegrationSuite {

private case class TestBuildProperties(projectName: String, buildVersion: String) extends BuildProperties

}
2 changes: 0 additions & 2 deletions build-all.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ IF %ERRORLEVEL% NEQ 0 GOTO end

CALL :cross_build 2.11 2.4
IF %ERRORLEVEL% NEQ 0 GOTO end
CALL :cross_build 2.12 2.4
IF %ERRORLEVEL% NEQ 0 GOTO end
CALL :cross_build 2.12 3.1
IF %ERRORLEVEL% NEQ 0 GOTO end

Expand Down
101 changes: 0 additions & 101 deletions examples-s3-sdk-extension/pom.xml

This file was deleted.

63 changes: 63 additions & 0 deletions examples/atum-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Atum Spark Job Application Example

This is a set of Atum Apache Spark Applications that can be used as inspiration for creating other
Spark projects. It includes all dependencies in a 'fat' jar to run the job locally and on a cluster.

Here is the list of examples (all from `za.co.absa.atum.examples` space):

- `SampleMeasurements{1|2|3}` - Example apps using core Atum to show the Atum initialization,
checkpoint setup and the resulting control measure handling (in the form of `_INFO` file)
- `CreateInfoFileTool[CSV]` - Applications demonstrating the means of creating the initial `_INFO` for data (CSV or general)

## Usage

The example application is in `za.co.absa.atum.examples` package. The project contains build files for `Maven`.

## Maven

**To test-run this locally use**
```shell script
mvn test
```
(This will run the `SampleMeasurements{1|2|3}` jobs via `SampleMeasurementsHdfsRunnerSpec` as tests)

**To build an uber jar to run on cluster**
```shell script
mvn package -DskipTests=true
```

## Scala and Spark version switching
Same as Atum itself, the example project also supports switching to build with different Scala and Spark version:

Switching Scala version (2.11 or 2.12) can be done via
```shell script
mvn scala-cross-build:change-version -Pscala-2.11 # this is default
# or
mvn scala-cross-build:change-version -Pscala-2.12
```

Choosing a spark version to build, there are `spark-2.4` and `spark-3.1` profiles:
```shell script
mvn clean install -Pspark-2.4 # this is default
mvn clean install -Pspark-3.1
```

## Running via spark-submit

After the project is packaged you can copy `target/2.11/atum-examples_2.11-0.0.1-SNAPSHOT.jar`
to an edge node of a cluster and use `spark-submit` to run the job. Here is an example when running on Yarn:

```shell script
spark-submit --master yarn --deploy-mode client --class za.co.absa.atum.examples.SampleMeasurements1 atum-examples_2.11-0.0.1-SNAPSHOT.jar
```

### Running Spark Applications in local mode from an IDE
If you try to run the example from an IDE you'll likely get the following exception:
```Exception in thread "main" java.lang.NoClassDefFoundError: scala/Option```

This is because the jar is created with all Scala and Spark dependencies removed (using shade plugin). This is done so that the uber jar for `spark-submit` is not too big.

There are multiple options to deal with it, namely:
- use the test runner class, for the SampleMeasurements, it is `SampleMeasurementsHdfsRunnerSpec` (provided dependencies will be loaded for tests)
- use the _Include dependencies with "Provided" scope_ option in Run Configuration in IDEA or equivalent in your IDE.
- change the scope of `provided` dependencies to `compile` in the POM file and run Spark Applications as a normal JVM App.
Loading