Coder Social home page Coder Social logo

spark-pytest's Introduction

spark-pytest

Dockerization of a pytest environment for tests that use Spark.

CI Workflow

Example Usage Steps

See the sample code in the example/ directory and the workflow in .github/workflows/ci.yml for a bare-bones use case.

  1. Create a Dockerfile within the repo to test
FROM foundryai/spark-pytest:latest

WORKDIR /usr/src/app

ADD requirements.txt /usr/src/app
ADD requirements-dev.txt /usr/src/app

RUN pip install -r requirements.txt
RUN pip install -r requirements-dev.txt

COPY . /usr/src/app

CMD ["pytest"]

2.) Build the latest Docker image of the source code. (See docker-build in example/Makefile.)

3.) Run the tests. (See spark-pytest in example/Makefile.)

(Note: running make spark-pytest in the example/ directory will complete steps 2 and 3 at once.)


Non-Dockerized setup steps

  1. Install maven, run the brew install maven command. If you are not running on MacOS, see the manual install steps below.

Prerequisites for Local PySpark Development

Complete these steps to prepare for local Python development:

  1. Install Apache Maven from the following location: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-common/apache-maven-3.6.0-bin.tar.gz.

  2. Install the Apache Spark distribution the following location: https://aws-glue-etl-artifacts.s3.amazonaws.com/glue-1.0/spark-2.4.3-bin-hadoop2.8.tgz

  3. Export the SPARK_HOME environment variable, setting it to the root location extracted from the Spark archive. For example:

    • export SPARK_HOME=/home/$USER/spark-2.4.3-bin-spark-2.4.3-bin-hadoop2.8

Running your tests

Utility Command Description
Pytest ./bin/pytest Write and run unit tests of your Python code. The pytest module must be installed and available in the PATH. For more information, see the pytest documentation.

References

Developing and Testing ETL Scripts Locally Using the AWS Glue ETL Library


Foundry is hiring!

spark-pytest's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.