Skip to content

Commit a1fa432

Browse files
committed
Changed the name to gtfs-datasets-comparer
1 parent 8420941 commit a1fa432

7 files changed

Lines changed: 49 additions & 49 deletions

File tree

functions-python/batch_process_dataset/src/pipeline_tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from shared.helpers.utils import (
1212
create_http_task,
1313
create_http_pmtiles_builder_task,
14-
create_http_gtfs_change_tracker_task,
14+
create_http_gtfs_datasets_comparer_task,
1515
)
1616

1717

@@ -172,7 +172,7 @@ def create_pipeline_tasks(dataset: Gtfsdataset, db_session: Session) -> None:
172172
dataset_stable_id,
173173
)
174174
else:
175-
create_http_gtfs_change_tracker_task(
175+
create_http_gtfs_datasets_comparer_task(
176176
feed_stable_id=stable_id,
177177
base_dataset_stable_id=previous_dataset.stable_id,
178178
new_dataset_stable_id=dataset_stable_id,

functions-python/batch_process_dataset/tests/test_batch_process_dataset_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ def mock_remove_side_effect(path):
449449
@patch.dict(
450450
os.environ, {"FEEDS_CREDENTIALS": '{"test_stable_id": "test_credentials"}'}
451451
)
452-
@patch("pipeline_tasks.create_http_gtfs_change_tracker_task")
452+
@patch("pipeline_tasks.create_http_gtfs_datasets_comparer_task")
453453
@with_db_session(db_url=default_db_url)
454-
def test_process(self, mock_gtfs_change_tracker_task, db_session):
454+
def test_process(self, mock_gtfs_datasets_comparer_task, db_session):
455455
feeds = db_session.query(Gtfsfeed).all()
456456
feed_id = feeds[0].id
457457

functions-python/gtfs_change_tracker/function_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gtfs-change-tracker",
2+
"name": "gtfs-datasets-comparer",
33
"description": "Tracks changes between two GTFS datasets and stores a structured changelog in GCS and the database",
44
"entry_point": "gtfs_change_tracker",
55
"timeout": 540,

functions-python/helpers/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,13 @@ def create_http_pmtiles_builder_task(
535535
)
536536

537537

538-
def create_http_gtfs_change_tracker_task(
538+
def create_http_gtfs_datasets_comparer_task(
539539
feed_stable_id: str,
540540
base_dataset_stable_id: str,
541541
new_dataset_stable_id: str,
542542
) -> None:
543543
"""
544-
Create a Cloud Task to run the gtfs-change-tracker function for a pair of datasets.
544+
Create a Cloud Task to run the gtfs-datasets-comparer function for a pair of datasets.
545545
"""
546546
from google.cloud import tasks_v2
547547
import json
@@ -563,7 +563,7 @@ def create_http_gtfs_change_tracker_task(
563563
create_http_task(
564564
client,
565565
body,
566-
f"https://{gcp_region}-{project_id}.cloudfunctions.net/gtfs-change-tracker-{gcp_env}",
566+
f"https://{gcp_region}-{project_id}.cloudfunctions.net/gtfs-datasets-comparer-{gcp_env}",
567567
project_id,
568568
gcp_region,
569569
queue_name,

infra/batch/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ locals {
4545

4646
function_pmtiles_builder_config = jsondecode(file("${path.module}/../../functions-python/pmtiles_builder/function_config.json"))
4747

48-
function_gtfs_change_tracker_config = jsondecode(file("${path.module}/../../functions-python/gtfs_change_tracker/function_config.json"))
48+
function_gtfs_datasets_comparer_config = jsondecode(file("${path.module}/../../functions-python/gtfs_datasets_comparer/function_config.json"))
4949
}
5050

5151
data "google_vpc_access_connector" "vpc_connector" {
@@ -274,11 +274,11 @@ resource "google_cloud_tasks_queue" "pmtiles_builder_task_queue" {
274274
}
275275
}
276276

277-
# Task queue to invoke gtfs_change_tracker function
278-
resource "google_cloud_tasks_queue" "gtfs_change_tracker_task_queue" {
277+
# Task queue to invoke gtfs_datasets_comparer function
278+
resource "google_cloud_tasks_queue" "gtfs_datasets_comparer_task_queue" {
279279
project = var.project_id
280280
location = var.gcp_region
281-
name = "gtfs-change-tracker-queue-${var.environment}-${local.deployment_timestamp}"
281+
name = "gtfs-datasets-comparer-queue-${var.environment}-${local.deployment_timestamp}"
282282

283283
rate_limits {
284284
max_concurrent_dispatches = 10
@@ -332,7 +332,7 @@ resource "google_cloudfunctions2_function" "pubsub_function" {
332332
MATERIALIZED_VIEW_QUEUE = google_cloud_tasks_queue.refresh_materialized_view_task_queue.name
333333
PMTILES_BUILDER_QUEUE = google_cloud_tasks_queue.pmtiles_builder_task_queue.name
334334
REVERSE_GEOLOCATION_QUEUE = "reverse-geolocation-processor-task-queue"
335-
GTFS_CHANGE_TRACKER_QUEUE = google_cloud_tasks_queue.gtfs_change_tracker_task_queue.name
335+
GTFS_CHANGE_TRACKER_QUEUE = google_cloud_tasks_queue.gtfs_datasets_comparer_task_queue.name
336336
WEB_REVALIDATION_QUEUE = google_cloud_tasks_queue.web_revalidation_task_queue.name
337337
}
338338
dynamic "secret_environment_variables" {
@@ -493,10 +493,10 @@ resource "google_cloud_run_service_iam_member" "pmtiles_builder_invoker" {
493493
member = "serviceAccount:${google_service_account.functions_service_account.email}"
494494
}
495495

496-
resource "google_cloud_run_service_iam_member" "gtfs_change_tracker_invoker" {
496+
resource "google_cloud_run_service_iam_member" "gtfs_datasets_comparer_invoker" {
497497
project = var.project_id
498498
location = var.gcp_region
499-
service = "${local.function_gtfs_change_tracker_config.name}-${var.environment}"
499+
service = "${local.function_gtfs_datasets_comparer_config.name}-${var.environment}"
500500
role = "roles/run.invoker"
501501
member = "serviceAccount:${google_service_account.functions_service_account.email}"
502502
}

infra/functions-python/main.tf

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ locals {
6666
function_pmtiles_builder_config = jsondecode(file("${path.module}/../../functions-python/pmtiles_builder/function_config.json"))
6767
function_pmtiles_builder_zip = "${path.module}/../../functions-python/pmtiles_builder/.dist/pmtiles_builder.zip"
6868

69-
function_gtfs_change_tracker_config = jsondecode(file("${path.module}/../../functions-python/gtfs_change_tracker/function_config.json"))
70-
function_gtfs_change_tracker_zip = "${path.module}/../../functions-python/gtfs_change_tracker/.dist/gtfs_change_tracker.zip"
69+
function_gtfs_datasets_comparer_config = jsondecode(file("${path.module}/../../functions-python/gtfs_datasets_comparer/function_config.json"))
70+
function_gtfs_datasets_comparer_zip = "${path.module}/../../functions-python/gtfs_datasets_comparer/.dist/gtfs_datasets_comparer.zip"
7171
}
7272

7373
locals {
@@ -80,7 +80,7 @@ locals {
8080
local.function_export_csv_config.secret_environment_variables,
8181
local.function_tasks_executor_config.secret_environment_variables,
8282
local.function_pmtiles_builder_config.secret_environment_variables,
83-
local.function_gtfs_change_tracker_config.secret_environment_variables
83+
local.function_gtfs_datasets_comparer_config.secret_environment_variables
8484
)
8585

8686
# Remove duplicates by key, keeping the first occurrence
@@ -227,10 +227,10 @@ resource "google_storage_bucket_object" "pmtiles_builder_zip" {
227227
}
228228

229229
# 16. GTFS Change Tracker
230-
resource "google_storage_bucket_object" "gtfs_change_tracker_zip" {
230+
resource "google_storage_bucket_object" "gtfs_datasets_comparer_zip" {
231231
bucket = google_storage_bucket.functions_bucket.name
232-
name = "gtfs-change-tracker-${substr(filebase64sha256(local.function_gtfs_change_tracker_zip), 0, 10)}.zip"
233-
source = local.function_gtfs_change_tracker_zip
232+
name = "gtfs-datasets-comparer-${substr(filebase64sha256(local.function_gtfs_datasets_comparer_zip), 0, 10)}.zip"
233+
source = local.function_gtfs_datasets_comparer_zip
234234
}
235235

236236
# Web app revalidation secret
@@ -1045,20 +1045,20 @@ resource "google_cloudfunctions2_function_iam_member" "pmtiles_builder_invoker"
10451045
member = "serviceAccount:${google_service_account.functions_service_account.email}"
10461046
}
10471047

1048-
# Grant execution permission to batchfunctions service account to the gtfs_change_tracker function
1049-
resource "google_cloudfunctions2_function_iam_member" "gtfs_change_tracker_invoker_batch_sa" {
1048+
# Grant execution permission to batchfunctions service account to the gtfs_datasets_comparer function
1049+
resource "google_cloudfunctions2_function_iam_member" "gtfs_datasets_comparer_invoker_batch_sa" {
10501050
project = var.project_id
10511051
location = var.gcp_region
1052-
cloud_function = google_cloudfunctions2_function.gtfs_change_tracker.name
1052+
cloud_function = google_cloudfunctions2_function.gtfs_datasets_comparer.name
10531053
role = "roles/cloudfunctions.invoker"
10541054
member = "serviceAccount:${local.batchfunctions_sa_email}"
10551055
}
10561056

1057-
# Grant execution permission to the functions service account to the gtfs_change_tracker function
1058-
resource "google_cloudfunctions2_function_iam_member" "gtfs_change_tracker_invoker" {
1057+
# Grant execution permission to the functions service account to the gtfs_datasets_comparer function
1058+
resource "google_cloudfunctions2_function_iam_member" "gtfs_datasets_comparer_invoker" {
10591059
project = var.project_id
10601060
location = var.gcp_region
1061-
cloud_function = google_cloudfunctions2_function.gtfs_change_tracker.name
1061+
cloud_function = google_cloudfunctions2_function.gtfs_datasets_comparer.name
10621062
role = "roles/cloudfunctions.invoker"
10631063
member = "serviceAccount:${google_service_account.functions_service_account.email}"
10641064
}
@@ -1257,21 +1257,21 @@ resource "google_cloudfunctions2_function" "pmtiles_builder" {
12571257
}
12581258

12591259

1260-
# 16. functions/gtfs_change_tracker cloud function
1261-
resource "google_cloudfunctions2_function" "gtfs_change_tracker" {
1262-
name = "${local.function_gtfs_change_tracker_config.name}-${var.environment}"
1260+
# 16. functions/gtfs_datasets_comparer cloud function
1261+
resource "google_cloudfunctions2_function" "gtfs_datasets_comparer" {
1262+
name = "${local.function_gtfs_datasets_comparer_config.name}-${var.environment}"
12631263
project = var.project_id
1264-
description = local.function_gtfs_change_tracker_config.description
1264+
description = local.function_gtfs_datasets_comparer_config.description
12651265
location = var.gcp_region
12661266
depends_on = [google_secret_manager_secret_iam_member.secret_iam_member]
12671267

12681268
build_config {
12691269
runtime = var.python_runtime
1270-
entry_point = local.function_gtfs_change_tracker_config.entry_point
1270+
entry_point = local.function_gtfs_datasets_comparer_config.entry_point
12711271
source {
12721272
storage_source {
12731273
bucket = google_storage_bucket.functions_bucket.name
1274-
object = google_storage_bucket_object.gtfs_change_tracker_zip.name
1274+
object = google_storage_bucket_object.gtfs_datasets_comparer_zip.name
12751275
}
12761276
}
12771277
}
@@ -1285,19 +1285,19 @@ resource "google_cloudfunctions2_function" "gtfs_change_tracker" {
12851285
# GTFS_DIFF_DUCKDB_TMPDIR: directs DuckDB spill files to the in-memory volume.
12861286
GTFS_DIFF_DUCKDB_TMPDIR = "/tmp/in-memory"
12871287
}
1288-
available_memory = local.function_gtfs_change_tracker_config.memory
1289-
timeout_seconds = local.function_gtfs_change_tracker_config.timeout
1290-
available_cpu = local.function_gtfs_change_tracker_config.available_cpu
1291-
max_instance_request_concurrency = local.function_gtfs_change_tracker_config.max_instance_request_concurrency
1292-
max_instance_count = local.function_gtfs_change_tracker_config.max_instance_count
1293-
min_instance_count = local.function_gtfs_change_tracker_config.min_instance_count
1288+
available_memory = local.function_gtfs_datasets_comparer_config.memory
1289+
timeout_seconds = local.function_gtfs_datasets_comparer_config.timeout
1290+
available_cpu = local.function_gtfs_datasets_comparer_config.available_cpu
1291+
max_instance_request_concurrency = local.function_gtfs_datasets_comparer_config.max_instance_request_concurrency
1292+
max_instance_count = local.function_gtfs_datasets_comparer_config.max_instance_count
1293+
min_instance_count = local.function_gtfs_datasets_comparer_config.min_instance_count
12941294
service_account_email = google_service_account.functions_service_account.email
1295-
ingress_settings = local.function_gtfs_change_tracker_config.ingress_settings
1295+
ingress_settings = local.function_gtfs_datasets_comparer_config.ingress_settings
12961296
vpc_connector = data.google_vpc_access_connector.vpc_connector.id
12971297
vpc_connector_egress_settings = "PRIVATE_RANGES_ONLY"
12981298

12991299
dynamic "secret_environment_variables" {
1300-
for_each = local.function_gtfs_change_tracker_config.secret_environment_variables
1300+
for_each = local.function_gtfs_datasets_comparer_config.secret_environment_variables
13011301
content {
13021302
key = secret_environment_variables.value["key"]
13031303
project_id = var.project_id
@@ -1311,17 +1311,17 @@ resource "google_cloudfunctions2_function" "gtfs_change_tracker" {
13111311
# google_cloudfunctions2_function does not expose volume mounts in its schema.
13121312
# This terraform_data resource mounts both the datasets GCS bucket and an in-memory tmpfs
13131313
# on the underlying Cloud Run service after the function is deployed.
1314-
resource "terraform_data" "gtfs_change_tracker_gcs_mount" {
1314+
resource "terraform_data" "gtfs_datasets_comparer_gcs_mount" {
13151315
triggers_replace = {
1316-
function_name = google_cloudfunctions2_function.gtfs_change_tracker.name
1316+
function_name = google_cloudfunctions2_function.gtfs_datasets_comparer.name
13171317
bucket = "${var.datasets_bucket_name}-${var.environment}"
13181318
region = var.gcp_region
13191319
project = var.project_id
13201320
}
13211321

13221322
provisioner "local-exec" {
13231323
command = <<-EOT
1324-
MOUNTS=$(gcloud run services describe ${google_cloudfunctions2_function.gtfs_change_tracker.name} \
1324+
MOUNTS=$(gcloud run services describe ${google_cloudfunctions2_function.gtfs_datasets_comparer.name} \
13251325
--project ${var.project_id} \
13261326
--region ${var.gcp_region} \
13271327
--format='value(spec.template.spec.volumes[].name)' 2>/dev/null)
@@ -1337,12 +1337,12 @@ resource "terraform_data" "gtfs_change_tracker_gcs_mount" {
13371337
if echo "$MOUNTS" | grep -q "in-memory"; then
13381338
echo "In-memory volume already mounted, skipping."
13391339
else
1340-
ARGS="$ARGS --add-volume name=in-memory,type=in-memory,size-limit=${var.gtfs_change_tracker_in_memory_size}"
1340+
ARGS="$ARGS --add-volume name=in-memory,type=in-memory,size-limit=${var.gtfs_datasets_comparer_in_memory_size}"
13411341
ARGS="$ARGS --add-volume-mount volume=in-memory,mount-path=/tmp/in-memory"
13421342
fi
13431343
13441344
if [ -n "$ARGS" ]; then
1345-
gcloud run services update ${google_cloudfunctions2_function.gtfs_change_tracker.name} \
1345+
gcloud run services update ${google_cloudfunctions2_function.gtfs_datasets_comparer.name} \
13461346
--project ${var.project_id} \
13471347
--region ${var.gcp_region} \
13481348
$ARGS \
@@ -1351,7 +1351,7 @@ resource "terraform_data" "gtfs_change_tracker_gcs_mount" {
13511351
EOT
13521352
}
13531353

1354-
depends_on = [google_cloudfunctions2_function.gtfs_change_tracker]
1354+
depends_on = [google_cloudfunctions2_function.gtfs_datasets_comparer]
13551355
}
13561356

13571357
# Create the Pub/Sub topic used for publishing messages about rebuilding missing bounding boxes

infra/functions-python/vars.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ variable "brevo_api_announcements_list_id" {
135135
description = "Brevo list ID for API announcements"
136136
default = ""
137137
}
138-
variable "gtfs_change_tracker_in_memory_size" {
138+
variable "gtfs_datasets_comparer_in_memory_size" {
139139
type = string
140-
description = "Size limit for the gtfs_change_tracker in-memory tmpfs volume"
140+
description = "Size limit for the gtfs_datasets_comparer in-memory tmpfs volume"
141141
default = "3Gi"
142142
}

0 commit comments

Comments
 (0)