-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uploading some test files, not necessarily final
- Loading branch information
1 parent
66d344c
commit 7c32a10
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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" |
This file contains 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
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))) |