Skip to content

Commit

Permalink
🦺 Event validation complete
Browse files Browse the repository at this point in the history
  • Loading branch information
aliberts committed Nov 26, 2023
1 parent 7c9c74d commit bdf5e0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions inews/infra/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -23,6 +21,7 @@
aws_session_token=session_token,
)


# S3
BUCKET = "intergalactic-news"
CHANNELS_S3_FILE = "channels_state.json"
Expand All @@ -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/")
Expand Down
8 changes: 7 additions & 1 deletion inews/infra/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

def handler(event, context):
status = utils.validate_event(event)
print(status)
pipeline.run_data(status)
pipeline.run_mailing(status)

0 comments on commit bdf5e0e

Please sign in to comment.