mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +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 typing import Any
|
||||
import json
|
||||
import logging
|
||||
# import logging
|
||||
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)
|
||||
|
|
@ -31,7 +32,6 @@ def get_user(user_id: str):
|
|||
if get_settings().ENVIRONMENT == "local":
|
||||
return {"id": user_id, "name": "Dummy User"}
|
||||
else:
|
||||
user = None
|
||||
if user_id == "known_id":
|
||||
user = {"id": user_id, "name": "Known User"}
|
||||
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):
|
||||
logger.info("Validating token")
|
||||
logger.info(token)
|
||||
logger.info("Secret")
|
||||
logger.info(get_settings().SECRET_KEY)
|
||||
token_data = validate_jwt_token(token)
|
||||
if not token_data:
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from app.dependencies import validate_token
|
|||
from app.plan.schemas import PlanTriggerRequest
|
||||
from app.utils import read_csv_from_s3
|
||||
from app.config import get_settings
|
||||
from app.utils import logger
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/plan",
|
||||
|
|
@ -14,14 +15,14 @@ router = APIRouter(
|
|||
|
||||
@router.post("/trigger")
|
||||
async def trigger_plan(body: PlanTriggerRequest):
|
||||
print("Getting the inputs")
|
||||
logger.info("Getting the inputs")
|
||||
# Read in the trigger file from s3
|
||||
bucket_name = get_settings().PLAN_TRIGGER_BUCKET
|
||||
print("bucket_name: ", bucket_name)
|
||||
print("body.trigger_file_path: ", body.trigger_file_path)
|
||||
logger.info("bucket_name: ", bucket_name)
|
||||
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)
|
||||
print("Got the inputs")
|
||||
print(plan_input)
|
||||
logger.info("Got the inputs")
|
||||
logger.info(plan_input)
|
||||
|
||||
# TODO: Parse the file
|
||||
# TODO: Put messages on the queue
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@ import csv
|
|||
from io import StringIO
|
||||
import string
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -26,4 +26,5 @@ uvloop==0.17.0
|
|||
watchfiles==0.19.0
|
||||
websockets==11.0.3
|
||||
boto3
|
||||
pycryptodome
|
||||
pycryptodome
|
||||
aws-lambda-powertools
|
||||
Loading…
Add table
Reference in a new issue