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 .DS_Store
Binary file not shown.
1,140 changes: 1,088 additions & 52 deletions TP1/1 - Practical number 1.ipynb

Large diffs are not rendered by default.

Binary file added TP2 and 3/.DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions TP2 and 3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
venv/
*.pyc
__pycache__/
.env
src/data/
src/models/
credentials.json
Binary file added TP2 and 3/config/.DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions TP2 and 3/config/dev/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ENV_NAME": "development",
"DEBUG": true,
"DATABASE_URI": "sqlite:///dev.db",
"API_URL": "http://localhost:8080"
}

7 changes: 7 additions & 0 deletions TP2 and 3/config/prd/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ENV_NAME": "production",
"DEBUG": false,
"DATABASE_URI": "postgresql://user:password@prod-db:5432/app",
"API_URL": "https://api.myapp.com"
}

Binary file added TP2 and 3/services/.DS_Store
Binary file not shown.
17 changes: 15 additions & 2 deletions TP2 and 3/services/epf-flower-data-science/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import os
from fastapi import FastAPI
import uvicorn

from fastapi.responses import RedirectResponse
from src.app import get_application
from src.api.routes import data

# Set the path to kaggle.json explicitly
kaggle_json_path = os.path.join(os.path.dirname(__file__), "src", "kaggle.json")

# Set the environment variable for the Kaggle API to the directory of kaggle.json
os.environ['KAGGLE_CONFIG_DIR'] = os.path.dirname(kaggle_json_path)

app = get_application()

@app.get("/", include_in_schema=False)
async def redirect_to_docs():
return RedirectResponse(url="/docs")

if __name__ == "__main__":
uvicorn.run("main:app", debug=True, reload=True, port=8080)
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""API Router for Fast API."""
from fastapi import APIRouter
from src.api.routes import hello, data

from src.api.routes import hello

router = APIRouter()

Expand Down
4 changes: 4 additions & 0 deletions TP2 and 3/services/epf-flower-data-science/src/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent))

from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import json

def load_config(env: str):
config_path = f"./config/{env}/config.json"
with open(config_path, "r") as f:
return json.load(f)

current_env = os.getenv("API", "dev")
config = load_config(current_env)
print(f"Environnement actuel : {config['API']}")