aarnphm / dha-ps

Product similarity API using distilBERT. Deployed on Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dha-ps

CircleCI Go Report Card PkgGoDev

backend to determine product similarity

database comms / routing can be found under ingress, semantic search related tasks are under pr otherwise

Instruction for local development

  • Requirements:
    • Go
    • docker - docker-compose (Optional)
    • poetry (Optional)
    • minikube and kubectl, then enable metrics-server with minikube addons add metrics-server
  • Run make build to generate docker images, then to deploy k8s locally do kubectl apply -f deploy/minikube.yml.
  • Check kubectl get svc and you will get something like shown:
NAME                 TYPE           CLUSTER-IP   EXTERNAL-IP       PORT(S)           AGE
ingress-service      LoadBalancer   10.0.0.96    <pending>         80:31939/TCP      72s
kubernetes           ClusterIP      10.0.0.1     <none>            443/TCP           38h
recommender-service  NodePort       10.0.3.13    <none>            30000:32610/TCP   71s
  • create your own secrets in .env with following format below, then apply with kubectl create secrets generic <pr/ingress> --from-env-file <dir/to/env file>. You can read more about secrets on kubernetes documentation.
# for ingress services
PG_HOST=...
PG_PORT=...
PG_USER=...
PG_PASSWORD=...
PG_DATABASE=...
PG_SEARCHPATH=...
APIKEY=...
# for price_recommender services
MONGO_URI=...
  • Note that EXTERNAL-IP will be configured depends on each cloud provider. If using minikube just run minikube service ingress-service to get the IP addr, then you should receive
"ProxyAlive":true,
"StreamAlive":true
  • You can access /swaggerui/ for API docs
  • Included a cuda-enabled images for price_recommender. Make sure you have nvidia-docker install. After do so run:
cd price_recommender 
docker build -t aar0npham/dha-pr:with-cuda -f build/with-cuda.dockerfile .
docker run -it --gpus=all -p 5000:5000 aar0npham/dha-pr:with-cuda
  • Below is an example with minikube:

Notes

  • This serves as an API
  • the model is currently running on insufficient and unorganized test database as a mock test
  • please refers to nlp/net.py for more details on models
  • Assumed that product_info exists in database
  • A recent bug with GCP, and docker-compose relating to OpenSSL, fix here
  • NodePort when cofiguring usually get auto-assigned by the system. Assign at 32610

price_recommender

  • find a data model that fits with textile industry
  • what are the requirements of the garment industry?
  • what are the domain of garment industry?
  • targets, users, location?
  • labor cost?

Todo

  • ☐ running model in browser?
  • ☐ makes swagger functionable with k8s
cd ingress && docker build -t aar0npham/dha-pr-swagger:latest -f build/swagger.dockerfile .
docker run -p 8081:8080 -e URLS="[{url:'/swagger.yml', name: 'Ingress Server'}]" aar0npham/dha-pr-swagger:latest
  • ☒ k8s deployment
  • ☒ generate godoc
  • ☒ prepare info from db for inference
  • ☒ streamline product_info into python server
  • ☒ added rate limiter for middleware
  • ☒ Find a model that fits with the requirement
  • ☒ Train on another dataset

About

Product similarity API using distilBERT. Deployed on Kubernetes

License:Apache License 2.0


Languages

Language:Go 57.9%Language:Python 32.6%Language:Dockerfile 4.9%Language:Makefile 2.4%Language:HTML 2.3%