ML/DL Automation with Jenkins, Git&GitHub and Docker

Aman Pasi
4 min readMay 30, 2020

--

This task shows “How you can automate your ML/DL projects”

Task Details :-
#ML-DevOps integration

For the code used in this task , use this GitHub link :-
https://github.com/apt-x4869/MLOPsT3.git

1. Create container image that’s has Python3 and Keras or numpy installed using dockerfile. When we launch this image, it should automatically starts train the model in the container.

*Create a job chain of job1, job2, job3, job4 and job5 using build pipeline plugin in Jenkins

2. Job1 : Pull the Github repo automatically when some developers push repo to Github.

3. Job2 : By looking at the code or program file, Jenkins should automatically start the respective machine learning software installed interpreter install image container to deploy code and start training( eg. If code uses CNN, then Jenkins should start the container that has already installed all the softwares required for the cnn processing).

4. Job3 : Train your model and predict accuracy or metrics.

5. Job4 : if metrics accuracy is less than 80% , then tweak the machine learning model architecture.

6. Job5: Retrain the model or notify that the best model is being created

7. Create One extra job job6 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again from where the last trained model left

Step 1 : Docker Image using Dockerfile

For Deep Learning Docker Image I have used CentOS as base image and installed all the libraries and dependencies using Dockerfile. Similar Image for ML project you can find it in GitHub link.

Step 2 : Job1 — Pulling GitHub Repository using Jenkins

As you can see I have created a job in jenkins to download and copy the source code from GutHub repository to /mlopsT3 directory.

Step 3 : Job 2 — By Looking at code run container for Deep Learning or Machine Learning Model

The Job 2 would look like this which can launch two types of container 1) Deep learning(keras) and 2) Machine Learning (sklearn).This job will be triggered right after the first job i.e. after the data is copied.

Step 4: Job3 — This will execute our code inside the container which we launced in previous job

As you can see depending upon the Python Code it runs the specified ML/DL code in that container. I have also putted a trigger by remote for our next job.

Step 5: Job 4 — Check the accuracy and Tune the HyperParameter

It run a python code tweak.py which checks for the accuracy and tweaks/change HyperParameters for better result. This is job runs/build automatically after Job3 stable-build.

This will also trigger the task 3 again after tweaking the HyperParameters which are stored in hPara.csv files and

6. Job5: Notify that the best model is being created

Here I have used python script to send email but you also use Jeknkins Email Notification and for that you can refer to my previous post https://link.medium.com/E0TOXrRWC7

This job will be remotely triggered by Job 4. If the accuracy of the model is required criteria then this job will be triggered by Job 4 to mail that the model has been trained. For mailing I have made a script in python to mail.

Step 7 : Job 6 — This job continuously checks if the container is running or not. If the container is not running then it relaunches the container for us.

This job is build periodically (every one minute).
It check the if desired container is running or not using docker ps command.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Aman Pasi
Aman Pasi

No responses yet

Write a response