Scheduling Spark notebooks with Gitlab CI/CD

Dear SWAN users,

We noticed interest on productionizing Spark notebooks for analytics pipelines, versioned with git.

The proposed pipeline will consist of prototyping a Spark job in SWAN in interactive mode, committing to git (e.g. GitLab) repository shared across many team members, and designing Gitlab CI/CD pipelines that would submit and manage your Spark Notebook jobs in a batch mode.

For our internal purposes at IT-DB-SAS, we daily schedule set of Spark Notebooks to check LCG software, cluster reliability and Hadoop client configuration compatibility with a set of notebooks. The example repository can be found here (you need to be logged in to CERN GitLab).

In the above example, we developed Python script that converts SWAN .ipynb file into set of Spark configurations and .py code.

You can use these examples as a reference implementation for your own pipelines:

Next step is to create .gitlab-ci.yml that would setup your pipelines. The example analytix submission would be defined as follows:

> .gitlab-ci.yml
    - cvmfs
    name: ${CI_REGISTRY_IMAGE}:latest
    entrypoint: ["/bin/sh", "-c"]
    # authenticate with kerberos for yarn cluster
    - klist
    # submit notebook
    - python ./analytix-example/ --cvmfs-lcg-view LCG_96 --cvmfs-lcg-platform x86_64-centos7-gcc8-opt --appid prod-lcg96-hostmetrics-notebook-$RANDOM --ipynb ./analytix-example/analytix-hostmetrics-example.ipynb --hadoop-confext /cvmfs/

You can configure some advanced specifics of your pipelines in Gitlab CI/CD interface (please check for more info). One example are some environment variables used to authenticate the submitting user. In our case, env KERB_ACCOUNT_USERNAME represents the submitting user as a service account hconfig@CERN.CH and service account password.

The example for a full pipeline (that includes running many notebooks, checking the return code, and triggering alert to Mattermost channel) can be found here

Using Git and GitLab pipelines could be very interesting solution to productionize your Spark applications that are fully controlled and orchestrated by git.

Please contact for consulting regarding setting up such a production pipelines