Skip to content

Commit 21ab430

Browse files
authored
Revert "Bring back cml CI and change what we print (#2605)"
This reverts commit 20398e4.
1 parent 20398e4 commit 21ab430

9 files changed

+139
-606
lines changed

.github/workflows/build-dbt.yml

+26-12
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,39 @@ jobs:
6161
destination: 'calitp-ci-artifacts/${{github.workflow}}/run_id=${{github.run_id}}/job=${{github.job}}/target/'
6262
# Only do visualization if we actually changed models and we are merging against main
6363
- uses: tj-actions/changed-files@v35
64-
if: ${{ github.event_name == 'pull_request' }}
64+
if: github.event.pull_request.base.ref == 'main'
6565
id: changed-files-warehouse
6666
with:
6767
files: 'warehouse/models/**/*.sql'
68-
# install a specific version of node before cml https://github.com/iterative/cml/issues/1377
69-
- uses: actions/setup-node@v1
70-
with:
71-
node-version: '16'
72-
- uses: iterative/setup-cml@v1
73-
if: steps.changed-files-warehouse.outputs.any_changed == 'true'
74-
- name: Create GitHub comment
68+
- name: Create report.md
7569
if: steps.changed-files-warehouse.outputs.any_changed == 'true'
76-
env:
77-
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7870
run: |
7971
cd warehouse
8072
gsutil cp -r gs://calitp-dbt-artifacts/latest/ .
81-
poetry run python scripts/visualize.py ci-report
82-
cml comment update target/report.md
73+
echo "Warehouse report 📦" >> report.md
74+
echo "### New models 🌱" >> report.md
75+
poetry run dbt --no-use-colors ls --resource-type model --select state:new --state ./latest | grep "^calitp_warehouse\." | sed "s/calitp_warehouse\.//g" >> report.md
76+
echo "### Changed models 🔀" >> report.md
77+
poetry run dbt --no-use-colors ls --resource-type model --select state:modified --exclude state:new --state ./latest | grep "^calitp_warehouse\." | sed "s/calitp_warehouse\.//g" >> report.md
78+
# echo "### DAG" >> report.md
79+
# poetry run dbt --no-use-colors ls --resource-type model --select state:modified --state ./latest | grep "^calitp_warehouse\." | sed 's/^/--include /g' | xargs poetry run python scripts/visualize.py man --output=target/dag.png
80+
# TODO: add these back
81+
# echo "" >> report.md
82+
# echo '![](./target/dag.png "Changed models")' >> report.md
83+
- uses: peter-evans/find-comment@v2
84+
if: steps.changed-files-warehouse.outputs.any_changed == 'true'
85+
id: fc
86+
with:
87+
issue-number: ${{ github.event.pull_request.number }}
88+
comment-author: 'github-actions[bot]'
89+
body-includes: Warehouse report
90+
- uses: peter-evans/create-or-update-comment@v3
91+
if: steps.changed-files-warehouse.outputs.any_changed == 'true'
92+
with:
93+
comment-id: ${{ steps.fc.outputs.comment-id }}
94+
issue-number: ${{ github.event.pull_request.number }}
95+
body-path: warehouse/report.md
96+
edit-mode: replace
8397

8498
build_push:
8599
name: package warehouse image

warehouse/macros/gtfs_rt_unnest_column_count_distinct.sql

-8
This file was deleted.

warehouse/models/intermediate/gtfs/int_gtfs_rt__service_alerts_trip_day_map_grouping.sql

-78
This file was deleted.

warehouse/models/intermediate/gtfs/int_gtfs_rt__trip_updates_trip_day_map_grouping.sql

-77
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,49 @@
11
{{
22
config(
3-
materialized='table',
3+
materialized='incremental',
4+
incremental_strategy='insert_overwrite',
5+
partition_by={
6+
'field': 'dt',
7+
'data_type': 'date',
8+
'granularity': 'day',
9+
},
410
cluster_by='base64_url',
511
)
612
}}
713

