You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complete full stack environment for dev & CI (#502)
* Diagram of primary models & relationships
* Add helpful commands to README, begin quickstart
* Simplify local dev by renaming local.yml to the default name
* Use env variable to specify API URL for backend
* Add compose config for CI workflows
* Bring back backend tests, fix most of them, disable a few of them
* Create sample data after migrations run
Platform for processing and reviewing images from automated insect monitoring stations.
3
+
Platform for processing and reviewing images from automated insect monitoring stations. Intended for collaborating on multi-deployment projects, maintaining metadata and orchestrating multiple machine learning pipelines for analysis.
4
4
5
-
[](https://github.com/cookiecutter/cookiecutter-django/)
- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
19
+
Install and run the frontend:
19
20
20
-
- To create a **superuser account**, use this command:
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
36
+
_TODO! Make a pre-built frontend available in the Docker compose stack._
To run the tests, check your test coverage, and generate an HTML coverage report:
47
+
#### Configuration
35
48
36
-
$ coverage run -m pytest
37
-
$ coverage html
38
-
$ open htmlcov/index.html
49
+
By default this will try to connect to http://localhost:8000 for the backend API. Use the env var `API_PROXY_TARGET` to change this. You can create multiple `.env` files in the `ui/` directory for different environments or configurations. For example, use `yarn start --mode staging` to load `.env.staging` and point the `API_PROXY_TARGET` to a remote backend.
Moved to [Live reloading and SASS compilation](https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html#sass-compilation-live-reloading).
47
58
48
-
###Celery
59
+
#### Helpful Commands
49
60
50
-
This app comes with Celery.
61
+
##### Watch the logs of Django & the backend workers
Please note: For Celery's import magic to work, it is important _where_ the celery commands are run. If you are in the same folder with _manage.py_, you should be right.
60
74
61
-
To run [periodic tasks](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html), you'll need to start the celery beat scheduler service. You can start it as a standalone process:
75
+
##### Run tests
62
76
63
77
```bash
64
-
cd ami
65
-
celery -A config.celery_app beat
78
+
docker compose run --rm django python manage.py test
66
79
```
67
80
68
-
or you can embed the beat service inside a worker with the `-B` option (not recommended for production use):
81
+
##### Run tests with a specific pattern in the test name
69
82
70
83
```bash
71
-
cd ami
72
-
celery -A config.celery_app worker -B -l info
84
+
docker compose run --rm django python manage.py test -k pattern
73
85
```
74
86
75
-
###Email Server
87
+
##### Launch the Django shell:
76
88
77
-
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server [MailHog](https://github.com/mailhog/MailHog) with a web interface is available as docker container.
89
+
docker-compose exec django python manage.py shell
78
90
79
-
Container mailhog will start automatically when you will run all docker containers.
80
-
Please check [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html) for more details how to start all containers.
91
+
>>> from ami.main.models import SourceImage, Occurrence
With MailHog running, to view messages that are sent by your application, open your browser and go to `http://127.0.0.1:8025`
94
+
##### Install backend dependencies locally for IDE support (Intellisense, etc):
83
95
84
-
### Sentry
85
-
86
-
Sentry is an error logging aggregator service. You can sign up for a free account at <https://sentry.io/signup/?code=cookiecutter> or download and host it yourself.
87
-
The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application.
docker compose run --rm django python manage.py graph_models -a -o models.dot --dot
118
+
dot -Tsvg models.dot > models.svg
119
+
```
99
120
100
121
## Project Data Storage
101
122
@@ -118,3 +139,31 @@ Bucket: ami
118
139
- Upload some test images to a subfolder in the `ami` bucket (one subfolder per deployment)
119
140
- Give the bucket or folder anonymous access using the "Anonymous access" button in the Minio web interface.
120
141
- You _can_ test private buckets and presigned URLs, but you will need to add an entry to your local /etc/hosts file to map the `minio` hostname to localhost.
142
+
143
+
## Email
144
+
145
+
The local environment uses the `console` email backend. To view emails sent by the platform, check the console output (run the `docker compose logs -f django celeryworker` command).
146
+
147
+
## Database
148
+
149
+
The local environment uses a local PostgreSQL database in a Docker container.
150
+
151
+
### Backup and Restore
152
+
153
+
docker compose run --rm postgres backup
154
+
155
+
### Reset the database
156
+
157
+
docker compose run --rm django python manage.py reset_db
158
+
159
+
### Show backups
160
+
161
+
docker compose run --rm postgres backups
162
+
163
+
### Restore a backup
164
+
165
+
docker compose run --rm postgres restore <backup_file_name>
166
+
167
+
### Load fixtures with test data
168
+
169
+
docker compose run --rm django python manage.py migrate
0 commit comments