The following instructions have been tested on MacOS Ventura, but they should work on other Unix-based OS.
Please install the following software on your workstation:
-
Clone the GitHub repository:
git clone https://github.com/alan-turing-institute/sqlsynthgen.git
-
In the directory of your local copy, create a virtual environment with all
sqlsynthgendependencies:cd sqlsynthgen poetry install --all-extrasIf you don't need to build the project documentation, the
--all-extrasoption can be omitted. -
Install the git hook scripts. They will run whenever you perform a commit:
pre-commit install --install-hooks
To execute the hooks before a commit, run
pre-commit run --all-files. -
Finally, activate the Poetry shell. Now you're ready to play with the code:
poetry shell
Executing unit tests is straightforward:
cd sqlsynthgen
python -m unittest discover --verbose tests/Functional tests require a PostgreSQL service running. Perform the following steps on your local server:
-
Set the password of user
postgrestopassword:psql -p5432 "postgres" postgres=# \password postgres Enter new password: <password> postgres=# \q
-
From the shell, create and load the
srcdatabase:createdb src cd sqlsynthgen PGPASSWORD=password psql --host=localhost --username=postgres --file=tests/examples/src.dumpWARNING: Some MacOS systems do not recognise the 'en_US.utf8' locale. As a workaround, replace
en_US.utf8withen_US.UTF-8on every*.dumpfile. -
Also, create
dstdatabase:createdb dst PGPASSWORD=password psql --host=localhost --username=postgres --file=tests/examples/dst.dump
-
Finally, run the functional tests. You will need the environment variable
REQUIRES_DBwith a value of1.REQUIRES_DB=1 poetry run python -m unittest discover --verbose tests
cd docs
make htmlWARNING: Some systems won't be able to import the sphinxcontrib.napoleon extension. In that case,
please replace sphinxcontrib.napoleon with sphinx.ext.napoleon in docs/source/conf.py.