8-
914
WITH service_alerts AS (
10-
SELECT *,
11-
-- https://gtfs.org/realtime/reference/#message-tripdescriptor
15+
SELECT * FROM {{ ref('fct_service_alerts_messages_unnested') }}
16+
WHERE {{ gtfs_rt_dt_where() }}
17+
),
18+
19+
fct_service_alerts_trip_summaries AS (
20+
SELECT
21+
-- https://gtfs.org/realtime/reference/#message-tripdescriptor
1222
{{ dbt_utils.generate_surrogate_key([
13-
'calculated_service_date',
23+
'dt',
1424
'base64_url',
1525
'trip_id',
26+
'trip_route_id',
27+
'trip_direction_id',
1628
'trip_start_time',
29+
'trip_start_date',
1730
]) }} as key,
18-
FROM {{ ref('int_gtfs_rt__service_alerts_trip_day_map_grouping') }}
19-
),
20-
21-
re_aggregate AS (
22-
SELECT
23-
key,
24-
calculated_service_date,
31+
dt,
2532
base64_url,
2633
trip_id,
2734
trip_route_id,
2835
trip_direction_id,
2936
trip_start_time,
3037
trip_start_date,
31-
trip_schedule_relationship,
32-
feed_timezone,
33-
COUNT(DISTINCT unnested_message_ids) AS num_distinct_message_ids,
34-
COUNT(DISTINCT unested_header_timestamps) AS num_distinct_header_timestamps,
35-
COUNT(DISTINCT unnested_message_keys) AS num_distinct_message_keys,
36-
MIN(min_extract_ts) AS min_extract_ts,
37-
MAX(max_extract_ts) AS max_extract_ts,
38-
MIN(min_header_timestamp) AS min_header_timestamp,
39-
MAX(max_header_timestamp) AS max_header_timestamp,
40-
ARRAY_AGG(DISTINCT unnested_alert_content)
41-
AS alert_content_array
38+
COUNT(DISTINCT id) AS num_distinct_message_ids,
39+
COUNT(DISTINCT header_timestamp) AS num_distinct_header_timestamps,
40+
ARRAY_AGG(DISTINCT service_alert_message_key) AS service_alert_message_keys,
41+
MIN(_extract_ts) AS min_extract_ts,
42+
MAX(_extract_ts) AS max_extract_ts,
43+
MIN(header_timestamp) AS min_header_timestamp,
44+
MAX(header_timestamp) AS max_header_timestamp,
4245
FROM service_alerts
43-
LEFT JOIN UNNEST(message_ids_array) AS unnested_message_ids
44-
LEFT JOIN UNNEST(header_timestamps_array) AS unested_header_timestamps
45-
LEFT JOIN UNNEST(message_keys_array) AS unnested_message_keys
46-
LEFT JOIN UNNEST(alert_content_array) AS unnested_alert_content
47-
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
48-
),
49-
50-
fct_service_alerts_trip_summaries AS (
51-
SELECT
52-
key,
53-
calculated_service_date,
54-
base64_url,
55-
trip_id,
56-
trip_route_id,
57-
trip_direction_id,
58-
trip_start_time,
59-
trip_start_date,
60-
trip_schedule_relationship,
61-
feed_timezone,
62-
num_distinct_message_ids,
63-
num_distinct_header_timestamps,
64-
num_distinct_message_keys,
65-
min_extract_ts,
66-
max_extract_ts,
67-
min_header_timestamp,
68-
max_header_timestamp,
69-
ARRAY_AGG(
70-
STRUCT<message_id string, cause string, effect string, header string, description string >
71-
(JSON_VALUE(unnested_alert, '$.message_id'),
72-
JSON_VALUE(unnested_alert, '$.cause'),
73-
JSON_VALUE(unnested_alert, '$.effect'),
74-
JSON_VALUE(unnested_alert, '$.header'),
75-
JSON_VALUE(unnested_alert, '$.description')))
76-
AS alert_content_array
77-
FROM re_aggregate
78-
LEFT JOIN UNNEST(alert_content_array) AS unnested_alert
79-
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
80-
)
46+
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8
47+
)
8148

8249
SELECT * FROM fct_service_alerts_trip_summaries

0 commit comments

Comments
 (0)