Skip to content

Commit 272069d

Browse files
authored
Merge pull request #2035 from MIT-LCP/alistair/more_gh_action_shenanigans
Fix GH actions and make concepts deterministic
2 parents cb8ca47 + 321dc69 commit 272069d

51 files changed

Lines changed: 473 additions & 375 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/download-demo/action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ inputs:
1010
runs:
1111
using: "composite"
1212
steps:
13-
# The demo datasets are version-pinned and immutable, so a static key never
14-
# goes stale
1513
- name: Restore demo data from cache
1614
id: cache
1715
uses: actions/cache@v4
@@ -27,6 +25,10 @@ runs:
2725
shell: bash
2826
working-directory: ${{ inputs.dest }}
2927
run: |
28+
set -euo pipefail
3029
echo "Downloading MIMIC-IV and MIMIC-IV-ED demo from PhysioNet."
31-
wget -r -N -c -q --reject "index.html*" -nH -np --cut-dirs=3 https://physionet.org/files/mimic-iv-demo/2.2/
32-
wget -r -N -c -q --reject "index.html*" -nH -np --cut-dirs=3 https://physionet.org/files/mimic-iv-ed-demo/2.2/
30+
# -4 forces IPv4
31+
# -c resumes any partially downloaded files on retry.
32+
wget_opts="-4 --tries=5 --retry-connrefused --waitretry=10 --timeout=60"
33+
wget -r -N -c -q $wget_opts --reject "index.html*" -nH -np --cut-dirs=3 https://physionet.org/files/mimic-iv-demo/2.2/
34+
wget -r -N -c -q $wget_opts --reject "index.html*" -nH -np --cut-dirs=3 https://physionet.org/files/mimic-iv-ed-demo/2.2/

.github/actions/setup-duckdb/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ runs:
1313
- name: Install DuckDB CLI
1414
shell: bash
1515
run: |
16-
wget -q "https://github.com/duckdb/duckdb/releases/download/v${{ inputs.version }}/duckdb_cli-linux-amd64.zip"
16+
set -euo pipefail
17+
url="https://github.com/duckdb/duckdb/releases/download/v${{ inputs.version }}/duckdb_cli-linux-amd64.zip"
18+
# -4 forces IPv4, plus retries to survive transient network failures
19+
wget -q -4 --tries=5 --retry-connrefused --waitretry=10 --timeout=60 \
20+
-O duckdb_cli-linux-amd64.zip "$url"
1721
unzip -o duckdb_cli-linux-amd64.zip -d /usr/local/bin
1822
rm duckdb_cli-linux-amd64.zip
1923
duckdb --version

.github/workflows/build-psql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
image: postgres:17
1515
env:
1616
POSTGRES_PASSWORD: postgres
17+
# Force byte-order (C) collation so string ordering matches DuckDB's
18+
# binary sort.
19+
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
1720
options: >-
1821
--health-cmd pg_isready
1922
--health-interval 10s

.github/workflows/concepts-psql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
image: postgres:17
1616
env:
1717
POSTGRES_PASSWORD: postgres
18+
# Force byte-order (C) collation so string ordering matches DuckDB's
19+
# binary sort.
20+
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
1821
options: >-
1922
--health-cmd pg_isready
2023
--health-interval 10s

.github/workflows/equivalence.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
workflow_call:
66

77
env:
8-
# Tables with known cross-engine differences
9-
IGNORE_TABLES: "first_day_gcs,suspicion_of_infection,oxygen_delivery,bg,first_day_bg,first_day_bg_art,kdigo_uo,kdigo_stages,urine_output_rate"
8+
# If tables are known to be non-equivalent, list them here (comma delimited) to ignore them in the diff.
9+
IGNORE_TABLES: ""
1010

1111
jobs:
1212
diff:
@@ -18,6 +18,9 @@ jobs:
1818
image: postgres:17
1919
env:
2020
POSTGRES_PASSWORD: postgres
21+
# Force byte-order (C) collation so string ordering matches DuckDB's
22+
# binary sort.
23+
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=C --lc-ctype=C"
2124
options: >-
2225
--health-cmd pg_isready
2326
--health-interval 10s

.github/workflows/mysql.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ jobs:
1818

