Skip to content

Commit

Permalink
[MyApps][ynab-010][feature: Upgrading to python3.10 and restart Docker]
Browse files Browse the repository at this point in the history
	modified:   app/Dockerfile
	modified:   app/docker-compose.yml
	modified:   app/miscellaneous/key_bash_commands.txt
	modified:   app/requirements.txt
	modified:   app/root.py
	modified:   app/utils/budget_import.py
  • Loading branch information
KamyNz committed Oct 13, 2023
1 parent c39cf0b commit 4443c3e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
20 changes: 8 additions & 12 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
FROM python:3.8.10-slim
FROM python:3.10-slim

RUN apt-get update
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& apt-get clean

WORKDIR /app

COPY /requirements.txt /app/requirements.txt

RUN pip install --upgrade pip
RUN pip3 install --upgrade pip

RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
RUN pip install --no-cache-dir --index-url=https://pypi.org/simple --upgrade -r /app/requirements.txt

COPY /data ./data

COPY /logging/config.yaml ./logging/config.yaml
COPY /utils ./utils

COPY /routes ./routes

COPY /resources ./resources

COPY /root.py /app/root.py

COPY /main.py /app/main.py

CMD ["uvicorn","main:app","--host","0.0.0.0","--port","80"]



6 changes: 4 additions & 2 deletions app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: '3'
services:
fast-api-ynab:
volumes:
- /Users/camilamv/BudgetYNABProgram/app/data/:/app/data/
build: ./
restart: unless-stopped
ports:
- "8225:80"
volumes:
- /Users/camilamv/BudgetYNABProgram/app/data/:/app/data/

7 changes: 7 additions & 0 deletions app/miscellaneous/key_bash_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ find . -type <f,d> -name <"name_pattern"> | xargs rm -r

# Example
find . -type d -name '__pycache__'

###---------------------------------------------------
## To remove conda env
## Link info: <>
###---------------------------------------------------

conda env list | awk '$1 ~ /^poc-/ {print $1}' | xargs -I {} conda env remove -n {}
15 changes: 9 additions & 6 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
chardet==4.0.0
fastapi==0.89.1
numpy==1.22.2
pandas==1.4.1
pydantic==1.9.1
chardet
fastapi
numpy
pandas
pydantic
starlette
uvicorn==0.17.6
uvicorn
python-multipart
pipreqs
pytest
pyyaml
1 change: 1 addition & 0 deletions app/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

DIR_ROOT=os.path.dirname(os.path.abspath(__file__))
DIR_DATA="{0}{1}data{1}".format(DIR_ROOT, os.sep)
DIR_LOG="{0}{1}logging{1}".format(DIR_ROOT, os.sep)
DIR_DATA_RAW="{0}{1}raw{1}".format(DIR_DATA, os.sep)
DIR_DATA_STAGE="{0}{1}stage{1}".format(DIR_DATA, os.sep)
DIR_DATA_ANALYTICS="{0}{1}analytics{1}".format(DIR_DATA, os.sep)
Expand Down
33 changes: 18 additions & 15 deletions app/utils/budget_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@
# Processing files
import re
import chardet
from pathlib import Path

ROOT_PATH = os.path.dirname(
(os.sep).join(os.path.abspath(__file__).split(os.sep)))
sys.path.insert(1, ROOT_PATH)
import root

#Logger configuration
with open("./logging/config.yaml",'r') as f:
config = yaml.safe_load(f.read())
logging.config.dictConfig(config)
log_config_path = "/app/logging/" +"config.yaml"

logger = logging.getLogger(__name__)
with open(log_config_path,'r') as f:
config = yaml.safe_load(f.read())
logging.config.dictConfig(config)

logger = logging.getLogger(__name__)

class YnabImportProgram():
"""
Expand Down Expand Up @@ -172,16 +174,17 @@ def process_structure_change(self) -> Dict[str, str]:

# Running locally from YnabImportProgram Class
# Running for api of FastApi, you have to comment main
if __name__ == "__main__":
print(root.DIR_DATA)
# print(root.DIR_DATA_RAW)
# print(root.DIR_DATA_RAW_TEST)
budget_obj = YnabImportProgram(root.DIR_DATA_RAW,root.DIR_DATA_ANALYTICS)
budget_obj.verify_running_platform()
#print(budget_obj)
#print(budget_obj.__str__)
#print("\n")
#print(budget_obj.__repr__)
budget_obj.process_structure_change()

# if __name__ == "__main__":
# print(root.DIR_DATA)
# # print(root.DIR_DATA_RAW)
# # print(root.DIR_DATA_RAW_TEST)
# budget_obj = YnabImportProgram(root.DIR_DATA_RAW,root.DIR_DATA_ANALYTICS)
# budget_obj.verify_running_platform()
# #print(budget_obj)
# #print(budget_obj.__str__)
# #print("\n")
# #print(budget_obj.__repr__)
# budget_obj.process_structure_change()


0 comments on commit 4443c3e

Please sign in to comment.