mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-31 23:47:51 +00:00
145 lines
5.4 KiB
Bash
Executable File
145 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This is complicated since we're now in a more complex Rust workspace with
|
|
# multiple projects and targets.
|
|
|
|
# NB(2022-01-31): For some reason, 'storyteller-web', despite importing the obs queries
|
|
# via the `database_queries` shared library, started to exclude these queries. It was
|
|
# working, but mysteriously stopped. I'm using this more complicated setup with jq-based
|
|
# json merge as a stop gap.
|
|
|
|
# NB: This format can be used without changing directory:
|
|
# SQLX_OFFLINE=true cargo sqlx prepare -- --bin storyteller-web --manifest-path crates/service/storyteller_web/Cargo.toml
|
|
|
|
set -euxo pipefail
|
|
|
|
# NB: Database used by desktop app for AiChatBot sidecar.
|
|
# Make sure it has been migrated (use aichatbot-sidecar app directory as root).
|
|
SQLITE_DATABASE_PATH=./runtime_data/database.db
|
|
|
|
# NB: OpenSSL is broken on Ubuntu 22.04 (this is documented elsewhere)
|
|
# See https://askubuntu.com/a/1403961
|
|
# For some reason, the choice of "rustls" or the vendored openssl is not persistent between calls.
|
|
#cargo install sqlx-cli --features openssl-vendored,mysql
|
|
|
|
build_shared_mysql_database_library() {
|
|
# NB: For now, this is our monolithic DB that serves all of our microservices (gross)
|
|
# It's a single package so that queries can be shared (again, gross)
|
|
pushd crates/lib/database_queries
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged
|
|
popd
|
|
}
|
|
|
|
build_shared_sqlite_database_library() {
|
|
# NB(1): These are *SQLite* queries for the desktop AiChatBot app.
|
|
# NB(2): Make sure to run migrations first.
|
|
# NB(3): SqLite has trouble with relative paths, so we copy the file to /
|
|
cp $SQLITE_DATABASE_PATH /tmp
|
|
pushd crates/lib/sqlite_queries
|
|
DATABASE_URL=sqlite:///tmp/database.db cargo sqlx prepare --merged
|
|
popd
|
|
}
|
|
|
|
build_storyteller_web_app() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/web/storyteller_web
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin storyteller-web # NB: Because multiple binary targets
|
|
popd
|
|
}
|
|
|
|
build_download_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/download_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin download-job
|
|
popd
|
|
}
|
|
|
|
build_tts_download_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/tts_download_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin tts-download-job
|
|
popd
|
|
}
|
|
|
|
build_inference_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/inference_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin inference-job
|
|
popd
|
|
}
|
|
|
|
build_tts_inference_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/tts_inference_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin tts-inference-job
|
|
popd
|
|
}
|
|
|
|
build_w2l_download_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/w2l_download_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin w2l-download-job
|
|
popd
|
|
}
|
|
|
|
build_w2l_inference_job() {
|
|
# NB: This imports the inference/upload job queries
|
|
# It should also import the shared database lib queries, but something(???) broke.
|
|
pushd crates/service/job/w2l_inference_job
|
|
SQLX_OFFLINE=true cargo sqlx prepare --merged -- --bin w2l-inference-job
|
|
popd
|
|
}
|
|
|
|
combine_sqlx_queries() {
|
|
|
|
|
|
#jq: error: Could not open file crates/programs/aichatbot-sidecar/sqlx-data.json: No such file or directory
|
|
#jq: error: Could not open file crates/service/web/storyteller_web/sqlx-data.json: No such file or directory
|
|
|
|
|
|
# Merge multiple JSON files into a single dictionary.
|
|
# https://stackoverflow.com/a/24904276
|
|
jq -s '.[0] * .[1]' \
|
|
crates/lib/database_queries/sqlx-data.json \
|
|
crates/lib/sqlite_queries/sqlx-data.json \
|
|
crates/service/web/storyteller_web/sqlx-data.json \
|
|
crates/service/job/download_job/sqlx-data.json \
|
|
crates/service/job/tts_download_job/sqlx-data.json \
|
|
crates/service/job/inference_job/sqlx-data.json \
|
|
crates/service/job/tts_inference_job/sqlx-data.json \
|
|
crates/service/job/w2l_download_job/sqlx-data.json \
|
|
crates/service/job/w2l_inference_job/sqlx-data.json \
|
|
> sqlx-data.json
|
|
}
|
|
|
|
cleanup_temp_files() {
|
|
rm crates/lib/database_queries/sqlx-data.json \
|
|
crates/lib/sqlite_queries/sqlx-data.json \
|
|
crates/service/web/storyteller_web/sqlx-data.json \
|
|
crates/service/job/download_job/sqlx-data.json \
|
|
crates/service/job/tts_download_job/sqlx-data.json \
|
|
crates/service/job/inference_job/sqlx-data.json \
|
|
crates/service/job/tts_inference_job/sqlx-data.json \
|
|
crates/service/job/w2l_download_job/sqlx-data.json \
|
|
crates/service/job/w2l_inference_job/sqlx-data.json
|
|
}
|
|
|
|
build_shared_mysql_database_library
|
|
build_shared_sqlite_database_library
|
|
build_storyteller_web_app
|
|
build_download_job
|
|
build_tts_download_job
|
|
build_inference_job
|
|
build_tts_inference_job
|
|
build_w2l_download_job
|
|
build_w2l_inference_job
|
|
combine_sqlx_queries
|
|
cleanup_temp_files
|
|
|