|
1 | | -# model-change-detector |
| 1 | +# Model Change Detector |
| 2 | + |
| 3 | +## About |
| 4 | + |
| 5 | +A utility that detects changes in models. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +```commandline |
| 10 | +py mcd.py <command> <db-connection-string> [--help] [--log-level] |
| 11 | +``` |
| 12 | + |
| 13 | +- `command` is the function to be performed by the utility. The currently supported values are |
| 14 | + - `START`: Marks the start of a new execution by creating a record for the same in the given database and returns an ID of the new execution. |
| 15 | +- `db-connection-string` is a [PostgreSQL Db Connection String](http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#module-sqlalchemy.dialects.postgresql.psycopg2) of the format `postgresql+psycopg2://user:password@host:port/dbname` |
| 16 | + |
| 17 | +### As a script |
| 18 | + |
| 19 | +- Use a local isolated/virtual python environment for this project |
| 20 | +- Install project dependencies |
| 21 | +- `py mcd.py <command> <db-connection-string> [--help] [--log-level]` |
| 22 | + |
| 23 | +_Windows example:_ |
| 24 | + |
| 25 | +```commandline |
| 26 | +py -m venv new-env --clear |
| 27 | +new-env\scripts\activate |
| 28 | +
|
| 29 | +py -m pip install -r requirements.txt |
| 30 | +
|
| 31 | +py mcd.py START postgresql+psycopg2://user:password@host:port/dbname |
| 32 | +``` |
| 33 | + |
| 34 | +### As a package |
| 35 | + |
| 36 | +- Use/create an empty directory |
| 37 | +- Use a local isolated/virtual python environment for this project |
| 38 | +- [Install](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs) this package |
| 39 | +- `py -m mcd <command> <db-connection-string> [--help] [--log-level]` |
| 40 | + |
| 41 | +_Windows example:_ |
| 42 | + |
| 43 | +```commandline |
| 44 | +mkdir new-dir |
| 45 | +cd new-dir |
| 46 | +
|
| 47 | +py -m venv new-env --clear |
| 48 | +new-env\scripts\activate |
| 49 | +
|
| 50 | +pip install -e path\to\model-change-detector |
| 51 | +
|
| 52 | +py -m mcd START postgresql+psycopg2://user:password@host:port/dbname |
| 53 | +``` |
| 54 | + |
| 55 | +## Setup |
| 56 | + |
| 57 | +1. Install pre-requisites |
| 58 | +2. Use a local isolated/virtual python environment for this project |
| 59 | +3. Install project dependencies |
| 60 | +4. Develop and test code changes |
| 61 | +5. Once done, deactivate the virtual environment |
| 62 | + |
| 63 | +### Install pre-requisites |
| 64 | + |
| 65 | +#### Python 3 |
| 66 | + |
| 67 | +Install from [here](https://www.python.org/) _(or your choice of safe software provider)_. During installation, choose the option to _Add to PATH_ and _Custom Installation_ so you can provide the install path to not be the default `C:\Program Files\Python37\` and be outside the `Program Files` directory to say, `C:\Python37\`. This is just a suggestion since there have been issues with updating key python packages once Python is installed within `Program Files` on Windows. |
| 68 | + |
| 69 | +Verify your installation by running the below commands. |
| 70 | + |
| 71 | +```powershell |
| 72 | +py --version |
| 73 | +python --version |
| 74 | +pip --version |
| 75 | +``` |
| 76 | + |
| 77 | +If you end up with multiple accidental/purposeful python installations, use the below in Windows Commandline to figure out where the executables are located. |
| 78 | + |
| 79 | +```cmd |
| 80 | +where py |
| 81 | +where python |
| 82 | +where pip |
| 83 | +``` |
| 84 | + |
| 85 | +### Use a local isolated/virtual python environment for this project |
| 86 | + |
| 87 | +`py -m venv /path/to/new/virtual/environment` _e.g._ `py -m venv new-env` |
| 88 | + |
| 89 | +If you build with `--system-site-packages` directory, your virtual environment will be allowed access to packages from your global site-packages directory. Although, if you want isolation from the global system, do not use this flag. Once you've created a new environment, you need to activate the same. |
| 90 | + |
| 91 | +On Windows: |
| 92 | + |
| 93 | +`path\to\environment\scripts\activate` _e.g._ `new-env\scripts\activate` |
| 94 | + |
| 95 | +On Linux / Mac OS |
| 96 | + |
| 97 | + `source path/to/environment/bin/activate` _e.g._ `source new-env/bin/activate` |
| 98 | + |
| 99 | +You should see the name of your virtual environment in brackets on your terminal line, e.g.: |
| 100 | +``` |
| 101 | +C:\path\to\working\dir: new-env\scripts\activate |
| 102 | +(new-env) C:\path\to\working\dir: _ |
| 103 | +``` |
| 104 | +Any python commands you use will now, work within your virtual environment only. |
| 105 | + |
| 106 | +### Install project dependencies |
| 107 | + |
| 108 | +```powershell |
| 109 | +pip install -r requirements.txt |
| 110 | +``` |
| 111 | + |
| 112 | +### Deactivate the virtual environment |
| 113 | + |
| 114 | +Once done, deactivate the virtual environment with a simple `decativate` command, e.g.: |
| 115 | + |
| 116 | +```commandline |
| 117 | +(new-env) C:\path\to\working\dir: deactivate |
| 118 | +C:\path\to\working\dir: _ |
| 119 | +``` |
0 commit comments