1919
- name: Extract demo data to local folder
2020
run: |
21-
mv hosp/*.csv.gz ./
22-
mv icu/*.csv.gz ./
23-
mv ed/*.csv.gz ./
21+
# download-demo provides the gzipped CSVs under hosp/, icu/ and ed/.
22+
# Flatten every nested CSV into the working directory, where the mysql
23+
# load.sql scripts expect them (e.g. LOAD DATA INFILE 'admissions.csv').
24+
# Using find keeps this robust to how deeply the files are nested.
25+
# NB: copy (not move) so hosp/, icu/ and ed/ retain their contents
26+
# and the cache is preserved.
27+
find . -mindepth 2 -name '*.csv.gz' -exec cp -t ./ {} +
2428
gzip -d *.csv.gz
2529
2630
- name: Start MySQL service

mimic-iv/concepts/demographics/weight_durations.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ WITH wt_stg AS (
66
, c.charttime
77
, CASE WHEN c.itemid = 226512 THEN 'admit'
88
ELSE 'daily' END AS weight_type
9-
-- TODO: eliminate obvious outliers if there is a reasonable weight
10-
, c.valuenum AS weight
9+
, ROUND(CAST(c.valuenum AS NUMERIC), 3) AS weight
1110
FROM `physionet-data.mimiciv_icu.chartevents` c
1211
WHERE c.valuenum IS NOT NULL
1312
AND c.itemid IN
@@ -16,6 +15,7 @@ WITH wt_stg AS (
1615
, 224639 -- Daily Weight
1716
)
1817
AND c.valuenum > 0
18+
AND c.valuenum < 1500
1919
)
2020

2121
-- assign ascending row number

mimic-iv/concepts/firstday/first_day_gcs.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ WITH gcs_final AS (
2121
, g.gcs_unable
2222
-- This sorts the data by GCS
2323
-- rn = 1 is the the lowest total GCS value
24+
-- tie-break on charttime (unique per stay) so the component columns
25+
-- are deterministic across SQL engines when multiple measurements
26+
-- share the same minimum GCS
2427
, ROW_NUMBER() OVER
2528
(
2629
PARTITION BY g.stay_id
27-
ORDER BY g.gcs
30+
ORDER BY g.gcs ASC NULLS LAST, g.charttime DESC NULLS LAST
2831
) AS gcs_seq
2932
FROM `physionet-data.mimiciv_icu.icustays` ie
3033
-- Only get data for the first 24 hours

mimic-iv/concepts/firstday/first_day_rrt.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ SELECT
55
, ie.stay_id
66
, MAX(dialysis_present) AS dialysis_present
77
, MAX(dialysis_active) AS dialysis_active
8-
, STRING_AGG(DISTINCT dialysis_type, ', ') AS dialysis_type
8+
, STRING_AGG(DISTINCT dialysis_type, ', ' ORDER BY dialysis_type)
9+
AS dialysis_type
910
FROM `physionet-data.mimiciv_icu.icustays` ie
1011
LEFT JOIN `physionet-data.mimiciv_derived.rrt` rrt
1112
ON ie.stay_id = rrt.stay_id

mimic-iv/concepts/make_concepts.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ do
6363

6464
# skip certain tables where order matters
6565
skip=0
66-
for skip_table in meld icustay_times first_day_sofa kdigo_stages vasoactive_agent norepinephrine_eqivalent_dose
66+
for skip_table in meld icustay_times first_day_sofa kdigo_stages vasoactive_agent norepinephrine_equivalent_dose sepsis3
6767
do
6868
if [[ "${tbl}" == "${skip_table}" ]]; then
6969
skip=1
@@ -83,7 +83,7 @@ done
8383

8484
echo "Now generating tables which were skipped due to depending on other tables."
8585
# generate tables after the above, and in a specific order to ensure dependencies are met
86-
for table_path in firstday/first_day_sofa organfailure/kdigo_stages organfailure/meld medication/vasoactive_agent medication/norepinephrine_equivalent_dose;
86+
for table_path in firstday/first_day_sofa organfailure/kdigo_stages organfailure/meld medication/vasoactive_agent medication/norepinephrine_equivalent_dose sepsis/sepsis3;
8787
do
8888
table=`echo $table_path | rev | cut -d/ -f1 | rev`
8989

0 commit comments

Comments
 (0)