Files
artcraft/_develop/docs/local_development/general_setup.md
T
Brandon Thomas 14d028ea8a docs
2023-09-19 18:34:39 -04:00

3.0 KiB

FakeYou dev setup (bare metal)

This document describes how to run the FakeYou infrastructure on your development machine's bare metal (no containers).

The applications (binary targets) you might be interested in running include:

  • storyteller-web, the HTTP API server
  • download-job, which downloads models from the web and stores them in GCS
  • inference-job, which downloads models from GCS and executes them

Database Setup

Linux Install

Install the following libraries, and see the notes further below about MySQL on Ubuntu 20.04.

jq # for combining mysql codegen outputs
libmysqlclient-dev
libsqlite3-dev
mysql-server
pkgconf # if using openssl instead of rustls

Mac Install

brew install mysql

If mysql -uroot fails, reboot the machine:

sudo reboot now

Database Migrations (Install Tooling)

To manage the database and perform migrations, install the Rust tools diesel and sqlx.

We'll be using diesel to manage the migrations, but sqlx within the app to actually perform queries. Diesel is an immature ORM, which isn't a good tech bet, so we use sqlx as at-compile-time typesafe SQL.

Install the SQLx CLI (Linux + Mac):

cargo install sqlx-cli --no-default-features --features rustls,mysql,sqlite

Install the Diesel CLI (Linux + Mac):

cargo install diesel_cli \
  --no-default-features \
  --features mysql,sqlite

Mac has issues and requires a few dependencies to be installed:

brew install libpq

Database Migrations (Run)

To run pending migrations, execute the following:

diesel migration run

[Fix] Sqlx Error on Linux when Performing Schema Migrations

You might get this error message during migration,

Encountered unknown type for Mysql: enum
thread 'main' panicked at 'internal error: entered unreachable code: Mysql only supports a closed set of types.
                         If you ever see this error message please open an issue at https://github.com/diesel-rs/diesel containing a dump of your schema definition.', diesel_cli/src/print_schema.rs:310:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I haven't found the cause (it doesn't happen on Mac), but the migrations appear to work regardless of this error message. You can essentially ignore it.

[Fix] Can't connect to local MySQL after install on Ubuntu

[Fix] MySql on Ubuntu 22.04

Should work largely out of the box. We'll need a dev account:

# Connect to mysql:
# sudo mysql -u root -p (password is "root")

use mysql;
CREATE USER 'storyteller'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON storyteller.* TO 'storyteller'@'localhost';

Then verify with ./dev_mysql_connect.sh