Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

v1.0.0 Release #21

Merged
merged 67 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8599b21
created driver for mongo
edoriggio Mar 5, 2024
c712230
updated workflow
edoriggio Mar 5, 2024
d9cf31b
new mongodb documents will now be automatically embedded and saved in…
edoriggio Mar 7, 2024
954b4fe
started working on sync for deleted documents + added documentation w…
edoriggio Mar 9, 2024
fa79f2e
testing pre-commit hooks
edoriggio Mar 9, 2024
33ee906
added swaggerhub documentation
edoriggio Mar 10, 2024
9269fb7
added swaggerhub documentation
edoriggio Mar 10, 2024
4e565e8
fixed ci pipeline
edoriggio Mar 10, 2024
e816ae3
fixed docker files + almost finished sync module
edoriggio Mar 10, 2024
49c3bd2
updated documentation
edoriggio Mar 10, 2024
ca23328
finished listeners for deletions and insertions
edoriggio Mar 12, 2024
e604ef7
Merge pull request #5 from APIScout/1-mongo-middleman-should-save-new…
edoriggio Mar 12, 2024
3b92748
testing ci docker image deployment
edoriggio Mar 13, 2024
d49e766
removed conditional in ci workflow file
edoriggio Mar 13, 2024
3e3554c
deploy job now needs test job to succeed
edoriggio Mar 13, 2024
6e0efba
added conditions to deploy job
edoriggio Mar 13, 2024
9bafb9f
added endpoint for retrieving specifications
edoriggio Mar 15, 2024
dd88a83
added routes for adding and getting specifications
edoriggio Mar 21, 2024
be68f70
fixed workflow file
edoriggio Mar 21, 2024
c5e19ac
Merge pull request #10 from APIScout/8-substitute-mongo-sync-with-ing…
edoriggio Mar 21, 2024
ab683a3
fixed MongoResponse Object
edoriggio Mar 22, 2024
0f65351
fixed MongoResponse Object
edoriggio Mar 22, 2024
340cd2c
sync pipeline also handles reconciliation
edoriggio Mar 22, 2024
04c89c3
added some documentation
edoriggio Mar 22, 2024
9ad820c
Merge pull request #7 from APIScout/4-retrieve-embeddings-and-perform…
edoriggio Mar 22, 2024
0f8d4d8
Update deploy-backend.yml
edoriggio Mar 22, 2024
0f19848
removed not needed build args
edoriggio Mar 22, 2024
3c251b6
updated the documentation
edoriggio Mar 25, 2024
5fe4165
added semantic version analysis and mapping for es index
edoriggio Mar 25, 2024
c24dcd5
started modelling and parsing the dsl
edoriggio Mar 29, 2024
a21eb84
started working on dsl parsing
edoriggio Apr 9, 2024
7c79c2b
added tests for dsl + started working on dsl to elastic query parser
edoriggio Apr 9, 2024
9f59ffa
fixed es filter parser
edoriggio Apr 10, 2024
3e08853
Merge pull request #17 from APIScout/11-create-dsl-for-retrieval-of-d…
edoriggio Apr 10, 2024
e9f5f32
fixed error in swag command
edoriggio Apr 10, 2024
f2d0048
finished search endpoint, needs to be fine-tuned
edoriggio Apr 11, 2024
89f6c01
fine-tuning the search endpoint
edoriggio Apr 19, 2024
9e8c6c1
finished adding metrics
edoriggio Apr 21, 2024
83e645e
updated dependency
edoriggio Apr 21, 2024
f24d328
Merge pull request #18 from APIScout/12-perform-approximate-knn-search
edoriggio Apr 21, 2024
661c950
fixed error messages
edoriggio Apr 21, 2024
e9661e9
removed unnecessary print
edoriggio Apr 21, 2024
0bd8980
fixed percentage on sync
edoriggio Apr 21, 2024
9ee458d
fixed percentage on sync
edoriggio Apr 21, 2024
f1b8371
added skip parameter on sync
edoriggio Apr 23, 2024
06f6fc4
fixed sync remaining time
edoriggio Apr 23, 2024
69122d7
fixed sync remaining time
edoriggio Apr 23, 2024
392bd97
added route for preprocessing
edoriggio Apr 29, 2024
e2c9892
fixed preprocessing regex
edoriggio Apr 29, 2024
e5ba52c
tried splitting endpoint with field filters
edoriggio May 1, 2024
672b053
fixed endpoint
edoriggio May 1, 2024
8819a70
added a filter on the id of the api
edoriggio May 5, 2024
6d32076
fixed minor issue with dsl
edoriggio May 5, 2024
e7b8c79
fixed minor issue with preprocessing
edoriggio May 6, 2024
9aa6b00
return ids in response when indexing
edoriggio May 6, 2024
fe56437
minor
edoriggio May 6, 2024
9a306ae
more changes done to the dsl
edoriggio May 7, 2024
c5e7481
more changes done to the dsl
edoriggio May 7, 2024
c9093cb
minor
edoriggio May 12, 2024
a8acca9
Update knn.go
edoriggio May 13, 2024
65c6f0d
Update knn.go
edoriggio May 13, 2024
debf3db
finished evaluation
edoriggio May 17, 2024
0b3c9f0
Merge pull request #19 from APIScout/15-perform-evaluation-on-the-ret…
edoriggio May 17, 2024
60018a9
Update README.md
edoriggio May 17, 2024
71ad777
added script for tsne
edoriggio May 23, 2024
7037835
finished implementation and evaluation
edoriggio May 28, 2024
e6967a3
Merge pull request #20 from APIScout/15-perform-evaluation-on-the-ret…
edoriggio May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,64 @@
name: Deploy Backend
name: Test and Deploy Backend

