Skip to content

Commit 39241b6

Browse files
committed
address PR issues
1 parent daf200a commit 39241b6

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

functions-python/pmtiles_builder/src/csv_cache.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,7 @@ def _read_csv(self, filename) -> list[dict]:
9898
except Exception as e:
9999
raise Exception(f"Failed to read CSV file {filename}: {e}") from e
100100

101-
def get_trip_from_route(self, route_id):
102-
if self.route_to_trip is None:
103-
self.route_to_trip = {}
104-
for row in self.get_file(TRIPS_FILE):
105-
route_id = row["route_id"]
106-
trip_id = row["trip_id"]
107-
if trip_id:
108-
if self.route_to_trip.get(route_id):
109-
self.route_to_trip[route_id] = trip_id
110-
else:
111-
self.route_to_trip.setdefault(route_id, trip_id)
112-
return self.route_to_trip.get(route_id, "")
113-
114-
def get_shape_from_route(self, route_id) -> List[ShapeTrips]:
101+
def get_shape_from_route(self, route_id) -> Dict[str, List[ShapeTrips]]:
115102
"""
116103
Returns a list of shape_ids with associated trip_ids information with a given route_id from the trips file.
117104
The relationship from the route to the shape is via the trips file.
@@ -152,7 +139,7 @@ def get_shape_from_route(self, route_id) -> List[ShapeTrips]:
152139
trip_no_shapes = []
153140
self.trips_no_shapes_per_route[route_id] = trip_no_shapes
154141
trip_no_shapes.append(trip_id)
155-
return self.route_to_shape.get(route_id, [])
142+
return self.route_to_shape.get(route_id, {})
156143

157144
def get_trips_without_shape_from_route(self, route_id) -> List[str]:
158145
return (

functions-python/pmtiles_builder/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def get_route_coordinates(self, route_id, shapes_index) -> List[RouteCoordinates
521521
)
522522
else:
523523
self.logger.info(
524-
"Coordinates were not have the right formatting for stops of trip_id %s on route_id %s",
524+
"Coordinates do not have the right formatting for stops of trip_id %s on route_id %s",
525525
trip_id,
526526
route_id,
527527
)

functions-python/pmtiles_builder/src/scripts/pmtiles_builder_verifier.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,35 @@
1919
)
2020

2121
feeds = [
22-
{"stable_id": "mdb-437", "dataset_stable_id": "mdb-437-202507081733"},
22+
{"stable_id": "mdb-437", "dataset_stable_id": "mdb-437-202507081733", "env": "dev"},
23+
{
24+
"stable_id": "mdb-2841",
25+
"dataset_stable_id": "mdb-2841-202509032137",
26+
"env": "prod",
27+
},
2328
]
24-
run_with_feed_index = 0 # Change this index to run with a different feed
29+
run_with_feed_index = 1 # Change this index to run with a different feed
2530

2631
FILES = [STOP_TIMES_FILE, SHAPES_FILE, TRIPS_FILE, ROUTES_FILE, STOPS_FILE, AGENCY_FILE]
2732

2833

29-
def download_feed_files(feed_stable_id: str, dataset_stable_id: str):
30-
FILES_URL = "https://dev-files.mobilitydatabase.org"
34+
def download_feed_files(
35+
feed_stable_id: str,
36+
dataset_stable_id: str,
37+
env: str = "dev",
38+
force_download: bool = False,
39+
):
40+
url_prefix = "" if env == "prod" else f"{env}-"
41+
FILES_URL = f"https://{url_prefix}files.mobilitydatabase.org"
3142
base_url = f"{FILES_URL}/{feed_stable_id}/{dataset_stable_id}/extracted"
3243
for file in FILES:
3344
url = f"{base_url}/{file}"
3445
logging.info(f"Downloading {url}")
3546
filename = f"{dataset_stable_id}/extracted/{file}"
3647
try:
37-
download_to_local(feed_stable_id, url, filename, False)
48+
download_to_local(
49+
feed_stable_id, url, filename, force_download=force_download
50+
)
3851
except Exception as e:
3952
logging.warning(f"Failed to download {file}: {e}")
4053

@@ -65,7 +78,7 @@ def download_feed_files(feed_stable_id: str, dataset_stable_id: str):
6578
)
6679
try:
6780
server = setup_local_storage_emulator()
68-
download_feed_files(feed_stable_id, dataset_stable_id)
81+
download_feed_files(feed_stable_id, dataset_stable_id, feed_dict["env"])
6982
response = build_pmtiles_handler(request)
7083
logging.info(response)
7184
except Exception as e:

0 commit comments

Comments
 (0)