Skip to content

Commit e8658d5

Browse files
authored
Publish action update (#1886)
* remove branches kw that probably isn't needed * drop all tables on the derived schema first * add copy concepts to version specific schema * fix to target physionet-data
1 parent 679037f commit e8658d5

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Generate tables on BigQuery
22

33
on:
44
release:
5-
types: [published]
6-
branches: ["main"]
5+
types: [released]
6+
7+
env:
8+
MIMIC_IV_VERSION: 3_1
79

810
jobs:
911
create-tables:
@@ -25,4 +27,9 @@ jobs:
2527
run: |
2628
echo "Generating tables on BigQuery"
2729
cd mimic-iv/concepts
28-
bash make_concepts.sh
30+
bash make_concepts.sh
31+
32+
- name: Copy to release specific schema
33+
run: |
34+
echo "Copying tables to release specific schema: mimiciv_${MIMIC_IV_VERSION}_derived"
35+
bash mimic-iv/concepts/copy_concepts_to_versioned_schema.sh ${MIMIC_IV_VERSION}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# This script copies the concepts in the BigQuery table mimiciv_derived to mimiciv_${VERSION}_derived.
3+
if [ -z "$$1" ]; then
4+
echo "Usage: $0 <version>"
5+
exit 1
6+
fi
7+
export SOURCE_DATASET=mimiciv_derived
8+
export TARGET_DATASET=mimiciv_$1_derived
9+
export PROJECT_ID=physionet-data
10+
11+
# check if the target dataset exists
12+
if bq ls --datasets --project_id ${PROJECT_ID} | grep -q ${TARGET_DATASET}; then
13+
echo "Using existing dataset ${TARGET_DATASET}."
14+
# drop the existing tables in the target dataset
15+
# this includes ones which may not be in the source dataset
16+
for TABLE in `bq ls ${PROJECT_ID}:${TARGET_DATASET} | cut -d' ' -f3`;
17+
do
18+
# skip the first line of dashes
19+
if [[ "${TABLE:0:2}" == '--' ]]; then
20+
continue
21+
fi
22+
bq rm -f -q ${PROJECT_ID}:${TARGET_DATASET}.${TABLE}
23+
done
24+
else
25+
echo "Creating dataset ${PROJECT_ID}:${TARGET_DATASET}"
26+
bq mk --dataset ${PROJECT_ID}:${TARGET_DATASET}
27+
fi
28+
29+
echo "Copying tables from ${SOURCE_DATASET} to ${TARGET_DATASET}."
30+
for TABLE in `bq ls ${PROJECT_ID}:${SOURCE_DATASET} | cut -d' ' -f3`;
31+
do
32+
# skip the first line of dashes
33+
if [[ "${TABLE:0:2}" == '--' ]]; then
34+
continue
35+
fi
36+
bq cp -f -q ${PROJECT_ID}:${SOURCE_DATASET}.${TABLE} ${PROJECT_ID}:${TARGET_DATASET}.${TABLE}
37+
done

mimic-iv/concepts/make_concepts.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ export TARGET_DATASET=mimiciv_derived
66
# note: max_rows=1 *displays* only one row, but all rows are inserted into the destination table
77
BQ_OPTIONS='--quiet --headless --max_rows=0 --use_legacy_sql=False --replace'
88

9+
# drop the existing tables in the target dataset
10+
for TABLE in `bq ls physionet-data:${TARGET_DATASET} | cut -d' ' -f3`;
11+
do
12+
# skip the first line of dashes
13+
if [[ "${TABLE:0:2}" == '--' ]]; then
14+
continue
15+
fi
16+
echo "Dropping table ${TARGET_DATASET}.${TABLE}"
17+
bq rm -f -q ${TARGET_DATASET}.${TABLE}
18+
done
19+
920
# generate a few tables first as the desired order isn't alphabetical
1021
for table_path in demographics/icustay_times;
1122
do

0 commit comments

Comments
 (0)