-
Notifications
You must be signed in to change notification settings - Fork 0
How to use
Start the server again:
sudo make
To run our example road segmenter example_roadnet_to_db.py
, open a new terminal, then make a bash-shell in your container with:
sudo docker exec -t -i vapi_django_1 /bin/bash
When you're inside, run:
python /vapi/apps/data/road_segmenting/example_roadnet_to_db.py
You can also run example_create_test_prod_data.py
to simulate production data input here, which requires you to have a apps/Driftsdata_SubSet_Small.geojson
file:
python /vapi/apps/data/example_create_test_prod_data.py
Default is the first command defined in the Makefile
, and as such will be run by simply running make
Target | Command | Description |
---|---|---|
default | build start | Both builds and starts the containers. |
build | docker-compose build | Builds the containers. |
start | docker-compose up | Starts the server. |
down | docker-compose down | Tears down the containers, handy for clearing out the database. |
stop | docker-compose stop | Stops your containers if they're already running mode. |
restart | stop start | Stops and starts (restart) your containers. |
migrate | docker-compose run --rm django python manage.py migrate | Applies existing migrations to the database |
migrations | docker-compose run --rm django python manage.py makemigrations | Creates new migrations based on changes made to models. |
superuser | docker-compose run --rm django python manage.py createsuperuser | Initiates Django superuser creation. |
psql | docker-compose exec -u postgres postgres psql | Starts a psql shell, handy for manually interacting with the database. |
test | test-only lint-only | Runs our linting and tests. We advice you to run this before pushing your code to Github, to ensure your code will pass our Travis CI build. |
lint-only | docker-compose run --rm django flake8 apps/ docker-compose run --rm django isort -c |
Only runs linting (flake8 and isort) |
test-only | docker-compose run --rm django py.test --cov-config=setup.cfg --cov=apps | Only runs our own tests |
An example is provided in backend/data/example_create_test_prod_data.py
Inputting production data is done by doing a POST request to /api/prod-data/. An example written in python is shown below.
url = 'http://localhost:8000/api/prod-data/'
r = requests.post(url, json=data, auth=(username, password))
print("Status: {}\n{}".format(r.status_code, r.text))
The data variable is on the format:
[
{
"time": "YYYY-MM-DDTHH:MM:SS+HH:MM",
"startlat": <float>,
"startlong": <float>,
"endlat": <float>,
"endlong": <float>,
# The fields below are optional
"dry_spreader_active": <True/False>,
"plow_active": <True/False>,
"wet_spreader_active": <True/False>,
"brush_active": <True/False>
"material_type_code": <Integer>
},
...
]
The production data will be mapped to the road network. The map matching prioritizes segments that are close in distance and as parallel as possible. Production data points that don't map will be ignored and if none if the data points map a 200 OK response will be returned as opposed to 201 CREATED and the number of mapped data if any of the production data get added.
-
Product related
-
Development process and guidelines
-
Sprints
-
Testing
-
-
Old notes