Skip to content

Commit fcec71a

Browse files
committed
Remove CHANGELOG_DB_WRITE_ENABLED flag (covered by dry_run)
1 parent 6ecedd0 commit fcec71a

3 files changed

Lines changed: 25 additions & 36 deletions

File tree

functions-python/gtfs_change_tracker/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,4 @@ The function always returns HTTP 200, including on errors. Errors are reported i
7878
- `DATASETS_BUCKET_MOUNT`: Mount path for the GCS bucket (default: `/mobilitydata-datasets`).
7979
- `GTFS_DIFF_DUCKDB_TMPDIR`: Mount path for the in-memory tmpfs used by the diff engine (default: `/tmp/in-memory`). Used by `limit_gcp_memory` to compute the available process memory and set `RLIMIT_AS`, preventing silent OOM kills.
8080
- `MEMORY_MARGIN_MB`: Safety margin in MiB subtracted from the memory limit before setting `RLIMIT_AS` (default: `200`).
81-
- `CHANGELOG_DB_WRITE_ENABLED`: Set to `true` to enable writing changelog records to the database (default: `false`).
8281
- `LOGGING_LEVEL`: Log level (default: `INFO`).

functions-python/gtfs_change_tracker/src/main.py

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -292,39 +292,28 @@ def _save_changelog_record(
292292
Upsert a row into gtfs_dataset_changelog.
293293
The UNIQUE constraint on (previous_dataset_id, current_dataset_id) ensures idempotency.
294294
"""
295-
# TODO: remove this flag and always write to DB once testing is complete
296-
if os.getenv("CHANGELOG_DB_WRITE_ENABLED", "true").lower() == "true":
297-
stmt = (
298-
insert(GtfsDatasetChangelog)
299-
.values(
300-
feed_id=feed_uuid,
301-
previous_dataset_id=prev_dataset_uuid,
302-
current_dataset_id=curr_dataset_uuid,
303-
changelog_url=changelog_url,
304-
diff_summary=diff_summary,
305-
)
306-
.on_conflict_do_update(
307-
constraint="gtfs_dataset_changelog_previous_current_key",
308-
set_={
309-
"changelog_url": changelog_url,
310-
"diff_summary": diff_summary,
311-
"generated_at": GtfsDatasetChangelog.generated_at.default,
312-
},
313-
)
295+
stmt = (
296+
insert(GtfsDatasetChangelog)
297+
.values(
298+
feed_id=feed_uuid,
299+
previous_dataset_id=prev_dataset_uuid,
300+
current_dataset_id=curr_dataset_uuid,
301+
changelog_url=changelog_url,
302+
diff_summary=diff_summary,
314303
)
315-
db_session.execute(stmt)
316-
db_session.commit()
317-
self.logger.info(
318-
"Saved changelog record for %s -> %s",
319-
self.base_dataset_stable_id,
320-
self.new_dataset_stable_id,
321-
)
322-
else:
323-
self.logger.info(
324-
"[TEMP] Would upsert gtfs_dataset_changelog: feed_id=%s previous=%s current=%s url=%s summary=%s",
325-
feed_uuid,
326-
prev_dataset_uuid,
327-
curr_dataset_uuid,
328-
changelog_url,
329-
diff_summary,
304+
.on_conflict_do_update(
305+
constraint="gtfs_dataset_changelog_previous_current_key",
306+
set_={
307+
"changelog_url": changelog_url,
308+
"diff_summary": diff_summary,
309+
"generated_at": GtfsDatasetChangelog.generated_at.default,
310+
},
330311
)
312+
)
313+
db_session.execute(stmt)
314+
db_session.commit()
315+
self.logger.info(
316+
"Saved changelog record for %s -> %s",
317+
self.base_dataset_stable_id,
318+
self.new_dataset_stable_id,
319+
)

infra/functions-python/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,8 @@ resource "google_cloudfunctions2_function" "gtfs_change_tracker" {
12821282
GCP_REGION = var.gcp_region
12831283
DATASETS_BUCKET_NAME = "${var.datasets_bucket_name}-${var.environment}"
12841284
DATASETS_BUCKET_MOUNT = "/mobilitydata-datasets"
1285-
GTFS_DIFF_DUCKDB_TMPDIR = "/tmp/in-memory"
1285+
# GTFS_DIFF_DUCKDB_TMPDIR: directs DuckDB spill files to the in-memory volume.
1286+
GTFS_DIFF_DUCKDB_TMPDIR = "/tmp/in-memory"
12861287
}
12871288
available_memory = local.function_gtfs_change_tracker_config.memory
12881289
timeout_seconds = local.function_gtfs_change_tracker_config.timeout

0 commit comments

Comments
 (0)