Skip to content

Instantly share code, notes, and snippets.

View xaviervasques's full-sized avatar

Xavier Vasques xaviervasques

View GitHub Profile
flask
flask-restful
joblib
@xaviervasques
xaviervasques / Dockerfile
Created July 13, 2021 19:54
Deploying a Machine Learning Model as an API on Red Hat OpenShift Container Platform: from Source Code in a GitHub repository with Flask, Scikit-Learn and Docker
FROM jupyter/scipy-notebook
RUN mkdir my-model
ENV MODEL_DIR=/home/jovyan/my-model
ENV MODEL_FILE=svc_model.model
COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
COPY train.py ./train.py
@xaviervasques
xaviervasques / api.py
Created July 13, 2021 19:52
Deploying a Machine Learning Model as an API on Red Hat OpenShift Container Platform: from Source Code in a GitHub repository with Flask, Scikit-Learn and Docker
import os
from sklearn import svm
from joblib import dump, load
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
from joblib import load
from flask import Flask
# Set environnment variables
@xaviervasques
xaviervasques / train.py
Created July 13, 2021 19:50
Deploying a Machine Learning Model as an API on Red Hat OpenShift Container Platform: from Source Code in a GitHub repository with Flask, Scikit-Learn and Docker
import os
from sklearn import svm
from joblib import dump, load
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
def train():
# Load directory paths for persisting model
MODEL_DIR = os.environ["MODEL_DIR"]
@xaviervasques
xaviervasques / kustomization.yaml
Created June 7, 2021 20:44
ML_Kubernetes_IBM_Cloud
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- deployment.yaml
- service_port.yaml
- service.yaml
@xaviervasques
xaviervasques / service_port.yaml
Created June 7, 2021 20:41
ML_Kubernetes_IBM_Cloud
apiVersion: v1
kind: Service
metadata:
name: nodeport
spec:
type: NodePort
ports:
- port: 32743
@xaviervasques
xaviervasques / service.yaml
Created June 7, 2021 20:39
ML_Kubernetes_IBM_Cloud
apiVersion: v1
kind: Service
metadata:
name: my-app
labels:
app: my-app
namespace: mlapi
spec:
type: LoadBalancer
ports:
@xaviervasques
xaviervasques / deployment.yaml
Created June 7, 2021 20:38
ML_Kubernetes_IBM_Cloud
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
env: qa
name: my-app
namespace: mlapi
spec:
replicas: 1 # Creating PODs for our app
@xaviervasques
xaviervasques / namespace.yaml
Created June 7, 2021 20:38
ML_Kubernetes_IBM_Cloud
apiVersion: v1
kind: Namespace
metadata:
name: mlapi
@xaviervasques
xaviervasques / Dockerfile
Created June 7, 2021 20:26
ML_Kubernetes_IBM_Cloud
FROM jupyter/scipy-notebook
RUN mkdir my-model
ENV MODEL_DIR=/home/jovyan/my-model
ENV MODEL_FILE=svc_model.model
COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
COPY train.py ./train.py