Skip to content

Commit 92cfa3c

Browse files
committed
fix shell script line endings and yaml parsing
1 parent c12b623 commit 92cfa3c

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf

scripts/run_data_pipeline.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ if [ ! -f "$PATHS_FILE" ]; then
1212
fi
1313

1414
_yaml_val() {
15-
grep -E "^${1}:" "$PATHS_FILE" | sed 's/^[^:]*:[[:space:]]*//' | tr -d '"'\''
15+
python - "$1" <<'PYEOF'
16+
import sys
17+
key = sys.argv[1]
18+
with open("configs/paths.local.yaml") as f:
19+
for line in f:
20+
line = line.strip()
21+
if line.startswith(key + ":"):
22+
val = line.split(":", 1)[1].strip().strip('"').strip("'")
23+
print(val)
24+
break
25+
PYEOF
1626
}
1727

1828
CXR_ROOT="$(_yaml_val mimic_cxr_root)"
1929
IV_ROOT="$(_yaml_val mimic_iv_root)"
2030
ED_ROOT="$(_yaml_val mimic_iv_ed_root)"
21-
LAB_DIR="$(_yaml_val labevents_dir)"
2231

2332
if [ -z "$CXR_ROOT" ] || [ -z "$ED_ROOT" ]; then
2433
echo "ERROR: mimic_cxr_root and mimic_iv_ed_root must be set in $PATHS_FILE" >&2

scripts/run_lab_pipeline.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ if [ ! -f "$PATHS_FILE" ]; then
1212
fi
1313

1414
_yaml_val() {
15-
grep -E "^${1}:" "$PATHS_FILE" | sed 's/^[^:]*:[[:space:]]*//' | tr -d '"'\''
15+
python - "$1" <<'PYEOF'
16+
import sys
17+
key = sys.argv[1]
18+
with open("configs/paths.local.yaml") as f:
19+
for line in f:
20+
line = line.strip()
21+
if line.startswith(key + ":"):
22+
val = line.split(":", 1)[1].strip().strip('"').strip("'")
23+
print(val)
24+
break
25+
PYEOF
1626
}
1727

1828
IV_ROOT="$(_yaml_val mimic_iv_root)"

0 commit comments

Comments
 (0)