Skip to content

Commit

Permalink
Merge pull request #160 from dara-network/procfile-dev-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy authored Sep 25, 2023
2 parents 2e56cec + b77c662 commit 7b6199d
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
APP_BASE_URL=http://localhost:3000
API_BASE_URL=http://localhost:8080
GS_BUCKET_NAME=dara-c1b52.appspot.com
PGHOST=127.0.0.1
PGPORT=5432
PGUSER=gooey
PGDATABASE=gooey
PGPASSWORD=gooey
22 changes: 22 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# this Procfile can be run with `honcho`, and it can start multiple processes
# with a single command. Handy for development. All of the below commands are
# setup to run in dev mode only, and not in prod.
#
# The assumptions here are that:
# - you have redis installed but not running as a background service
# - you have rabbitmq installed but not running as a background service
# - your local gooey-ui repo is at ../gooey-ui/
#
# You can comment any of the processes if you have background services running
# for them. You can also change the path for the `ui` process from `../gooey-ui/`
# to wherever your local gooey-ui directory is.

api: poetry run uvicorn server:app --host 127.0.0.1 --port 8080 --reload

admin: poetry run python manage.py runserver 127.0.0.1:8000

dashboard: poetry run streamlit run Home.py --server.port 8501 --server.headless true

celery: poetry run celery -A celeryapp worker

ui: cd ../gooey-ui/; PORT=3000 npm run dev
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
## Setup

* Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile)
* Install [poetry](https://python-poetry.org/docs/)
* Create & active a virtualenv (e.g. `poetry shell`)
* Create & activate a virtualenv (e.g. `poetry shell`)
* Run `poetry install --with dev`
* Install [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/), [rabbitmq](https://www.rabbitmq.com/install-homebrew.html), and [postgresql](https://formulae.brew.sh/formula/postgresql@15) (e.g. `brew install redis rabbitmq postgresql@15`)
* Enable background services for `redis`, `rabbitmq`, and `postgresql` (e.g. with `brew services start redis` and similar for `rabbitmq` and `postgresql`)
* Use `sqlcreate` helper to create a user and database for gooey:
* `./manage.py sqlcreate | psql postgres`
* make sure you are able to access the database with `psql -W -U gooey gooey` (and when prompted for password, entering `gooey`)
* Create an `.env` file from `.env.example` (Read [12factor.net/config](https://12factor.net/config))
* Run `./manage.py migrate`
* Install the zbar library (`brew install zbar`)

## Run

### API + GUI server

```bash
uvicorn server:app --host 0.0.0.0 --port 8080 --reload
```

Open [localhost:8080](localhost:8080) in your browser

### Admin Site
You can start all required processes in one command with Honcho:

```bash
python3 manage.py runserver 0.0.0.0:8000
```shell
$ poetry run honcho start
```

Open [localhost:8000](localhost:8000) in your browser

The processes that it starts are defined in [`Procfile`](Procfile).
Currently they are these:

### Usage Dashboard
| Service | Port |
| ------- | ---- |
| API + GUI Server | 8080 |
| Admin site | 8000 |
| Usage dashboard | 8501 |
| Celery | - |
| UI | 3000 |

```
streamlit run Home.py --server.port 8501
```
This default startup assumes that Redis, RabbitMQ, and PostgreSQL are installed and running
as background services on ports 6379, 5672, and 5432 respectively.
It also assumes that the gooey-ui repo can be found at `../gooey-ui/` (adjacent to where the
gooey-server repo sits). You can open the Procfile and comment this out if you don't need
to run it.

Open [localhost:8501](localhost:8501) in your browser
**Note:** the Celery worker must be manually restarted on code changes. You
can do this by stopping and starting Honcho.

## To run any recipe

* Save `serviceAccountKey.json` to project root
* Install & start [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/)
* Install & start [rabbitmq](https://www.rabbitmq.com/install-homebrew.html)
* Run the celery worker (**Note:** you must manually restart it on code changes)
```bash
celery -A celeryapp worker
```

## To connect to our GPU cluster

Expand Down
Loading

0 comments on commit 7b6199d

Please sign in to comment.