Alex Latipov commited on
Commit
b9f7267
·
1 Parent(s): 434cda2

Fix HF corporate graph count parsing

Browse files
Files changed (1) hide show
  1. scripts/hf_load_corporate_graph.sh +10 -7
scripts/hf_load_corporate_graph.sh CHANGED
@@ -48,16 +48,19 @@ wait_for_virtuoso() {
48
  }
49
 
50
  graph_count() {
51
- printf "select count(*) from DB.DBA.RDF_QUAD where G = iri_to_id('%s');\n" "${GRAPH_URI}" \
52
- | "$ISQL_BIN" "$ISQL_PORT" "$DBA_USER" "$DBA_PASSWORD" 2>/dev/null \
53
- | python3 - <<'PY'
 
 
 
 
54
  import re
55
- import sys
56
 
57
- text = sys.stdin.read()
58
- matches = re.findall(r'^\s*(\d+)\s*$', text, flags=re.MULTILINE)
59
  print(matches[-1] if matches else "0")
60
- PY
61
  }
62
 
63
  echo "Waiting for Virtuoso before loading corporate graph ..."
 
48
  }
49
 
50
  graph_count() {
51
+ local raw
52
+ raw="$(
53
+ printf "select count(*) from DB.DBA.RDF_QUAD where G = iri_to_id('%s');\n" "${GRAPH_URI}" \
54
+ | "$ISQL_BIN" "$ISQL_PORT" "$DBA_USER" "$DBA_PASSWORD" 2>/dev/null || true
55
+ )"
56
+ RAW_ISQL_OUTPUT="$raw" python3 -c '
57
+ import os
58
  import re
 
59
 
60
+ text = os.environ.get("RAW_ISQL_OUTPUT", "")
61
+ matches = re.findall(r"^\s*(\d+)\s*$", text, flags=re.MULTILINE)
62
  print(matches[-1] if matches else "0")
63
+ '
64
  }
65
 
66
  echo "Waiting for Virtuoso before loading corporate graph ..."