Skip to content

Commit

Permalink
Add Flake8 corrections for GTFS RT validator
Browse files Browse the repository at this point in the history
  • Loading branch information
erikamov committed Nov 21, 2024
1 parent 352936e commit 80448bf
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions jobs/gtfs-rt-parser-v2/gtfs_rt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import json
import os
import subprocess
import sys
import tempfile
import traceback
from collections import defaultdict
Expand All @@ -19,22 +18,15 @@
from functools import lru_cache
from itertools import islice
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Sequence, Tuple, Union
from typing import Any, ClassVar, Dict, List, Optional, Tuple

import backoff # type: ignore
import gcsfs # type: ignore
import pendulum
import sentry_sdk
import typer
from aiohttp.client_exceptions import (
ClientOSError,
ClientResponseError,
ServerDisconnectedError,
)
from calitp_data_infra.storage import ( # type: ignore
JSONL_GZIP_EXTENSION,
GTFSDownloadConfig,
GTFSFeedExtract,
GTFSFeedType,
GTFSRTFeedExtract,
GTFSScheduleFeedExtract,
Expand Down Expand Up @@ -565,6 +557,7 @@ def process(
exception=e,
process_stderr=stderr,
)
for extract in self.aggregation.extracts
]

if not outcomes:
Expand All @@ -581,13 +574,13 @@ def process(
fg=typer.colors.YELLOW,
)

for e in extracts:
for extract in extracts:
outcomes.append(
RTFileProcessingOutcome(
step=self.aggregation.step,
success=False,
extract=e,
aggregation=aggregation,
exception=e,
extract=extract,
)
)
continue
Expand Down Expand Up @@ -682,7 +675,7 @@ def process(
feed.ParseFromString(f.read())
parsed = json_format.MessageToDict(feed)
except DecodeError as e:
if verbose:
if self.verbose:
typer.secho(
f"WARNING: DecodeError for {str(extract.path)}",
fg=typer.colors.YELLOW,
Expand Down Expand Up @@ -854,10 +847,10 @@ def main(
):
hourly_feed_files = FeedStorage(feed_type).get_hour(hour)
if not hourly_feed_files.valid():
typer.secho(f"missing: {files_missing_metadata}")
typer.secho(f"invalid: {files_invalid_metadata}")
typer.secho(f"missing: {hourly_feed_files.files_missing_metadata}")
typer.secho(f"invalid: {hourly_feed_files.files_invalid_metadata}")
raise RuntimeError(
f"too many files have missing/invalid metadata; {total - len(files)} of {total}" # noqa: E702
f"too many files have missing/invalid metadata; {hourly_feed_files.total - len(hourly_feed_files.files)} of {hourly_feed_files.total}"
)
aggregated_feed = hourly_feed_files.get_query(step, feed_type)
aggregations_to_process = (
Expand Down

0 comments on commit 80448bf

Please sign in to comment.