Skip to content

Commit

Permalink
Remove conditional from GTFS-RT validator
Browse files Browse the repository at this point in the history
  • Loading branch information
ohrite committed Nov 22, 2024
1 parent e7f3dd8 commit 4a98da5
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions jobs/gtfs-rt-parser-v2/gtfs_rt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ def process(
outcomes: List[RTFileProcessingOutcome] = []
fs = get_fs()

if not self.aggregation.extracts[0].config.schedule_url_for_validation:
outcomes = [
RTFileProcessingOutcome(
step=self.aggregation.step,
success=False,
extract=extract,
exception=NoScheduleDataSpecified(),
)
for extract in self.aggregation.extracts
]

aggregation_extracts = AggregationExtracts(fs, tmp_dir, self.aggregation)
aggregation_extracts.download()
gtfs_zip = aggregation_extracts.download_most_recent_schedule()
Expand Down Expand Up @@ -777,7 +788,6 @@ def parse_and_validate(
verbose: bool = False,
) -> List[RTFileProcessingOutcome]:
validator = RtValidator(jar_path)
outcomes = []
with tempfile.TemporaryDirectory() as tmp_dir:
with sentry_sdk.push_scope() as scope:
scope.set_tag(
Expand All @@ -793,29 +803,13 @@ def parse_and_validate(
):
raise RuntimeError("we should not be here")

if (
aggregation.step == RTProcessingStep.validate
and not aggregation.extracts[0].config.schedule_url_for_validation
):
outcomes = [
RTFileProcessingOutcome(
step=aggregation.step,
success=False,
extract=extract,
exception=NoScheduleDataSpecified(),
)
for extract in aggregation.extracts
]

if aggregation.step == RTProcessingStep.validate:
outcomes = ValidationProcessor(aggregation, validator, verbose).process(
return ValidationProcessor(aggregation, validator, verbose).process(
tmp_dir, scope
)

if aggregation.step == RTProcessingStep.parse:
outcomes = ParseProcessor(aggregation, verbose).process(tmp_dir, scope)

return outcomes
return ParseProcessor(aggregation, verbose).process(tmp_dir, scope)


def make_dict_bq_safe(d: Dict[str, Any]) -> Dict[str, Any]:
Expand Down

0 comments on commit 4a98da5

Please sign in to comment.