Skip to main content

spark-pager

265, You got Mail

A 'tongue-in-cheek' pager of some sorts that notifies users via email alerts on the status of Spark Jobs during/after execution

Prerequisites

  • An E-mail Address and Password

Installation

Install spark-pager with pip

  pip install spark-pager

Usage

  • Import and instantiate package with e-mail credentials and spark context
from spark_pager import Pager
from pyspark import SparkContext

sc = SparkContext()

pager = Pager(spark_context=sc, 
              username = <username>, 
              password = <password>,
              host = <host>,
              port = <port>)

## monitor the spark-context when spark-jobs are initiated 
## and notify users on its status.

pager.listener()

💥 Note: the default host is smtp.gmail.com and the default port is 587; feel free to revert to the host and port of your choosing

  • To Stop the pager; run this .::
# To stop the pager
pager.stop()

# To stop the spark-context
sc.stop()

Example-Code

## Import Packages
from spark_pager import Pager
from pyspark import SparkContext
from pyspark.sql import SparkSession

## Set Spark Configuration
sc = SparkContext()
spark = SparkSession.builder \
                    .enableHiveSupport() \
                    .getOrCreate() 

spark.sparkContext.setLogLevel("ERROR")
spark.conf.set("spark.sql.repl.eagerEval.enabled", True)

## Intialize Pager 
pager = Pager(spark_context=sc, 
              username = user@gmail.com, 
              password = password)

## Set Listener
pager.listener()

df = spark.createDataFrame([("john-doe", 34), 
                            ("jane-doe", 22)], 
                            ["name", "age"])

# Stop Pager
pager.stop()

# Stop Spark-Context
sc.stop()          

💥 Note: Job Status could either be Running, Failed or Succeeded

Now if everything goes well; you should receive a mail notification that looks kind-of like this .::

alt text

Appendix

This project is open to contributions and additions from the community

Authors

Metadata

Release files for spark-pager 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spark-pager 1.1.2
File Size Uploaded
spark_pager-1.1.2.tar.gz 8.3 kB Details

Release files / spark_pager-1.1.2.tar.gz

Download URL spark_pager-1.1.2.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82caae3a728a1b1ae421c4ae90d1c4d8ca7c80da81eb463a6807d273cf0f23e5
BLAKE2b-256 checksum
How to use checksums
a6f4c1f8b1fec0463d602c92ee86e2fa0e9b4745b1558e845b06044421a3d0e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.1.2 This release

1 release file

1.1.1

1 release file

1.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page