Skip to content

Commit

Permalink
uploading some test files, not necessarily final
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhanush123 committed Feb 25, 2020
1 parent 66d344c commit 7c32a10
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
# build the container image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/shakti0:$COMMIT_SHA", "."]
# push the container image to Container Registry
- name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/shakti0:$COMMIT_SHA"]
# Deploy container image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args:
- "run"
- "deploy"
- "shakti0"
- "--image"
- "gcr.io/$PROJECT_ID/shakti0:$COMMIT_SHA"
- "--region"
- "us-east1"
- "--platform"
- "managed"
images:
- "gcr.io/$PROJECT_ID/shakti0:$COMMIT_SHA"
33 changes: 33 additions & 0 deletions test1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os

from flask import Flask, jsonify
from gcp_utils.googlebucket import gcs_download_file
from joblib import load

app = Flask(__name__)

model = None


@app.before_request
def load_resources():
'''Flask template is currently only for scikit-learn models'''
if not model:
model_path = gcs_download_file(os.environ.get("MODEL_PATH"))
model = load(model_path)


def transform_data(input_data):
# no transform by default
return input_data


@app.route('/')
def predict(input_data):
transformed_data = transform_data(input_data)
prediction = model.predict(transformed_data)
return jsonify({"prediction": prediction})


if __name__ == "__main__":
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))

0 comments on commit 7c32a10

Please sign in to comment.