This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from airflow import DAG | |
| import os | |
| from airflow.operators.python_operator import PythonOperator | |
| from airflow.models import Variable | |
| def backup(): | |
| backup_cmd = 'mysqldump -u root -ppassword sample > "/home/shrini/backups/"sample_"$(date +"%Y%m%d_%H%M%S").sql"' | |
| os.system(backup_cmd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pykafka import KafkaClient | |
| from pymongo import MongoClient | |
| import json | |
| import sys | |
| K_client = KafkaClient(hosts='localhost:9092') | |
| topic = K_client.topics['dataets'] | |
| consumer = topic.get_simple_consumer(consumer_timeout_ms=5000) | |
| M_client = MongoClient('localhost',27017) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pykafka import KafkaClient | |
| import json | |
| import time | |
| client = KafkaClient(hosts='localhost:9092') | |
| topic = client.topics['dataets'] | |
| producer = topic.get_sync_producer() | |
| producer.produce(b'test message') | |
| for e in range(1000): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3' | |
| services: | |
| app: | |
| build: . | |
| image: flaskapp:v10 | |
| environment: | |
| - FLASK_ENV=development | |
| ports: | |
| - 5000:5000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, request, jsonify | |
| from pymongo import MongoClient | |
| app = Flask(__name__) | |
| client = MongoClient('mongodb',27017) | |
| db = client.forest | |
| collection = db.flowers | |
| @app.route('/', methods=['POST', 'GET']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:20.04 | |
| COPY . /app | |
| WORKDIR /app | |
| RUN apt-get update | |
| RUN apt-get install python3-pip -y | |
| RUN pip3 install -r requirements.txt | |
| ENTRYPOINT ["python3"] | |
| CMD ["prediction_api.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:20.04 | |
| COPY . /app | |
| WORKDIR /app | |
| RUN apt-get update | |
| RUN apt-get install python3-pip -y | |
| ENTRYPOINT ["python3"] | |
| CMD ["sample_api.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import pandas as pd | |
| import numpy | |
| from flask import Flask, render_template, request, jsonify | |
| from pandas.io.json import json_normalize | |
| #from sklearn.externals import joblib | |
| import joblib | |
| app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import pandas as pd | |
| import numpy | |
| #from sklearn.externals import joblib | |
| import joblib | |
| s = pd.read_json('./parameters.json') | |
| p = joblib.load("./model.pkl") | |
| r = p.predict(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.model_selection import train_test_split,cross_val_score | |
| #from sklearn.externals import joblib | |
| import joblib | |
| from sklearn.metrics import mean_squared_error | |
| import matplotlib.pyplot as plt | |
| from math import sqrt | |
| import os |