diff --git a/inews/infra/io.py b/inews/infra/io.py index b06c874..0713372 100644 --- a/inews/infra/io.py +++ b/inews/infra/io.py @@ -13,8 +13,6 @@ load_dotenv() session_token = os.environ["AWS_SESSION_TOKEN"] if "AWS_SESSION_TOKEN" in os.environ else None -DATA_PATH = Path("/tmp") if "AWS_LAMBDA_FUNCTION_NAME" in os.environ else Path("data") - s3 = boto3.resource( "s3", region_name=os.environ["AWS_REGION"], @@ -23,6 +21,7 @@ aws_session_token=session_token, ) + # S3 BUCKET = "intergalactic-news" CHANNELS_S3_FILE = "channels_state.json" @@ -37,6 +36,7 @@ MAILING_CONFIG_FILE = Path("config/mailing.yaml") # Data +DATA_PATH = Path("/tmp") if "AWS_LAMBDA_FUNCTION_NAME" in os.environ else Path("data") CHANNELS_LOCAL_FILE = DATA_PATH / Path("channels_state.json") TRANSCRIPTS_LOCAL_PATH = DATA_PATH / Path("transcripts/") SUMMARIES_LOCAL_PATH = DATA_PATH / Path("summaries/") diff --git a/inews/infra/utils.py b/inews/infra/utils.py index 94cbb7f..b16a334 100644 --- a/inews/infra/utils.py +++ b/inews/infra/utils.py @@ -2,4 +2,10 @@ def validate_event(event: dict) -> RunStatus: - return RunStatus.TEST if event["Status"] == "test" else RunStatus.PROD + print(event) + if event["Status"] == "test": + return RunStatus.TEST + elif event["Status"] == "prod": + return RunStatus.PROD + else: + raise ValueError diff --git a/lambda_function.py b/lambda_function.py index 70119fd..3987f61 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -4,5 +4,6 @@ def handler(event, context): status = utils.validate_event(event) + print(status) pipeline.run_data(status) pipeline.run_mailing(status)