File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
6+ VENV_DIR=" $ROOT_DIR /venv"
7+
8+ if [[ ! -d " $VENV_DIR " ]]; then
9+ echo " Creating virtual environment in $VENV_DIR "
10+ python3 -m venv " $VENV_DIR "
11+ fi
12+
13+ source " $VENV_DIR /bin/activate"
14+
15+ if ! python -c " import flask" > /dev/null 2>&1 ; then
16+ echo " Installing Python dependencies"
17+ pip install -r " $ROOT_DIR /requirements.txt"
18+ fi
19+
20+ export NO_LOGIN=" ${NO_LOGIN:- 1} "
21+ export INSECURE_REQUESTS=" ${INSECURE_REQUESTS:- 1} "
22+ export FLASK_APP=" $ROOT_DIR /cre.py"
23+ export FLASK_CONFIG=" ${FLASK_CONFIG:- development} "
24+
25+ echo " Starting OpenCRE on http://127.0.0.1:5000"
26+ exec flask run --host 127.0.0.1 --port 5000
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
5+ DB_PATH=" ${1:- $ROOT_DIR / standards_cache.sqlite} "
6+
7+ if [[ ! -f " $DB_PATH " ]]; then
8+ echo " Database not found: $DB_PATH " >&2
9+ exit 1
10+ fi
11+
12+ echo " Database: $DB_PATH "
13+ du -h " $DB_PATH "
14+
15+ " $ROOT_DIR /venv/bin/python" - " $DB_PATH " << 'PY '
16+ import os
17+ import sqlite3
18+ import sys
19+
20+ db_path = sys.argv[1]
21+ conn = sqlite3.connect(db_path)
22+ cur = conn.cursor()
23+
24+ print(f"size_bytes {os.path.getsize(db_path)}")
25+
26+ tables = [
27+ "node",
28+ "cre",
29+ "cre_links",
30+ "cre_node_links",
31+ "embeddings",
32+ ]
33+
34+ for table in tables:
35+ try:
36+ count = cur.execute(f"select count(*) from {table}").fetchone()[0]
37+ print(f"{table}_count {count}")
38+ except sqlite3.Error as exc:
39+ print(f"{table}_count unavailable ({exc})")
40+
41+ try:
42+ standards = cur.execute(
43+ """
44+ select name, count(*)
45+ from node
46+ where name is not null
47+ group by name
48+ order by count(*) desc, name asc
49+ limit 15
50+ """
51+ ).fetchall()
52+ print("top_standards")
53+ for name, count in standards:
54+ print(f"{name}\t{count}")
55+ except sqlite3.Error as exc:
56+ print(f"top_standards unavailable ({exc})")
57+
58+ conn.close()
59+ PY
You can’t perform that action at this time.
0 commit comments