mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Added deeper logging
This commit is contained in:
parent
f77ff1ec22
commit
654c2e93d2
4 changed files with 22 additions and 9 deletions
|
|
@ -5,11 +5,12 @@ from Crypto.Protocol.KDF import HKDF
|
||||||
from Crypto.Hash import SHA256
|
from Crypto.Hash import SHA256
|
||||||
from typing import Any
|
from typing import Any
|
||||||
import json
|
import json
|
||||||
import logging
|
# import logging
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
|
from app.utils import logger
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
# logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
api_key_header = APIKeyHeader(name=get_settings().API_KEY_NAME, auto_error=False)
|
api_key_header = APIKeyHeader(name=get_settings().API_KEY_NAME, auto_error=False)
|
||||||
|
|
@ -31,7 +32,6 @@ def get_user(user_id: str):
|
||||||
if get_settings().ENVIRONMENT == "local":
|
if get_settings().ENVIRONMENT == "local":
|
||||||
return {"id": user_id, "name": "Dummy User"}
|
return {"id": user_id, "name": "Dummy User"}
|
||||||
else:
|
else:
|
||||||
user = None
|
|
||||||
if user_id == "known_id":
|
if user_id == "known_id":
|
||||||
user = {"id": user_id, "name": "Known User"}
|
user = {"id": user_id, "name": "Known User"}
|
||||||
else:
|
else:
|
||||||
|
|
@ -97,6 +97,10 @@ def validate_jwt_token(token: str = Depends(oauth2_scheme)):
|
||||||
|
|
||||||
|
|
||||||
async def validate_token(token: str = Depends(oauth2_scheme), request: Request = None):
|
async def validate_token(token: str = Depends(oauth2_scheme), request: Request = None):
|
||||||
|
logger.info("Validating token")
|
||||||
|
logger.info(token)
|
||||||
|
logger.info("Secret")
|
||||||
|
logger.info(get_settings().SECRET_KEY)
|
||||||
token_data = validate_jwt_token(token)
|
token_data = validate_jwt_token(token)
|
||||||
if not token_data:
|
if not token_data:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from app.dependencies import validate_token
|
||||||
from app.plan.schemas import PlanTriggerRequest
|
from app.plan.schemas import PlanTriggerRequest
|
||||||
from app.utils import read_csv_from_s3
|
from app.utils import read_csv_from_s3
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
|
from app.utils import logger
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
prefix="/plan",
|
prefix="/plan",
|
||||||
|
|
@ -14,14 +15,14 @@ router = APIRouter(
|
||||||
|
|
||||||
@router.post("/trigger")
|
@router.post("/trigger")
|
||||||
async def trigger_plan(body: PlanTriggerRequest):
|
async def trigger_plan(body: PlanTriggerRequest):
|
||||||
print("Getting the inputs")
|
logger.info("Getting the inputs")
|
||||||
# Read in the trigger file from s3
|
# Read in the trigger file from s3
|
||||||
bucket_name = get_settings().PLAN_TRIGGER_BUCKET
|
bucket_name = get_settings().PLAN_TRIGGER_BUCKET
|
||||||
print("bucket_name: ", bucket_name)
|
logger.info("bucket_name: ", bucket_name)
|
||||||
print("body.trigger_file_path: ", body.trigger_file_path)
|
logger.info("body.trigger_file_path: ", body.trigger_file_path)
|
||||||
plan_input = read_csv_from_s3(bucket_name=bucket_name, filepath=body.trigger_file_path)
|
plan_input = read_csv_from_s3(bucket_name=bucket_name, filepath=body.trigger_file_path)
|
||||||
print("Got the inputs")
|
logger.info("Got the inputs")
|
||||||
print(plan_input)
|
logger.info(plan_input)
|
||||||
|
|
||||||
# TODO: Parse the file
|
# TODO: Parse the file
|
||||||
# TODO: Put messages on the queue
|
# TODO: Put messages on the queue
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@ import csv
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import string
|
import string
|
||||||
import secrets
|
import secrets
|
||||||
|
from aws_lambda_powertools import Logger, Metrics, Tracer
|
||||||
|
from aws_lambda_powertools.metrics import MetricUnit # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
|
logger: Logger = Logger()
|
||||||
|
metrics: Metrics = Metrics()
|
||||||
|
tracer: Tracer = Tracer()
|
||||||
|
|
||||||
|
|
||||||
def read_csv_from_s3(bucket_name, filepath):
|
def read_csv_from_s3(bucket_name, filepath):
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,5 @@ uvloop==0.17.0
|
||||||
watchfiles==0.19.0
|
watchfiles==0.19.0
|
||||||
websockets==11.0.3
|
websockets==11.0.3
|
||||||
boto3
|
boto3
|
||||||
pycryptodome
|
pycryptodome
|
||||||
|
aws-lambda-powertools
|
||||||
Loading…
Add table
Reference in a new issue