Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consolidate quality checks for stop id #49

Merged
merged 2 commits into from
Jan 11, 2024
Merged
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
15 changes: 8 additions & 7 deletions src/event.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from datetime import date, datetime
from typing import Tuple
import pandas as pd
Expand Down Expand Up @@ -47,12 +48,13 @@ def reduce_update_event(update):

try:
# The vehicle’s current (when current_status is STOPPED_AT) or next stop.
if "stop" in update["relationships"]:
stop_id = update["relationships"]["stop"]["data"]["id"]
else:
stop_id = None
except TypeError:
logger.error(f"Encountered TypeError when processing update: {update}")
stop_id = update["relationships"]["stop"]["data"]["id"]
except (TypeError, KeyError):
logger.error(
f"Encountered degenerate stop information. This event will be skipped: {json.dumps(update)}",
stack_info=True,
exc_info=True,
)
stop_id = None

return (
Expand Down Expand Up @@ -105,7 +107,6 @@ def process_event(
prev["updated_at"] = datetime.fromisoformat(prev["updated_at"])

if stop_id is None:
logger.info(f"Skipping event with no stop_id: {update}")
return

is_departure_event, is_arrival_event = arr_or_dep_event(
Expand Down