Skip to content

Commit

Permalink
Finally got it at least working, now I really need to make it fast by…
Browse files Browse the repository at this point in the history
… having some control over the loading graph
  • Loading branch information
initialed85 committed Aug 19, 2024
1 parent cd0ef12 commit b1a967c
Show file tree
Hide file tree
Showing 79 changed files with 27,313 additions and 16,981 deletions.
67 changes: 66 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints
39 changes: 22 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ function teardown() {
}
trap teardown exit

# ensure we've got a djangolang executable available (required for templating)
if [[ "${FORCE_UPDATE}" == "1" ]] || ! command -v djangolang >/dev/null 2>&1; then
GOPRIVATE="${GOPRIVATE:-}" go install github.com/initialed85/djangolang@latest
GOPRIVATE="${GOPRIVATE:-}" go get -u github.com/initialed85/djangolang@latest
fi

# we need oapi-codegen to generate the client for use by Go code
if ! command -v oapi-codegen; then
# # we need oapi-codegen to generate the client for use by Go code
if ! command -v oapi-codegen >/dev/null 2>&1; then
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@main
fi

Expand All @@ -32,6 +26,12 @@ if ! docker compose ps | grep camry | grep postgres | grep healthy >/dev/null 2>
exit 1
fi

# ensure we've got a djangolang executable available (required for templating)
if [[ "${FORCE_UPDATE_DJANGOLANG}" == "1" ]] || ! command -v djangolang >/dev/null 2>&1; then
GOPRIVATE="${GOPRIVATE:-}" go install github.com/initialed85/djangolang@latest
GOPRIVATE="${GOPRIVATE:-}" go get -u github.com/initialed85/djangolang@latest
fi

# introspect the database and generate the Djangolang API
# note: the environment variables are coupled to the environment described in docker-compose.yaml
echo -e "\ngenerating the api..."
Expand All @@ -44,18 +44,23 @@ DJANGOLANG_API_ROOT=/api ./pkg/api/bin/api dump-openapi-json >./schema/openapi.j
# generate the client for use by the frontend
echo -e "\ngenerating typescript client..."
cd frontend
if [[ "${FORCE_UPDATE}" == "1" ]]; then
if [[ "${SKIP_UPDATE_FRONTEND}" != "1" ]]; then
npm ci
fi
npm run openapi-typescript
npm run prettier
cd ..

# generate the client for use by Go code
echo -e "\ngenerating go client..."
mkdir -p ./pkg/api_client
oapi-codegen --generate 'types,client,spec' -package api_client -o ./pkg/api_client/client.go ./schema/openapi.json
go mod tidy
goimports -w .
go get ./...
go fmt ./...
# generate the client for use by Python code
mkdir -p object_detector/
openapi-generator-cli generate -i schema/openapi.json -g python -o object_detector/

# TODO: disabled for now- some bug in the 3rd party generator doesn't like $ref or something
# # generate the client for use by Go code
# echo -e "\ngenerating go client..."
# mkdir -p ./pkg/api_client
# oapi-codegen --generate 'types,client,spec' -package api_client -o ./pkg/api_client/client.go ./schema/openapi.json
# go mod tidy
# goimports -w .
# go get ./...
# go fmt ./...
15 changes: 12 additions & 3 deletions database/migrations/00001_initial.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ CREATE INDEX video_ended_at ON public.video (ended_at);

CREATE INDEX video_camera_id_ended_at ON public.video (camera_id, ended_at);

CREATE INDEX video_file_name ON public.video (file_name);

CREATE INDEX video_camera_id_file_name ON public.video (camera_id, file_name);

CREATE INDEX video_status ON public.video (status);

CREATE INDEX video_camera_id_status ON public.video (camera_id, status);

--
-- detection
--
Expand All @@ -107,6 +115,7 @@ CREATE TABLE
score float NOT NULL,
centroid Point NOT NULL,
bounding_box Polygon NOT NULL,
video_id uuid NOT NULL REFERENCES public.video (id),
camera_id uuid NOT NULL REFERENCES public.camera (id)
);

Expand All @@ -118,11 +127,11 @@ CREATE INDEX detection_class_id_seen_at ON public.detection (class_id, seen_at);

CREATE INDEX detection_class_name_seen_at ON public.detection (class_name, seen_at);

CREATE INDEX detection_camera_id_seen_at ON public.detection (camera_id, seen_at);
CREATE INDEX detection_video_id_seen_at ON public.detection (video_id, seen_at);

CREATE INDEX detection_camera_id_class_id_seen_at ON public.detection (camera_id, class_id, seen_at);
CREATE INDEX detection_video_id_class_id_seen_at ON public.detection (video_id, class_id, seen_at);

CREATE INDEX detection_camera_id_class_name_seen_at ON public.detection (camera_id, class_name, seen_at);
CREATE INDEX detection_video_id_class_name_seen_at ON public.detection (video_id, class_name, seen_at);

--
-- triggers for camera
Expand Down
Loading

0 comments on commit b1a967c

Please sign in to comment.