Skip to content

Commit

Permalink
FIX dependencies issues and complete gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien Massiot committed Sep 19, 2023
1 parent c5641ae commit 374015c
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 29 deletions.
Binary file removed .DS_Store
Binary file not shown.
162 changes: 159 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,160 @@
.idea/*
.vscode
# Byte-compiled / optimized / DLL files
__pycache__/
.ipynb_checkpoints/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
# poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
6 changes: 3 additions & 3 deletions TP_instructions/tp0.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ git clone [email protected]:octo-technology/Formation-MLOps-1.git

NB : Si vous êtes sur Windows, vous aurez besoin de l'utilitaire [Git for windows](https://gitforwindows.org/)

## Ouvrir pycharm est le configure
## Ouvrir PyCharm et le configurer

Duration: 0:03:00

Ouvrir le projet sur pycharm
Ouvrir le projet sur PyCharm

Si vous êtes sous Windows, configurez votre terminal dans Pycharm afin de pouvoir exécuter toutes les commandes :
Si vous êtes sous Windows, configurez votre terminal dans PyCharm afin de pouvoir exécuter toutes les commandes :

- Allez dans Paramètres > Outils > Terminal
- Modifiez le "Shell path" par : `cmd.exe "/K" "C:\Users\>>me<<Miniconda3\Scripts\activate.bat"`
Expand Down
33 changes: 17 additions & 16 deletions api/main.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import os
import pickle
from typing import Optional

from fastapi import FastAPI
import numpy as np
import pandas as pd
import pickle
from fastapi import FastAPI
from sklearn.ensemble._forest import RandomForestClassifier

from models import MODELS_PATH
from src.feature_engineering import Preprocessor

app = FastAPI()

with open("./models/model_rf.pkl", "rb") as file_in:
with open(os.path.join(MODELS_PATH, "model_rf.pkl"), "rb") as file_in:
model: RandomForestClassifier = pickle.load(file_in)

with open("./models/preprocessor.pkl", "rb") as file_in:
with open(os.path.join(MODELS_PATH, "preprocessor.pkl"), "rb") as file_in:
preprocessor: Preprocessor = pickle.load(file_in)


column_dtypes = {
"PassengerId": "int64",
"Pclass": "int64",
Expand Down Expand Up @@ -45,18 +47,17 @@ def fillna(df: pd.DataFrame) -> pd.DataFrame:

@app.get("/predict/{pclass}/{name}/{sex}/")
async def predict(
pclass: int,
name: str,
sex: str,
age: Optional[float] = None,
sib_sp: Optional[int] = None,
parch: Optional[int] = None,
ticket: Optional[str] = None,
fare: Optional[float] = None,
cabin: Optional[str] = None,
embarked: Optional[str] = None,
pclass: int,
name: str,
sex: str,
age: Optional[float] = None,
sib_sp: Optional[int] = None,
parch: Optional[int] = None,
ticket: Optional[str] = None,
fare: Optional[float] = None,
cabin: Optional[str] = None,
embarked: Optional[str] = None,
):

input = pd.DataFrame(
{
"PassengerId": [1],
Expand Down
3 changes: 3 additions & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

MODELS_PATH = os.path.dirname(__file__)
Binary file modified models/preprocessor.pkl
Binary file not shown.
Binary file removed notebook/.DS_Store
Binary file not shown.
20 changes: 14 additions & 6 deletions notebook/titanic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"../src/\")"
"sys.path.append(\"../\")"
]
},
{
Expand All @@ -147,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"from indus.feature_engineering import Preprocessor"
"from src.feature_engineering import Preprocessor"
]
},
{
Expand Down Expand Up @@ -360,7 +360,8 @@
"metadata": {},
"outputs": [],
"source": [
"import pickle"
"import pickle\n",
"from models import MODELS_PATH"
]
},
{
Expand All @@ -369,10 +370,10 @@
"metadata": {},
"outputs": [],
"source": [
"with open(\"../models/preprocessor.pkl\", \"wb\") as file_out:\n",
"with open(os.path.join(MODELS_PATH, \"preprocessor.pkl\"), \"wb\") as file_out:\n",
" pickle.dump(processor, file_out)\n",
"\n",
"with open(\"../models/model_rf.pkl\", \"wb\") as file_out:\n",
"with open(os.path.join(MODELS_PATH, \"model_rf.pkl\"), \"wb\") as file_out:\n",
" pickle.dump(rf, file_out)"
]
},
Expand All @@ -388,6 +389,13 @@
"\n",
"I welcome any comments and suggestions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -408,7 +416,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ uvicorn==0.22.0

# Temp fix due to broken new version of jupyter-nbextensions-configurator 0.6.3 incompatible with notebook 7.0.0
notebook==6.5.4
jupyter-nbextensions-configurator==0.6.2
jupyter-nbextensions-configurator==0.6.2

# Fix SAJO AUMA
traitlets==5.9.0
Binary file removed src/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file removed src/__pycache__/feature_engineering.cpython-37.pyc
Binary file not shown.
Binary file removed tests/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file not shown.

0 comments on commit 374015c

Please sign in to comment.