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

185 html report always cleaning #248

Merged
merged 11 commits into from
May 1, 2024
2 changes: 1 addition & 1 deletion src/transport_performance/gtfs/report/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _set_up_report_dir(
raise FileExistsError(
"Report already exists at path: "
f"[{path}]."
"Consider setting overwrite=True"
"Consider setting overwrite=True "
"if you'd like to overwrite this."
)

Expand Down
11 changes: 9 additions & 2 deletions src/transport_performance/gtfs/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ def _extended_validation(
"stops": self.feed.stops,
"trips": self.feed.trips,
"calendar": self.feed.calendar,
"full_stop_schedule": self.full_stop_schedule,
}

# determine which errors/warnings have rows that can be located
Expand Down Expand Up @@ -1447,6 +1448,7 @@ def html_report(
overwrite: bool = False,
summary_type: str = "mean",
extended_validation: bool = True,
clean_feed: bool = True,
) -> None:
"""Generate a HTML report describing the GTFS data.

Expand All @@ -1462,7 +1464,9 @@ def html_report(
default "mean"
extended_validation : bool, optional
Whether or not to create extended reports for gtfs validation
errors/warnings.
errors/warnings, by default True
clean_feed : bool, optional
Whether or not to clean the feed before validating, by default True

Returns
-------
Expand All @@ -1475,6 +1479,8 @@ def html_report(

"""
_type_defence(overwrite, "overwrite", bool)
_type_defence(clean_feed, "clean_feed", bool)
_type_defence(extended_validation, "extended_validation", bool)
_type_defence(summary_type, "summary_type", str)
_set_up_report_dir(path=report_dir, overwrite=overwrite)
summary_type = summary_type.lower().strip()
Expand All @@ -1486,7 +1492,8 @@ def html_report(
date = datetime.datetime.strftime(datetime.datetime.now(), "%d-%m-%Y")

# feed evaluation
self.clean_feed(validate=True, fast_travel=True)
if clean_feed:
self.clean_feed(validate=True, fast_travel=True)
# re-validate to clean any newly raised errors/warnings
validation_dataframe = self.is_valid(far_stops=True)

Expand Down
1 change: 0 additions & 1 deletion src/transport_performance/gtfs/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def _join_max_speed(r_type: int) -> int:
return invalid_stops

# add the error to the validation table
# TODO: After merge add full_stop_schedule to HTML output table keys
_add_validation_row(
gtfs=gtfs,
_type="warning",
Expand Down
2 changes: 1 addition & 1 deletion tests/gtfs/report/test_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test__set_up_report_dir_defence(self, tmp_path):
re.escape(
"Report already exists at path: "
f"[{tmp_path}]."
"Consider setting overwrite=True"
"Consider setting overwrite=True "
"if you'd like to overwrite this."
)
),
Expand Down
Loading