Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
pytest

codecoverage:
runs-on: ubuntu-latest # choose the OS for running the action
runs-on: windows-latest # choose the OS for running the action
strategy:
matrix:
python: ['3.7', '3.8', '3.9']
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Dev-Sec-Ops Demo/Assignment

[![codecov](https://codecov.io/gh/PGCSEDS-IIITH/devsecops-iris/branch/master/graph/badge.svg?token=EILEH8L7R5)](https://codecov.io/gh/PGCSEDS-IIITH/devsecops-iris)
[![codecov][![codecov](https://codecov.io/gh/swathi14-5/devsecops-iris/branch/master/graph/badge.svg?token=BI069NHK2A)](https://codecov.io/gh/swathi14-5/devsecops-iris)

This repository contains code which demonstrates Dev-Sec-Ops using a `FastAPI` application which predicts the flower class using the IRIS dataset (https://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html)

## Running Instructions
- Create a fork of the repo using the `fork` button.
- Clone your fork using `git clone https://www.github.com/<your-username>/mlops-iris.git`
- Clone your fork using `git clone https://www.github.com/swathi14-5/mlops-iris.git`
- Install dependencies using `pip3 install -r requirements.txt`
- Run application using `python3 main.py`
- Run tests using `pytest`
Expand All @@ -25,4 +25,4 @@ This repository contains code which demonstrates Dev-Sec-Ops using a `FastAPI` a
- Make a visualisation for sarif report using any tool. upload screenshot, image, html or pdf. Add it to the reports/ folder.

## Submission
- Link to github repository as a comment on the submission (olympus portal). [uploading .txt is optional]
- Link to github repository as a comment on the submission (olympus portal). [uploading .txt is optional]
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
from ml_utils import load_model, predict, retrain
from ml_utils import load_model, predict #retrain
from typing import List

# defining the main app
Expand Down Expand Up @@ -49,13 +49,13 @@ def predict_flower(query_data: QueryIn):
return output


@app.post("/feedback_loop", status_code=200)
#@app.post("/feedback_loop", status_code=200)
# Route to further train the model based on user input in form of feedback loop
# Payload: FeedbackIn containing the parameters and correct flower class
# Response: Dict with detail confirming success (200)
def feedback_loop(data: List[FeedbackIn]):
retrain(data)
return {"detail": "Feedback loop successful"}
#def feedback_loop(data: List[FeedbackIn]):
#retrain(data)
#return {"detail": "Feedback loop successful"}


# Main function to start the app when main.py is called
Expand Down
2 changes: 2 additions & 0 deletions ml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ def predict(query_data):


# function to retrain the model as part of the feedback loop
"""
def retrain(data):
# pull out the relevant X and y from the FeedbackIn object
X = [list(d.dict().values())[:-1] for d in data]
y = [r_classes[d.flower_class] for d in data]

# fit the classifier again based on the new data obtained
clf.fit(X, y)
"""
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pytest==6.2.4
requests==2.25.1
pandas==1.2.4
scikit-learn==0.24.1
pytest-cov
3,819 changes: 3,819 additions & 0 deletions results.sarif

Large diffs are not rendered by default.