on: [ push, pull_request ]
on: [ push ]

jobs:
test:
runs-on: "ubuntu-latest"
steps:
- name: 'Checkout github action'
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup golang
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Install dependencies
run: |
go install gotest.tools/gotestsum@latest
go get ./...

- name: Build
run: go build -o . ./...
- name: Run Tests
run: go build -o ./main ./app

- name: Run tests
run: gotestsum --hide-summary=skipped ./app/tests/... > tests-result.txt

- name: Upload tests result
uses: actions/upload-artifact@v4
with:
name: tests-result
path: tests-result.txt
# deploy:
# if: github.event_name == 'pull_request' && github.ref == 'refs/heads/main'

deploy:
runs-on: ubuntu-latest
needs: test
if: contains('
refs/heads/dev
refs/heads/main
', github.ref)
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/#-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: edoriggio/api-scout

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ go.work
.vscode/
.DS_Store

ca.crt
*.crt
*.config.yml
!config/template.config.yml
models/*
!.keep
!.keep

mongo-ids.txt
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
hooks:
- id: go-unit-tests
# - repo: local
# hooks:
# - id: generate-go-docs
# name: generate-go-docs
# entry: ./scripts/hooks/generate-go-docs.sh
# language: system
# - id: generate-swagger-docs
# name: generate-swagger-docs
# entry: ./scripts/hooks/generate-swagger-docs.sh
# language: system
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ COPY go.* ./
RUN go mod download

COPY . .
RUN go build -o /backend/build/app ./app/cmd/main
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN cd app && swag init
RUN go build -o /backend/build/app /backend/app

FROM alpine:latest

WORKDIR /backend

ENV GIN_MODE="release"
ENV MODELS_HOST="models"
ARG GIN_MODE
ARG MODELS_HOST

COPY --from=builder /backend/build/app /backend/build/app
COPY --from=builder /backend/config /backend/config

EXPOSE 8080
ENTRYPOINT [ "/backend/build/app" ]
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# API Scout - Backend
# API Scout
## Configure

## Set ENV Variables
### Set ENV Variables

The following are the variables that need to be set:

- `GIN_MODE`: In which mode Gin should be running (can be `release` or `debug`)
- `MODELS_HOST`: The hostname of the DL models container (use `models` if in release mode, `127.0.0.1` if in debug mode)

## Downloading USE Model
### Downloading USE Model

To download the Universal Sentence Encoder (USE) model, run the python script in `scripts/download-use.py` by running the following commands (you should run these commands while in the `backend` directory):

Expand All @@ -18,7 +19,7 @@ conda run -n api-scout python ./scripts/download-use.py

You will now have a new directory in `models` called `universal-encoder`. This model will be used by the `docker-compose.yml` file to serve the model in a container.

## Spinning up the Containers
### Spinning up the Containers

For replication purposes, in this repo you will find both a `Dockerfile` and a `docker-compose.yml` file. The `Dockerfile` will create a Docker image with a build of the Golang backend in it. To create the image, simply run:

Expand All @@ -34,6 +35,33 @@ docker-compose up -d

This will create a Docker container for the Golang backend and for the USE model. The backend will now be able to make HTTP calls to the USE model to embed queries and documents. N.B.: The USE container will not expose any ports, it will be called locally by the backend by means of the `be-network` shared network.

## Dependencies
### Dependencies

For the backend to work, both an ElasticSearch instance and a MongoDB instance should be up and running.

## Documentation

To generate and consult the documentation, you can use the following commands.

### Generate Documentation

To generate the documentation, first you need to make sure that you have all the necessary dependencies installed. Run the following commands:

```shell
go install go.abhg.dev/doc2go@latest
npm install -g pagefind@latest
```

Once all dependencies have been installed, run:

```shell
doc2go -config ./app/internal/doc2go.rc ./app/internal/...
```

### Consult Documentation

To consult the documentation of the `app/internal` API, run the following command:

```shell
cd docs && python -m http.server 8000
```
Loading