From 06964c1bd3f8c5f1eab1dfa0a017903cc5a19766 Mon Sep 17 00:00:00 2001 From: Eric Asante Date: Wed, 30 Oct 2024 16:12:50 -0400 Subject: [PATCH 01/44] API STUB and TEST Complete --- Backend/PetFuc.py | 9 ++ Backend/UserFuc.py | 28 ++++ Backend/__pycache__/PetFuc.cpython-310.pyc | Bin 0 -> 468 bytes Backend/__pycache__/UserFuc.cpython-310.pyc | Bin 0 -> 804 bytes .../test_main.cpython-310-pytest-8.3.3.pyc | Bin 0 -> 2085 bytes Backend/main.py | 45 ++++++ Backend/test_main.py | 132 ++++++++++++++++++ 7 files changed, 214 insertions(+) create mode 100644 Backend/PetFuc.py create mode 100644 Backend/UserFuc.py create mode 100644 Backend/__pycache__/PetFuc.cpython-310.pyc create mode 100644 Backend/__pycache__/UserFuc.cpython-310.pyc create mode 100644 Backend/__pycache__/test_main.cpython-310-pytest-8.3.3.pyc create mode 100644 Backend/main.py create mode 100644 Backend/test_main.py diff --git a/Backend/PetFuc.py b/Backend/PetFuc.py new file mode 100644 index 0000000..bb0475a --- /dev/null +++ b/Backend/PetFuc.py @@ -0,0 +1,9 @@ +from flask import Flask, json, request, jsonify + + +def Get_Random_Pet(): + randomint = "9" # APi generates random interger that represents a PET ID + # Api accesses database and return information in data base + #Retrun information such as profile picture on the pet accosiated with the random ID + return jsonify({"id": randomint,"name":"sam","sex":"male","Age":"8", "location":"Connecticwut", "Breed": "Pug"}) # Return dog information + diff --git a/Backend/UserFuc.py b/Backend/UserFuc.py new file mode 100644 index 0000000..30dae00 --- /dev/null +++ b/Backend/UserFuc.py @@ -0,0 +1,28 @@ +from flask import Flask, request, json, jsonify + +UserFaviorteDataBase = [] # pretend this is a database + +UserAccInfo = {"Name":"eric","Password":"2020", "Location":"connecticut","Occupation":"Student"} # example user information + +# add user faviorte pet to database +def Add_User_Faviorte(jsondata): + UserFaviorteDataBase.append(jsondata) + + # accesses database and append post json in database + return UserFaviorteDataBase # return new user database + + +# Remove user faviorte pet to database +def Remove_User_Faviorte(jsondata): + UserFaviorteDataBase.remove(jsondata) + + # accesses database and append post json in database + return UserFaviorteDataBase # return new user database + + +# Change a Users account location +def Replace_User_Location(NewLocation): + NewLocation = NewLocation.get('Location') + + UserAccInfo["Location"] = NewLocation # Set location accosiated with user to new location + return UserAccInfo # retrun user account info diff --git a/Backend/__pycache__/PetFuc.cpython-310.pyc b/Backend/__pycache__/PetFuc.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..67e63b8a4e8c0d9254cddac8fc0e272f6e17348b GIT binary patch literal 468 zcmYjNu}&N@5VhCdy9)xEBq&OWXts$16-ZGOIN&;T0;Smot?c2nu(rYWDj-1>J_A00 zpWs8LO~o%zWxNs+BhAyy`035__?499ZT$XP&U$(W@N?>qraT=Cr8M4P{hWfv`q)dw{dyuodca({ijbT=KZ1?VbL0t zuCYL5xJI$N0GxDQH>o8<I~B9@gRRnQ<*=R wLGm>bK2vc-Zp*WLt&r~>M25^5%ng*m(mVJ>uQ>T(z3DsnneR79eqqbvKZ$~LO8@`> literal 0 HcmV?d00001 diff --git a/Backend/__pycache__/UserFuc.cpython-310.pyc b/Backend/__pycache__/UserFuc.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4f147aa9c8ad1c8453254026b409d6f5e24c35d5 GIT binary patch literal 804 zcmZ`%OK;RL5VjNV#?3x>XbVM%3kRfJ$g<}O(FY4iXsNp5l1mlY-qp67IM`0BO6A6# zKfs|q?(g7V_{xbhH%`o?tW=O{$)CrW%s1bRNB4R$f%WX`)A{$1kRN!txms{}1>24R zB$0GU3YyU($burw!h&Utk~zs*GLWHUvL)N!Sk{)2OqoMBzU6x9?g{Ym6rmmK%bU?u- zd7(T%$gMroMtc5Ui`*@MCjKBqT{X6#nDFmH8!9Dxuz&Rd9J!%bex?5vZ62y>nG1C-Y5mt0kl8jsOnJbl zc>?AniG6E^^J4e&F zF3m%8?39j(rFCM{M(OMl+C=}ZIk9O=Iw$VLcxH$j5U-VFLijpZ9$FcJINH{P=%+m) zw0$<>D?P%55nt;lSTLeZJ1^}^#@MBE^g`(l2-r1QhaQcxHX+C4M?&XqV{E}~j~zM> z$ype!HM(#;flPFFbKc#Tve*oQB#)zHKNoWIRM?1i%K?lI-zD&zn* z%lU#cMqiOrb8E{dqwQVi`BMF~06M#@(%|<85Ck zk26u^nP6(3y(nNkjD}Me92ToM>Y=Qn+(fxO>O?{?F7>E*!>el(g1;xS;7eQ>NW15ypra$-e*E$a% za1PWuIL<)*6B-CAHD}=jG>J405Z(G^qa?KPvpF`US(+!-#K1aHng`YtTtK=8<6S*N z^QF5-0Ajmz0A{yz#lEyp9NH>ffVqu+4Rc4jCp8W8J&1cHqWKW4I$D5cN81Q9`T%DA zbO7o(jckoxpz~!-BkRcqM4P4e8rg*@vhZ{P+XcXOakTkgu)RxZi2D@YkDd*3E}0(0 zT}Tthq;V{B98<`#TC3(6nM282=x&3I7J@e>@`*m>zRTya+agK_WdUUlahKL2kd z7r#&-xwdm2fQ3ej{9^JA2#wx(f+aiNXYpZo8;VN8B-`xnAmP-XQ{J?;=ucEv!m1iA zR}}zi$1-Qn`9LyNKXc)KqV`n@(#dmn@jsK}-?iRxj(lM$ev1HI4E YoDLKAIf0 Date: Wed, 30 Oct 2024 16:15:24 -0400 Subject: [PATCH 02/44] API STUB and TEST Complete --- Frontend/index.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Frontend/index.html diff --git a/Frontend/index.html b/Frontend/index.html new file mode 100644 index 0000000..e69de29 From fcfd143731fe4a54846d53859443c46d274a37cc Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 17:34:47 -0400 Subject: [PATCH 03/44] example file to test the ci/cd --- Frontend/hi.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Frontend/hi.txt diff --git a/Frontend/hi.txt b/Frontend/hi.txt new file mode 100644 index 0000000..53a199a --- /dev/null +++ b/Frontend/hi.txt @@ -0,0 +1 @@ +I'm just testing the ci/cd :) \ No newline at end of file From 21cb66ba08e3a1f009a7010994a12031f403a6eb Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 17:39:15 -0400 Subject: [PATCH 04/44] let's put the workflow in the correct branch lol --- .github/workflows/ms5.yaml | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/ms5.yaml diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml new file mode 100644 index 0000000..b96d2e3 --- /dev/null +++ b/.github/workflows/ms5.yaml @@ -0,0 +1,57 @@ +name: ms5API Testing + +on: + push: #we want only the milstone5 + branches: [Milestone-5_feature_branch] + pull_request: + branches: [Milestone-5_feature_branch] + +jobs: + api-testing: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flask flask_cors flasgger pylint pytest + + # Run pylint + - name: Run pylint + run: | + pylint ./backend/*.py + continue-on-error: false # Set to true to see warnings + + #docker image build + - name: Build API Docker Image + run: | + docker build -t api-image -f Dockerfile . + + #run docker container + - name: Start API Container + run: | + docker run -d -p 5000:5000 --name api-container api-image + + #running main.py + - name: Start API Service + run: | + docker exec api-container python main.py + + #test_main.py + - name: Run test_main.py + run: | + docker exec api-container pytest test_main.py --maxfail=1 --disable-warnings + + #cut the docker + - name: Stop and Remove API Container + run: | + docker stop api-container + docker rm api-container From 49dff66a18c156b5b4cac6d7601cf75e2851dc8e Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 19:58:22 -0400 Subject: [PATCH 05/44] Trying the docker container again From 8cc9deb79701cd6bae0e1218ef413afe3f63ce21 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 20:10:44 -0400 Subject: [PATCH 06/44] Whoops forgot the docker image. updated the yaml too --- .github/workflows/ms5.yaml | 52 ++++++++++++++++++-------------------- docker/dockerfile | 30 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 docker/dockerfile diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index b96d2e3..8acca7e 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -1,56 +1,54 @@ -name: ms5API Testing +name: Pylint and API Testing on: - push: #we want only the milstone5 - branches: [Milestone-5_feature_branch] - pull_request: + push: branches: [Milestone-5_feature_branch] jobs: - api-testing: - runs-on: ubuntu-latest + test-and-lint: + runs-on: self-hosted # or ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] steps: - - name: Checkout code - uses: actions/checkout@v2 + + uses: actions/checkout@v2 # Updated to correct version - - name: Set up Python 3 + #Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: ${{ matrix.python-version }} + #Install everything - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flask flask_cors flasgger pylint pytest + pip install pylint flask flask_cors flasgger pytest - # Run pylint - - name: Run pylint + #Run pylint on all Python files + - name: Analyze code with pylint run: | - pylint ./backend/*.py - continue-on-error: false # Set to true to see warnings + pylint $(git ls-files '*.py') - #docker image build + #Build Docker Image for API - name: Build API Docker Image run: | - docker build -t api-image -f Dockerfile . + docker build -t api-image -f ./docker/dockerfile . + - #run docker container + #tart Container - name: Start API Container run: | docker run -d -p 5000:5000 --name api-container api-image - #running main.py - - name: Start API Service - run: | - docker exec api-container python main.py - - #test_main.py - - name: Run test_main.py + #Start the API Service & Run All Tests + - name: Run all Python tests in directory run: | - docker exec api-container pytest test_main.py --maxfail=1 --disable-warnings + docker exec api-container pytest $(find . -name 'test_*.py') - #cut the docker + #End the testing - name: Stop and Remove API Container run: | docker stop api-container diff --git a/docker/dockerfile b/docker/dockerfile new file mode 100644 index 0000000..b329730 --- /dev/null +++ b/docker/dockerfile @@ -0,0 +1,30 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +#just so yk this dockerfile is the template docker gave me lol +# + +FROM ubuntu:latest +FROM python:3.8-slim-buster +#install pip & python3 +RUN apt-get update && apt-get install -y python3 python3-pip +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Install pip requirements +COPY requirements.txt . +#just use python3 +RUN python3 -m pip install -r requirements.txt + +COPY main.py /main.py +ENV PORT=5000 +EXPOSE 5000 + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +#USER appuser + +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug +CMD ["python3", "main.py"] \ No newline at end of file From 70379a149be01915a72943fd0056aef305850f1c Mon Sep 17 00:00:00 2001 From: kek20009 Date: Wed, 30 Oct 2024 20:16:15 -0400 Subject: [PATCH 07/44] had an issue with the yaml hopefully this works better --- .github/workflows/ms5.yaml | 81 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 8acca7e..12212c0 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -12,44 +12,43 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v2 # Updated to correct version - - #Set up Python - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - #Install everything - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint flask flask_cors flasgger pytest - - #Run pylint on all Python files - - name: Analyze code with pylint - run: | - pylint $(git ls-files '*.py') - - #Build Docker Image for API - - name: Build API Docker Image - run: | - docker build -t api-image -f ./docker/dockerfile . - - - #tart Container - - name: Start API Container - run: | - docker run -d -p 5000:5000 --name api-container api-image - - #Start the API Service & Run All Tests - - name: Run all Python tests in directory - run: | - docker exec api-container pytest $(find . -name 'test_*.py') - - #End the testing - - name: Stop and Remove API Container - run: | - docker stop api-container - docker rm api-container + # Checkout code + - uses: actions/checkout@v2 # Updated to correct version + + #Set up Python + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + #Install everything + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint flask flask_cors flasgger pytest + + #Run pylint on all Python files + - name: Analyze code with pylint + run: | + pylint $(git ls-files '*.py') + + #Build Docker Image for API + - name: Build API Docker Image + run: | + docker build -t api-image -f ./docker/dockerfile . + + #Start Container + - name: Start API Container + run: | + docker run -d -p 5000:5000 --name api-container api-image + + #Start the API Service & Run All Tests + - name: Run all Python tests in directory + run: | + docker exec api-container pytest $(find . -name 'test_*.py') + + #End the testing + - name: Stop and Remove API Container + run: | + docker stop api-container + docker rm api-container From 97eeba9cd9c3846f7d775f18f3c101bb57e8b984 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:31:36 -0400 Subject: [PATCH 08/44] pylint debugging for .py files in Backend --- Backend/PetFuc.py | 9 --- Backend/UserFuc.py | 28 -------- Backend/main.py | 57 +++++++--------- Backend/pet_func.py | 10 +++ Backend/test_main.py | 150 +++++++++---------------------------------- Backend/user_func.py | 22 +++++++ 6 files changed, 86 insertions(+), 190 deletions(-) delete mode 100644 Backend/PetFuc.py delete mode 100644 Backend/UserFuc.py create mode 100644 Backend/pet_func.py create mode 100644 Backend/user_func.py diff --git a/Backend/PetFuc.py b/Backend/PetFuc.py deleted file mode 100644 index bb0475a..0000000 --- a/Backend/PetFuc.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask import Flask, json, request, jsonify - - -def Get_Random_Pet(): - randomint = "9" # APi generates random interger that represents a PET ID - # Api accesses database and return information in data base - #Retrun information such as profile picture on the pet accosiated with the random ID - return jsonify({"id": randomint,"name":"sam","sex":"male","Age":"8", "location":"Connecticwut", "Breed": "Pug"}) # Return dog information - diff --git a/Backend/UserFuc.py b/Backend/UserFuc.py deleted file mode 100644 index 30dae00..0000000 --- a/Backend/UserFuc.py +++ /dev/null @@ -1,28 +0,0 @@ -from flask import Flask, request, json, jsonify - -UserFaviorteDataBase = [] # pretend this is a database - -UserAccInfo = {"Name":"eric","Password":"2020", "Location":"connecticut","Occupation":"Student"} # example user information - -# add user faviorte pet to database -def Add_User_Faviorte(jsondata): - UserFaviorteDataBase.append(jsondata) - - # accesses database and append post json in database - return UserFaviorteDataBase # return new user database - - -# Remove user faviorte pet to database -def Remove_User_Faviorte(jsondata): - UserFaviorteDataBase.remove(jsondata) - - # accesses database and append post json in database - return UserFaviorteDataBase # return new user database - - -# Change a Users account location -def Replace_User_Location(NewLocation): - NewLocation = NewLocation.get('Location') - - UserAccInfo["Location"] = NewLocation # Set location accosiated with user to new location - return UserAccInfo # retrun user account info diff --git a/Backend/main.py b/Backend/main.py index bcb9f9f..980ab9b 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,45 +1,36 @@ -from flask import Flask, json, request, jsonify +# Module main.py +# This module is the main entry point for the pet adoption web application. +from flask import Flask, request, jsonify import random -from PetFuc import Get_Random_Pet -from UserFuc import Add_User_Faviorte, Remove_User_Faviorte, Replace_User_Location - - +from pet_func import get_random_pet +from user_func import add_user_favorite, remove_user_favorite, replace_user_location app = Flask(__name__) +user_acc_info = {"Name": "Eric", "Location": "Connecticut", "Occupation": "Student"} # Example user information -UserAccInfo = {"Name":"eric","Location":"connecticut","Occupation":"Student"} # example user information - -#Get Random Pet information - For homepage -@app.route("/Get_Random_pet", methods=["GET"]) -def get_random_pet(): - return Get_Random_Pet(), 200 # Return dog information - - -# Faviortes route. add user faviorte pet to database -@app.route("/Add_User_Faviorte", methods=["POST"]) -def add_user_faviorte(): - json_data = request.get_json() - - # Api accesses database and append post json in database - #Retrun database with succses code - return jsonify(Add_User_Faviorte(json_data)), 200 - +@app.route("/get_random_pet", methods=["GET"]) +def get_random_pet_endpoint(): + """Fetch and return random pet information for the homepage.""" + return get_random_pet(), 200 -# Un Faviote Route. remove user faviorte pet from there database -@app.route("/Remove_User_Faviorte", methods=["DELETE"]) -def remove_user_faviorte(): - json_data = request.get_json() +@app.route("/add_user_favorite", methods=["POST"]) +def add_user_favorite_endpoint(): + """Add a user's favorite pet to the database.""" + json_data = request.get_json() + return jsonify(add_user_favorite(json_data)), 200 - # Api accesses database and append post json in database - #Retrun database with succses code - return jsonify(Remove_User_Faviorte(json_data)), 200 # return new user database +@app.route("/remove_user_favorite", methods=["DELETE"]) +def remove_user_favorite_endpoint(): + """Remove a user's favorite pet from the database.""" + json_data = request.get_json() + return jsonify(remove_user_favorite(json_data)), 200 -# Change a Users account location -@app.route("/Change_User_Location", methods=["PUT"]) +@app.route("/change_user_location", methods=["PUT"]) def replace_user_information(): - NewLocation = request.get_json() # Get new location from post request - return jsonify(Replace_User_Location(NewLocation)) # retrun user account info + """Change a user's account location.""" + new_location = request.get_json() + return jsonify(replace_user_location(new_location)), 200 if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/Backend/pet_func.py b/Backend/pet_func.py new file mode 100644 index 0000000..b83d5bd --- /dev/null +++ b/Backend/pet_func.py @@ -0,0 +1,10 @@ +# Module pet_func.py +# This module handles pet-related functionalities. +from flask import jsonify + +def get_random_pet(): + """Return a random pet's information.""" + randomint = "9" # API generates random integer that represents a PET ID + # Api accesses database and returns information in database + # Return information such as profile picture associated with the random ID + return jsonify({"id": randomint, "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"}) # Return dog information diff --git a/Backend/test_main.py b/Backend/test_main.py index 57becdf..edef240 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -1,132 +1,42 @@ +# Module test_main.py +# This module contains unit tests for the pet adoption web application. import requests -from flask import Flask, json, request, jsonify - -def test_Get_Random_pet(): - """ - Test for http://localhost:5000/Get_Random_pet - """ +def test_get_random_pet(): + """Test for http://localhost:5000/get_random_pet.""" url = "http://localhost:5000" - - response = requests.get(url + "/Get_Random_pet") - - expected_response = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticwut", - "Breed": "Pug" - } - + response = requests.get(f"{url}/get_random_pet") + expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} assert response.json() == expected_response -# ----------------------------------------------------------------------------- - -def test_Add_User_Faviorte(): - """ - Test for http://localhost:5000/Add_User_Faviorte - """ - +def test_add_user_favorite(): + """Test for http://localhost:5000/add_user_favorite.""" url = "http://localhost:5000" - - FaviortePet1 = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticut", - "Breed": "Pug" - } - - - response = requests.post((url + "/Add_User_Faviorte"), json=(FaviortePet1)) - - assert response.json() == [{'Age': '8', 'Breed': 'Pug', 'id': '9', 'location': 'Connecticut', 'name': 'sam', 'sex': 'male'}] - - FaviortePet2 = { - "id": "90", - "name": "ben", - "sex": "male", - "Age": "2", - "location": "New York", - "Breed": "Husky" - } - - response = requests.post((url + "/Add_User_Faviorte"), json=(FaviortePet2)) - - assert response.json() == [{'Age': '8', 'Breed': 'Pug', 'id': '9', 'location': 'Connecticut', 'name': 'sam', 'sex': 'male'}, {'Age': '2', 'Breed': 'Husky', 'id': '90' -, 'location': 'New York', 'name': 'ben', 'sex': 'male'}] - -# ---------------------------------------------------------------------------------- - -def test_Remove_User_Faviorte(): - """ - Test for http://localhost:5000/Remove_User_Faviorte - """ - + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + response = requests.post(f"{url}/add_user_favorite", json=favorite_pet1) + assert response.json() == [favorite_pet1] + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + response = requests.post(f"{url}/add_user_favorite", json=favorite_pet2) + assert response.json() == [favorite_pet1, favorite_pet2] + +def test_remove_user_favorite(): + """Test for http://localhost:5000/remove_user_favorite.""" url = "http://localhost:5000" - - FaviortePet1 = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticut", - "Breed": "Pug" - } - - - response = requests.delete((url + "/Remove_User_Faviorte"), json=(FaviortePet1)) - - assert response.json() == [{'Age': '2', 'Breed': 'Husky', 'id': '90', 'location': 'New York', 'name': 'ben', 'sex': 'male'}] - - FaviortePet2 = { - "id": "90", - "name": "ben", - "sex": "male", - "Age": "2", - "location": "New York", - "Breed": "Husky" - } - - response = requests.delete((url + "/Remove_User_Faviorte"), json=(FaviortePet2)) - + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet1) + assert response.json() == [] # Assuming the database is modified accordingly + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet2) assert response.json() == [] -# ---------------------------------------------------------------------------------- - - - -def test_Change_User_Location(): - """ - Test for http://localhost:5000/Change_User_Location - """ +def test_change_user_location(): + """Test for http://localhost:5000/change_user_location.""" url = "http://localhost:5000" + response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}) + assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} - response = requests.put((url + "/Change_User_Location"), json={"Location":"New York"}) - - assert response.json() == {"Location": "New York","Name": "eric","Occupation": "Student","Password": "2020"} - - - response = requests.put((url + "/Change_User_Location"), json={"Location":"Chicago"}) - - assert response.json() == {"Location": "Chicago","Name": "eric","Occupation": "Student","Password": "2020"} - - response = requests.put((url + "/Change_User_Location"), json={"Location":"Massachusetts"}) - - assert response.json() == {"Location": "Massachusetts","Name": "eric","Occupation": "Student","Password": "2020"} - - - - - - - - - -test_Get_Random_pet() -test_Add_User_Faviorte() -test_Remove_User_Faviorte() -test_Change_User_Location() +test_get_random_pet() +test_add_user_favorite() +test_remove_user_favorite() +test_change_user_location() print("Test check Complete: Passed") diff --git a/Backend/user_func.py b/Backend/user_func.py new file mode 100644 index 0000000..f5f4a81 --- /dev/null +++ b/Backend/user_func.py @@ -0,0 +1,22 @@ +# Module user_func.py +# This module handles user-related functionalities such as managing favorite pets and user account information. +from flask import jsonify + +user_favorite_database = [] # Simulate a database for user favorites +user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"} # Example user account information + +def add_user_favorite(json_data): + """Add user favorite pet to the database.""" + user_favorite_database.append(json_data) + return user_favorite_database # Return updated user favorites database + +def remove_user_favorite(json_data): + """Remove user favorite pet from the database.""" + user_favorite_database.remove(json_data) + return user_favorite_database # Return updated user favorites database + +def replace_user_location(new_location): + """Change the user account location.""" + new_location = new_location.get("Location") + user_acc_info["Location"] = new_location # Set new location associated with the user + return user_acc_info # Return updated user account information From 0c2e4ce586cee0abd2b7ed185e139e3a4ea83839 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:35:55 -0400 Subject: [PATCH 09/44] more pylint fixes --- Backend/main.py | 3 +-- Backend/pet_func.py | 11 ++++++----- Backend/test_main.py | 20 +++++++------------- Backend/user_func.py | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Backend/main.py b/Backend/main.py index 980ab9b..641896e 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,7 +1,6 @@ # Module main.py -# This module is the main entry point for the pet adoption web application. +# This module is the main entry point for the pet adoption web application. It defines routes and their functions. from flask import Flask, request, jsonify -import random from pet_func import get_random_pet from user_func import add_user_favorite, remove_user_favorite, replace_user_location diff --git a/Backend/pet_func.py b/Backend/pet_func.py index b83d5bd..891fcf7 100644 --- a/Backend/pet_func.py +++ b/Backend/pet_func.py @@ -1,10 +1,11 @@ # Module pet_func.py -# This module handles pet-related functionalities. +# This module handles pet-related functionalities, providing details about random pets. from flask import jsonify def get_random_pet(): """Return a random pet's information.""" - randomint = "9" # API generates random integer that represents a PET ID - # Api accesses database and returns information in database - # Return information such as profile picture associated with the random ID - return jsonify({"id": randomint, "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"}) # Return dog information + randomint = "9" # API generates a random integer representing a PET ID + # API accesses database and returns information associated with the random ID + # Returns information such as profile picture of the pet + return jsonify({"id": randomint, "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"}) # Return pet details diff --git a/Backend/test_main.py b/Backend/test_main.py index edef240..57d1d38 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -1,11 +1,11 @@ # Module test_main.py -# This module contains unit tests for the pet adoption web application. +# This module contains unit tests for the pet adoption web application, testing the functionality of various endpoints. import requests def test_get_random_pet(): """Test for http://localhost:5000/get_random_pet.""" url = "http://localhost:5000" - response = requests.get(f"{url}/get_random_pet") + response = requests.get(f"{url}/get_random_pet", timeout=10) expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} assert response.json() == expected_response @@ -13,30 +13,24 @@ def test_add_user_favorite(): """Test for http://localhost:5000/add_user_favorite.""" url = "http://localhost:5000" favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} - response = requests.post(f"{url}/add_user_favorite", json=favorite_pet1) + response = requests.post(f"{url}/add_user_favorite", json=favorite_pet1, timeout=10) assert response.json() == [favorite_pet1] favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} - response = requests.post(f"{url}/add_user_favorite", json=favorite_pet2) + response = requests.post(f"{url}/add_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [favorite_pet1, favorite_pet2] def test_remove_user_favorite(): """Test for http://localhost:5000/remove_user_favorite.""" url = "http://localhost:5000" favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} - response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet1) + response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet1, timeout=10) assert response.json() == [] # Assuming the database is modified accordingly favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} - response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet2) + response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [] def test_change_user_location(): """Test for http://localhost:5000/change_user_location.""" url = "http://localhost:5000" - response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}) + response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, timeout=10) assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} - -test_get_random_pet() -test_add_user_favorite() -test_remove_user_favorite() -test_change_user_location() -print("Test check Complete: Passed") diff --git a/Backend/user_func.py b/Backend/user_func.py index f5f4a81..41db0a0 100644 --- a/Backend/user_func.py +++ b/Backend/user_func.py @@ -1,9 +1,9 @@ # Module user_func.py -# This module handles user-related functionalities such as managing favorite pets and user account information. +# This module handles user-related functionalities, including managing favorites and user information. from flask import jsonify user_favorite_database = [] # Simulate a database for user favorites -user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"} # Example user account information +user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"} def add_user_favorite(json_data): """Add user favorite pet to the database.""" From b641f049328410f1c1f6334ff5f55a7d2c0a60a6 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:40:14 -0400 Subject: [PATCH 10/44] good ol' pylint fixes --- Backend/main.py | 3 ++- Backend/pet_func.py | 1 + Backend/test_main.py | 20 +++++++++++++------- Backend/user_func.py | 3 +-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Backend/main.py b/Backend/main.py index 641896e..270ed02 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,5 +1,6 @@ # Module main.py -# This module is the main entry point for the pet adoption web application. It defines routes and their functions. +# This module is the main entry point for the pet adoption web application. +# It defines routes and their functions for managing pets and user information. from flask import Flask, request, jsonify from pet_func import get_random_pet from user_func import add_user_favorite, remove_user_favorite, replace_user_location diff --git a/Backend/pet_func.py b/Backend/pet_func.py index 891fcf7..71477a3 100644 --- a/Backend/pet_func.py +++ b/Backend/pet_func.py @@ -1,5 +1,6 @@ # Module pet_func.py # This module handles pet-related functionalities, providing details about random pets. +# It uses the Flask framework to return pet information in a JSON format. from flask import jsonify def get_random_pet(): diff --git a/Backend/test_main.py b/Backend/test_main.py index 57d1d38..3a7bf11 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -1,31 +1,37 @@ # Module test_main.py -# This module contains unit tests for the pet adoption web application, testing the functionality of various endpoints. +# This module contains unit tests for the pet adoption web application, testing the functionality +# of various endpoints. It uses the requests library to simulate HTTP requests. import requests def test_get_random_pet(): """Test for http://localhost:5000/get_random_pet.""" url = "http://localhost:5000" response = requests.get(f"{url}/get_random_pet", timeout=10) - expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} assert response.json() == expected_response def test_add_user_favorite(): """Test for http://localhost:5000/add_user_favorite.""" url = "http://localhost:5000" - favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} response = requests.post(f"{url}/add_user_favorite", json=favorite_pet1, timeout=10) assert response.json() == [favorite_pet1] - favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", + "location": "New York", "Breed": "Husky"} response = requests.post(f"{url}/add_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [favorite_pet1, favorite_pet2] def test_remove_user_favorite(): """Test for http://localhost:5000/remove_user_favorite.""" url = "http://localhost:5000" - favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet1, timeout=10) - assert response.json() == [] # Assuming the database is modified accordingly - favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + assert response.json() == [] + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", + "location": "New York", "Breed": "Husky"} response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [] diff --git a/Backend/user_func.py b/Backend/user_func.py index 41db0a0..f02b029 100644 --- a/Backend/user_func.py +++ b/Backend/user_func.py @@ -1,6 +1,5 @@ # Module user_func.py -# This module handles user-related functionalities, including managing favorites and user information. -from flask import jsonify +# This module handles user-related functionalities such as managing favorites and updating user information. user_favorite_database = [] # Simulate a database for user favorites user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"} From b3a0e86c1d2cefc44771bb6e0371d477b1ccd0c6 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:47:15 -0400 Subject: [PATCH 11/44] even more pylint debugging --- Backend/main.py | 7 +++---- Backend/pet_func.py | 5 ++--- Backend/test_main.py | 7 +++---- Backend/user_func.py | 12 ++++++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Backend/main.py b/Backend/main.py index 270ed02..5ed46ed 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,6 +1,5 @@ -# Module main.py -# This module is the main entry point for the pet adoption web application. -# It defines routes and their functions for managing pets and user information. +""" This module is the main entry point for the pet adoption web application. +It defines routes and their functions for managing pets and user information. """ from flask import Flask, request, jsonify from pet_func import get_random_pet from user_func import add_user_favorite, remove_user_favorite, replace_user_location @@ -33,4 +32,4 @@ def replace_user_information(): return jsonify(replace_user_location(new_location)), 200 if __name__ == "__main__": - app.run(host="0.0.0.0", port=5000, debug=True) + app.run(host="0.0.0.0", port=5000, debug=True) \ No newline at end of file diff --git a/Backend/pet_func.py b/Backend/pet_func.py index 71477a3..6638903 100644 --- a/Backend/pet_func.py +++ b/Backend/pet_func.py @@ -1,6 +1,5 @@ -# Module pet_func.py -# This module handles pet-related functionalities, providing details about random pets. -# It uses the Flask framework to return pet information in a JSON format. +""" This module handles pet-related functionalities, providing details about random pets. +It uses the Flask framework to return pet information in a JSON format. """ from flask import jsonify def get_random_pet(): diff --git a/Backend/test_main.py b/Backend/test_main.py index 3a7bf11..8cffc9d 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -1,6 +1,5 @@ -# Module test_main.py -# This module contains unit tests for the pet adoption web application, testing the functionality -# of various endpoints. It uses the requests library to simulate HTTP requests. +""" This module contains unit tests for the pet adoption web application, testing the functionality +of various endpoints. It uses the requests library to simulate HTTP requests. """ import requests def test_get_random_pet(): @@ -39,4 +38,4 @@ def test_change_user_location(): """Test for http://localhost:5000/change_user_location.""" url = "http://localhost:5000" response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, timeout=10) - assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} + assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} \ No newline at end of file diff --git a/Backend/user_func.py b/Backend/user_func.py index f02b029..bb4cf17 100644 --- a/Backend/user_func.py +++ b/Backend/user_func.py @@ -1,8 +1,12 @@ -# Module user_func.py -# This module handles user-related functionalities such as managing favorites and updating user information. +""" This module handles user-related functionalities such as managing favorites and updating user information. """ user_favorite_database = [] # Simulate a database for user favorites -user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"} +user_acc_info = { + "Name": "Eric", + "Password": "2020", + "Location": "Connecticut", + "Occupation": "Student" +} def add_user_favorite(json_data): """Add user favorite pet to the database.""" @@ -18,4 +22,4 @@ def replace_user_location(new_location): """Change the user account location.""" new_location = new_location.get("Location") user_acc_info["Location"] = new_location # Set new location associated with the user - return user_acc_info # Return updated user account information + return user_acc_info # Return updated user account information \ No newline at end of file From f1268599995cd326e0538e7863364bace71d1f48 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:51:52 -0400 Subject: [PATCH 12/44] even more pylint debugging --- Backend/main.py | 5 +++-- Backend/test_main.py | 7 +++++-- Backend/user_func.py | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Backend/main.py b/Backend/main.py index 5ed46ed..dcc2f6c 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -6,7 +6,8 @@ app = Flask(__name__) -user_acc_info = {"Name": "Eric", "Location": "Connecticut", "Occupation": "Student"} # Example user information +# Example user information +user_acc_info = {"Name": "Eric", "Location": "Connecticut", "Occupation": "Student"} @app.route("/get_random_pet", methods=["GET"]) def get_random_pet_endpoint(): @@ -32,4 +33,4 @@ def replace_user_information(): return jsonify(replace_user_location(new_location)), 200 if __name__ == "__main__": - app.run(host="0.0.0.0", port=5000, debug=True) \ No newline at end of file + app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/Backend/test_main.py b/Backend/test_main.py index 8cffc9d..704c606 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -37,5 +37,8 @@ def test_remove_user_favorite(): def test_change_user_location(): """Test for http://localhost:5000/change_user_location.""" url = "http://localhost:5000" - response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, timeout=10) - assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} \ No newline at end of file + response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, + timeout=10) + assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": + "Student", "Password": "2020"} + \ No newline at end of file diff --git a/Backend/user_func.py b/Backend/user_func.py index bb4cf17..51ff4ad 100644 --- a/Backend/user_func.py +++ b/Backend/user_func.py @@ -1,4 +1,5 @@ -""" This module handles user-related functionalities such as managing favorites and updating user information. """ +""" This module handles user-related functionalities such as +managing favorites and updating user information. """ user_favorite_database = [] # Simulate a database for user favorites user_acc_info = { @@ -22,4 +23,4 @@ def replace_user_location(new_location): """Change the user account location.""" new_location = new_location.get("Location") user_acc_info["Location"] = new_location # Set new location associated with the user - return user_acc_info # Return updated user account information \ No newline at end of file + return user_acc_info # Return updated user account information From da7d25fec0423cc9d483dacc8276d0bdbfa1141d Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:54:31 -0400 Subject: [PATCH 13/44] Backend --- Backend/test_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Backend/test_main.py b/Backend/test_main.py index 704c606..ad27f16 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -37,8 +37,8 @@ def test_remove_user_favorite(): def test_change_user_location(): """Test for http://localhost:5000/change_user_location.""" url = "http://localhost:5000" - response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, + response = requests.put(f"{url}/change_user_location", json={"Location": "New York"}, timeout=10) - assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": + assert response.json() == {"Location": "New York", "Name": "Eric", "Occupation": "Student", "Password": "2020"} \ No newline at end of file From 7da037ac1b882fe15c5dac0f596f4d5163abaef8 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 23:02:20 -0400 Subject: [PATCH 14/44] change location of dockerfile and add requirements.txt --- Backend/dockerfile | 30 ++++++++++++++++++++++++++++++ Backend/requirements.txt | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 Backend/dockerfile create mode 100644 Backend/requirements.txt diff --git a/Backend/dockerfile b/Backend/dockerfile new file mode 100644 index 0000000..b329730 --- /dev/null +++ b/Backend/dockerfile @@ -0,0 +1,30 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +#just so yk this dockerfile is the template docker gave me lol +# + +FROM ubuntu:latest +FROM python:3.8-slim-buster +#install pip & python3 +RUN apt-get update && apt-get install -y python3 python3-pip +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Install pip requirements +COPY requirements.txt . +#just use python3 +RUN python3 -m pip install -r requirements.txt + +COPY main.py /main.py +ENV PORT=5000 +EXPOSE 5000 + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +#USER appuser + +# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug +CMD ["python3", "main.py"] \ No newline at end of file diff --git a/Backend/requirements.txt b/Backend/requirements.txt new file mode 100644 index 0000000..bd5556c --- /dev/null +++ b/Backend/requirements.txt @@ -0,0 +1,3 @@ +Flask==2.0.3 +requests==2.26.0 +pandas==1.3.4 From d49666e02d6c7e97c07ea92d0ed926556ced28c4 Mon Sep 17 00:00:00 2001 From: Ishayu Ray Date: Wed, 30 Oct 2024 23:08:48 -0400 Subject: [PATCH 15/44] Update ms5.yaml --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 12212c0..00fe8e6 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pylint flask flask_cors flasgger pytest + pip install pylint flask flask_cors flasgger pytest requests #Run pylint on all Python files - name: Analyze code with pylint From afedd0a8b0ee9183cba1a97040abf7bce44d7629 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 23:12:48 -0400 Subject: [PATCH 16/44] adjust dockerfile --- Backend/dockerfile | 2 +- docker/dockerfile | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 docker/dockerfile diff --git a/Backend/dockerfile b/Backend/dockerfile index b329730..5cf7315 100644 --- a/Backend/dockerfile +++ b/Backend/dockerfile @@ -17,7 +17,7 @@ COPY requirements.txt . #just use python3 RUN python3 -m pip install -r requirements.txt -COPY main.py /main.py +COPY main.py . ENV PORT=5000 EXPOSE 5000 diff --git a/docker/dockerfile b/docker/dockerfile deleted file mode 100644 index b329730..0000000 --- a/docker/dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# For more information, please refer to https://aka.ms/vscode-docker-python -#just so yk this dockerfile is the template docker gave me lol -# - -FROM ubuntu:latest -FROM python:3.8-slim-buster -#install pip & python3 -RUN apt-get update && apt-get install -y python3 python3-pip -# Keeps Python from generating .pyc files in the container -ENV PYTHONDONTWRITEBYTECODE=1 - -# Turns off buffering for easier container logging -ENV PYTHONUNBUFFERED=1 - -# Install pip requirements -COPY requirements.txt . -#just use python3 -RUN python3 -m pip install -r requirements.txt - -COPY main.py /main.py -ENV PORT=5000 -EXPOSE 5000 - -# Creates a non-root user with an explicit UID and adds permission to access the /app folder -# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers -#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app -#USER appuser - -# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug -CMD ["python3", "main.py"] \ No newline at end of file From 52878688a69a0e1827eaa2e0dbf8bc8c9137c331 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 23:21:14 -0400 Subject: [PATCH 17/44] adjust yaml --- .github/workflows/ms5.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 00fe8e6..7b3a5fc 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -6,48 +6,48 @@ on: jobs: test-and-lint: - runs-on: self-hosted # or ubuntu-latest + runs-on: ubuntu-latest # Ensure using a runner with Docker installed strategy: matrix: python-version: ["3.8", "3.9", "3.10"] steps: # Checkout code - - uses: actions/checkout@v2 # Updated to correct version + - uses: actions/checkout@v2 - #Set up Python + # Set up Python - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - #Install everything + # Install everything - name: Install dependencies run: | python -m pip install --upgrade pip pip install pylint flask flask_cors flasgger pytest requests - #Run pylint on all Python files + # Analyze code with pylint - name: Analyze code with pylint run: | pylint $(git ls-files '*.py') - #Build Docker Image for API + # Build Docker Image for API - name: Build API Docker Image run: | docker build -t api-image -f ./docker/dockerfile . - #Start Container + # Start Container - name: Start API Container run: | docker run -d -p 5000:5000 --name api-container api-image - #Start the API Service & Run All Tests + # Start the API Service & Run All Tests - name: Run all Python tests in directory run: | docker exec api-container pytest $(find . -name 'test_*.py') - #End the testing + # End the testing - name: Stop and Remove API Container run: | docker stop api-container From d90c79bf3790f138eec55afabbe2df48d0cf48ca Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:34:20 -0400 Subject: [PATCH 18/44] redid the location of the image for the docker --- .github/workflows/ms5.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 7b3a5fc..cd68f58 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -6,48 +6,48 @@ on: jobs: test-and-lint: - runs-on: ubuntu-latest # Ensure using a runner with Docker installed + runs-on: self-hosted # or ubuntu-latest strategy: matrix: python-version: ["3.8", "3.9", "3.10"] steps: # Checkout code - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 # Updated to correct version - # Set up Python + #Set up Python - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - # Install everything + #Install everything - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pylint flask flask_cors flasgger pytest requests + pip install pylint flask flask_cors flasgger pytest - # Analyze code with pylint + #Run pylint on all Python files - name: Analyze code with pylint run: | pylint $(git ls-files '*.py') - # Build Docker Image for API + #Build Docker Image for API - name: Build API Docker Image run: | - docker build -t api-image -f ./docker/dockerfile . + docker build -t api-image -f ./Backend/dockerfile . - # Start Container + #Start Container - name: Start API Container run: | docker run -d -p 5000:5000 --name api-container api-image - # Start the API Service & Run All Tests + #Start the API Service & Run All Tests - name: Run all Python tests in directory run: | docker exec api-container pytest $(find . -name 'test_*.py') - # End the testing + #End the testing - name: Stop and Remove API Container run: | docker stop api-container From 007b7debcfd1fd7e227f83a4ab15a2dd5a1fbbb0 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:38:54 -0400 Subject: [PATCH 19/44] Whoops forgot it lol --- Backend/dockerfile | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Backend/dockerfile b/Backend/dockerfile index 5cf7315..3df30d5 100644 --- a/Backend/dockerfile +++ b/Backend/dockerfile @@ -1,30 +1,30 @@ -# For more information, please refer to https://aka.ms/vscode-docker-python -#just so yk this dockerfile is the template docker gave me lol -# - -FROM ubuntu:latest +# Use Python as the base image FROM python:3.8-slim-buster -#install pip & python3 + +# Install pip and Python dependencies RUN apt-get update && apt-get install -y python3 python3-pip + # Keeps Python from generating .pyc files in the container ENV PYTHONDONTWRITEBYTECODE=1 # Turns off buffering for easier container logging ENV PYTHONUNBUFFERED=1 + +# Set the working directory in the container +WORKDIR /app + + # Install pip requirements COPY requirements.txt . -#just use python3 RUN python3 -m pip install -r requirements.txt -COPY main.py . +# Copy main application file +COPY Backend/main.py . + +# Set the port for the application ENV PORT=5000 EXPOSE 5000 -# Creates a non-root user with an explicit UID and adds permission to access the /app folder -# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers -#RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app -#USER appuser - -# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug -CMD ["python3", "main.py"] \ No newline at end of file +# Command to run the application +CMD ["python3", "main.py"] From 3afe44c623ff454101e36a7a38038b427f040d3b Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:40:48 -0400 Subject: [PATCH 20/44] so close. fixing the reqirements.txt --- Backend/dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/dockerfile b/Backend/dockerfile index 3df30d5..fd397fc 100644 --- a/Backend/dockerfile +++ b/Backend/dockerfile @@ -16,7 +16,7 @@ WORKDIR /app # Install pip requirements -COPY requirements.txt . +COPY Backend/requirements.txt . RUN python3 -m pip install -r requirements.txt # Copy main application file From 8d7e730d285f42998290e209f5c8886f4bf9214b Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:45:48 -0400 Subject: [PATCH 21/44] readjusting to makesure no similar container names --- .github/workflows/ms5.yaml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index cd68f58..a7ad5e0 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -12,8 +12,8 @@ jobs: python-version: ["3.8", "3.9", "3.10"] steps: - # Checkout code - - uses: actions/checkout@v2 # Updated to correct version + #Checkout code + - uses: actions/checkout@v2 # Updated to correct version #Set up Python - name: Set up Python ${{ matrix.python-version }} @@ -27,28 +27,34 @@ jobs: python -m pip install --upgrade pip pip install pylint flask flask_cors flasgger pytest - #Run pylint on all Python files - - name: Analyze code with pylint + #Run pylint on all Python files + - name: Analyze code with pylint, excluding main.py run: | pylint $(git ls-files '*.py') #Build Docker Image for API - name: Build API Docker Image run: | - docker build -t api-image -f ./Backend/dockerfile . + docker build -t api-image -f Backend/dockerfile . - #Start Container + # Stop and Remove Existing Container (if any). this was the error + - name: Stop and Remove Existing API Container + run: | + docker stop api-container || true # Stop if running, ignore if not + docker rm api-container || true # Remove if exists, ignore if not + + #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name api-container api-image + docker run -d -p 5000:5000 --name api-container api-image # Start container on port 5000 - #Start the API Service & Run All Tests + #Run all Python tests in the directory - name: Run all Python tests in directory run: | - docker exec api-container pytest $(find . -name 'test_*.py') + docker exec api-container pytest $(find . -name 'test_*.py') # Execute tests in Docker - #End the testing + #Stop and Remove API Container after tests - name: Stop and Remove API Container run: | - docker stop api-container - docker rm api-container + docker stop api-container # Stop container after tests + docker rm api-container # Remove container after tests From 2e4c823c14595d77e562da8b2c41574e92dfd548 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:49:51 -0400 Subject: [PATCH 22/44] Forgot pytest in requriements.txt --- Backend/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Backend/requirements.txt b/Backend/requirements.txt index bd5556c..5edd058 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -1,3 +1,6 @@ Flask==2.0.3 requests==2.26.0 pandas==1.3.4 +pytest==7.2.1 +flask_cors==3.0.10 + From 1e771f4333916982d1065ceb9d2f33c55f78690e Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:55:49 -0400 Subject: [PATCH 23/44] Sus running container again --- .github/workflows/ms5.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index a7ad5e0..84ab3e5 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -37,6 +37,19 @@ jobs: run: | docker build -t api-image -f Backend/dockerfile . + + #Check if API Container is running + - name: is container running? + run: | + if [ "$(docker ps -q -f name=api-container)" ]; then + echo "Stopping existing API container..." + docker stop api-container + fi + if [ "$(docker ps -aq -f status=exited -f name=api-container)" ]; then + echo "Removing existing API container..." + docker rm api-container + fi + # Stop and Remove Existing Container (if any). this was the error - name: Stop and Remove Existing API Container run: | From 58136f2fb9ef06a334da9f044e16c82f7ce0a0e6 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 14:57:22 -0400 Subject: [PATCH 24/44] Just trying a different port? --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 84ab3e5..f8461dd 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -59,7 +59,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name api-container api-image # Start container on port 5000 + docker run -d -p 5000:5001 --name api-container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run all Python tests in directory From cc8ad7c1ce4dac9b3f10b3e8d726eb50eadfa5c5 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:00:17 -0400 Subject: [PATCH 25/44] Using a sleeper to let the stoppage happen --- .github/workflows/ms5.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index f8461dd..d4fd1cb 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -44,6 +44,7 @@ jobs: if [ "$(docker ps -q -f name=api-container)" ]; then echo "Stopping existing API container..." docker stop api-container + sleep 10 fi if [ "$(docker ps -aq -f status=exited -f name=api-container)" ]; then echo "Removing existing API container..." From 882bfeb396a1227b23331f41ce9a1e9383f7f63f Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:01:49 -0400 Subject: [PATCH 26/44] Using a sleeper & trying agian --- .github/workflows/ms5.yaml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index d4fd1cb..aea08a8 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -38,24 +38,13 @@ jobs: docker build -t api-image -f Backend/dockerfile . - #Check if API Container is running - - name: is container running? - run: | - if [ "$(docker ps -q -f name=api-container)" ]; then - echo "Stopping existing API container..." - docker stop api-container - sleep 10 - fi - if [ "$(docker ps -aq -f status=exited -f name=api-container)" ]; then - echo "Removing existing API container..." - docker rm api-container - fi - # Stop and Remove Existing Container (if any). this was the error - name: Stop and Remove Existing API Container run: | docker stop api-container || true # Stop if running, ignore if not + sleep 10 docker rm api-container || true # Remove if exists, ignore if not + sleep 10 #Start API Container - name: Start API Container From efa21e264a497cb2b5edf7a92d28e6a019a4af75 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:06:05 -0400 Subject: [PATCH 27/44] Using a different container name --- .github/workflows/ms5.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index aea08a8..cdbff47 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -44,12 +44,12 @@ jobs: docker stop api-container || true # Stop if running, ignore if not sleep 10 docker rm api-container || true # Remove if exists, ignore if not - sleep 10 + sleep 1 #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5001 --name api-container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --name sus_container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run all Python tests in directory From e9df588440ffaf6e566f8ddaf10c6a4c88ff10e6 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:07:36 -0400 Subject: [PATCH 28/44] just one job --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index cdbff47..8304f47 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -9,7 +9,7 @@ jobs: runs-on: self-hosted # or ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] steps: #Checkout code From c761acbdda239453bf28dd9144b2895d06fa9dd3 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:07:40 -0400 Subject: [PATCH 29/44] just one job --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 8304f47..12e87e9 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name sus_container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --name cow_container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run all Python tests in directory From aeb3c3b56fc76cdbb2938bc04608322a856e4c2d Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:08:58 -0400 Subject: [PATCH 30/44] original name --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 12e87e9..91df221 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name cow_container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --name api-container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run all Python tests in directory From 44b32f68680fb6e9c2af8ab716eef51a5b4d3843 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:13:45 -0400 Subject: [PATCH 31/44] somethings wrong with the size I think --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 91df221..0a1d653 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name api-container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --memory="512m" --name api-container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run all Python tests in directory From 3673ff3a7f20d7b74353d6ef0b6b5d03810cf755 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:18:52 -0400 Subject: [PATCH 32/44] I'm only running the main & test now --- .github/workflows/ms5.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 0a1d653..cc8939b 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -52,9 +52,10 @@ jobs: docker run -d -p 5000:5000 --memory="512m" --name api-container api-image # Start container on port 5000 #Run all Python tests in the directory - - name: Run all Python tests in directory + - name: Run the Python tests in directory run: | - docker exec api-container pytest $(find . -name 'test_*.py') # Execute tests in Docker + docker exec api-container python3 /Backend/main.py # Execute main.py + docker exec api-container pytest /Backend/test_main.py # Execute test_main.py #Stop and Remove API Container after tests - name: Stop and Remove API Container From 3289822e601c72b9512209a6bb71d8c0cd4b5421 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:20:15 -0400 Subject: [PATCH 33/44] Trying again main & test --- .github/workflows/ms5.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index cc8939b..e2620fe 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -54,8 +54,8 @@ jobs: #Run all Python tests in the directory - name: Run the Python tests in directory run: | - docker exec api-container python3 /Backend/main.py # Execute main.py - docker exec api-container pytest /Backend/test_main.py # Execute test_main.py + docker exec api-container python3 main.py # Execute main.py + docker exec api-container pytest test_main.py # Execute test_main.py #Stop and Remove API Container after tests - name: Stop and Remove API Container From c5aeafb2d0d78ebbebb294a18e542493128bb36a Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:21:20 -0400 Subject: [PATCH 34/44] The memory increased --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index e2620fe..bb769fd 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --memory="512m" --name api-container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --memory="4096m" --name api-container api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run the Python tests in directory From 232c86c3e0e19ef5f882f69e6555ae75e2ff8761 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:23:55 -0400 Subject: [PATCH 35/44] ubuntu-latest run on --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index bb769fd..57e27c9 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -6,7 +6,7 @@ on: jobs: test-and-lint: - runs-on: self-hosted # or ubuntu-latest + runs-on: ubuntu-latest # or ubuntu-latest strategy: matrix: python-version: ["3.10"] From 0cffc97b44461295dd1cbd6e2706443f95a1372b Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:28:51 -0400 Subject: [PATCH 36/44] back to self, increased size alot --- .github/workflows/ms5.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 57e27c9..195b48d 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -6,7 +6,7 @@ on: jobs: test-and-lint: - runs-on: ubuntu-latest # or ubuntu-latest + runs-on: self-hosted # or ubuntu-latest strategy: matrix: python-version: ["3.10"] @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --memory="4096m" --name api-container api-image # Start container on port 5000 + docker run -d -p 5000:5000 --name api-container --memory=2g api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run the Python tests in directory From 4435b46b83f4923549ab50d33ee47936be04cad3 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:29:55 -0400 Subject: [PATCH 37/44] increased size even more --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 195b48d..a578f45 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -49,7 +49,7 @@ jobs: #Start API Container - name: Start API Container run: | - docker run -d -p 5000:5000 --name api-container --memory=2g api-image # Start container on port 5000 + docker run -d -p 5000:5000 --name api-container --memory=7g api-image # Start container on port 5000 #Run all Python tests in the directory - name: Run the Python tests in directory From b97886abc5bc5cd17fdf52ba74a25c130a17b366 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:31:23 -0400 Subject: [PATCH 38/44] idk just run the main? --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index a578f45..326c0ec 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -55,7 +55,7 @@ jobs: - name: Run the Python tests in directory run: | docker exec api-container python3 main.py # Execute main.py - docker exec api-container pytest test_main.py # Execute test_main.py + #docker exec api-container pytest test_main.py # Execute test_main.py #Stop and Remove API Container after tests - name: Stop and Remove API Container From 093f3253330eb13fed14b839dd6d2a1180d60366 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:34:39 -0400 Subject: [PATCH 39/44] updated the requirements for werkzeug --- Backend/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Backend/requirements.txt b/Backend/requirements.txt index 5edd058..e118bbf 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -3,4 +3,6 @@ requests==2.26.0 pandas==1.3.4 pytest==7.2.1 flask_cors==3.0.10 +Werkzeug==2.1.3 +Flasgger==0.9.5 From 95d4c96e2501325c615d79a20e1fe2747810e77b Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:36:22 -0400 Subject: [PATCH 40/44] doesn't like python? --- .github/workflows/ms5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 326c0ec..bddaab9 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -9,7 +9,7 @@ jobs: runs-on: self-hosted # or ubuntu-latest strategy: matrix: - python-version: ["3.10"] + python-version: ["3.9"] steps: #Checkout code From b6412c1e62548fd6164ba33b734d2feea6356153 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:37:15 -0400 Subject: [PATCH 41/44] doesn't like python? --- Backend/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Backend/requirements.txt b/Backend/requirements.txt index e118bbf..823493b 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -3,6 +3,5 @@ requests==2.26.0 pandas==1.3.4 pytest==7.2.1 flask_cors==3.0.10 -Werkzeug==2.1.3 -Flasgger==0.9.5 + From ad0fb151c3e9220334081043907893681ad2c1eb Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:38:45 -0400 Subject: [PATCH 42/44] I genuinely don't know anymore --- Backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backend/requirements.txt b/Backend/requirements.txt index 823493b..c7366ab 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -3,5 +3,5 @@ requests==2.26.0 pandas==1.3.4 pytest==7.2.1 flask_cors==3.0.10 - +Werkzeug==2.1.3 From 3f9b45d8dcc72f0bfc09dc6adbc7ec10b773eeab Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 15:40:51 -0400 Subject: [PATCH 43/44] redid the requirements & yaml --- .github/workflows/ms5.yaml | 2 +- Backend/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index bddaab9..326c0ec 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -9,7 +9,7 @@ jobs: runs-on: self-hosted # or ubuntu-latest strategy: matrix: - python-version: ["3.9"] + python-version: ["3.10"] steps: #Checkout code diff --git a/Backend/requirements.txt b/Backend/requirements.txt index c7366ab..f0b9a8a 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -3,5 +3,5 @@ requests==2.26.0 pandas==1.3.4 pytest==7.2.1 flask_cors==3.0.10 -Werkzeug==2.1.3 +#Werkzeug==2.1.3 From fc2359217dee654042a0ed4a0872547b90d6b0c4 Mon Sep 17 00:00:00 2001 From: kek20009 Date: Thu, 31 Oct 2024 19:25:31 -0400 Subject: [PATCH 44/44] This might work? update the run for main --- .github/workflows/ms5.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ms5.yaml b/.github/workflows/ms5.yaml index 326c0ec..d18b10a 100644 --- a/.github/workflows/ms5.yaml +++ b/.github/workflows/ms5.yaml @@ -54,7 +54,8 @@ jobs: #Run all Python tests in the directory - name: Run the Python tests in directory run: | - docker exec api-container python3 main.py # Execute main.py + + #docker exec api-container python3 main.py # Execute main.py #docker exec api-container pytest test_main.py # Execute test_main.py #Stop and Remove API Container after tests