Spaces:
Running
Running
| set -euo pipefail | |
| DUMP_REPO="${GENMOD_DUMP_REPO:-cnil/genmod-dump-neo4j}" | |
| DUMP_REVISION="${GENMOD_DUMP_REVISION:-main}" | |
| DUMP_BASE_URL="https://huggingface.co/datasets/${DUMP_REPO}/resolve/${DUMP_REVISION}" | |
| AUTH_HEADER="Authorization: Bearer ${HF_TOKEN}" | |
| # Load the database backup. Metadata is optional for compatibility with the | |
| # original dump; the application then falls back to its historical date. | |
| wget --header="${AUTH_HEADER}" "${DUMP_BASE_URL}/system.dump" -O /backups/system.dump | |
| wget --header="${AUTH_HEADER}" "${DUMP_BASE_URL}/neo4j.dump" -O /backups/neo4j.dump | |
| if ! wget --header="${AUTH_HEADER}" "${DUMP_BASE_URL}/database_metadata.json" \ | |
| -O /backups/database_metadata.json; then | |
| rm -f /backups/database_metadata.json | |
| fi | |
| neo4j-admin database load --expand-commands system --from-path=/backups --overwrite-destination=true | |
| neo4j-admin database load --expand-commands neo4j --from-path=/backups --overwrite-destination=true | |
| # start database | |
| /startup/docker-entrypoint.sh neo4j & | |
| # The Community importer cannot create indexes through --schema. Ensure that | |
| # dumps produced by the refresh Job receive the required indexes before the | |
| # application starts serving searches. | |
| until cypher-shell -u neo4j -p genealogiemodeles \ | |
| "RETURN 1;" >/dev/null 2>&1; do | |
| sleep 2 | |
| done | |
| cypher-shell -u neo4j -p genealogiemodeles \ | |
| "CREATE INDEX IF NOT EXISTS FOR (m:Model) ON (m.name); | |
| CREATE INDEX IF NOT EXISTS FOR (a:Author) ON (a.name); | |
| CREATE INDEX IF NOT EXISTS FOR (d:Dataset) ON (d.name); | |
| CALL db.awaitIndexes(600);" | |
| # start tool | |
| python3 /application_neo4j/app.py neo4j genealogiemodeles & | |
| # wait for any process to exit | |
| wait -n | |
| # exit with status of process that exited first | |
| exit $? | |