diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..e36cfaa4e --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +JUSTFILE_DOCKER_USERNAME="" # Your Docker Hub username +JUSTFILE_DOCKER_TOKEN="" # A PAT generated from Docker Hub \ No newline at end of file diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index ab0e31288..834d12a7d 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -1,69 +1,37 @@ name: build -on: - push: - branches: - - master - -jobs: - docker_images: - name: docker images - runs-on: ubuntu-latest - strategy: - matrix: - image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] - steps: - - name: Pull source - uses: actions/checkout@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build docker image - uses: docker/build-push-action@v2.6.1 - with: - context: . - platforms: linux/amd64,linux/arm64 - file: cmd/${{ matrix.image }}/Dockerfile - push: true - tags: zhenghaoz/${{ matrix.image }}:nightly - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Resolve Images on Description - run: | - sed -i -E "s/src=\"assets\//src=\"https:\/\/github.com\/gorse-io\/gorse\/raw\/master\/assets\//" README.md - - - name: Update DockerHub Description - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: zhenghaoz/${{ matrix.image }} - - windows_images: - name: windows images - runs-on: windows-latest - strategy: - matrix: - image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] - steps: - - name: Pull source - uses: actions/checkout@v1 - - - name: Build docker image - run: | - docker login -u $env:DOCKERHUB_USERNAME -p $env:DOCKERHUB_TOKEN - docker build -f cmd/${{ matrix.image }}/Dockerfile.windows ` - -t zhenghaoz/${{ matrix.image }}:nightly-windowsservercore . - docker image push --all-tags zhenghaoz/${{ matrix.image }} - docker logout - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} +# on: +# push: +# branches: +# - master + +# jobs: +# docker_images: +# name: docker images +# runs-on: ubuntu-latest +# strategy: +# matrix: +# image: [gorse-master, gorse-server, gorse-worker] +# steps: +# - name: Pull source +# uses: actions/checkout@v1 + +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 + +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# - name: Build docker image +# uses: docker/build-push-action@v2.6.1 +# with: +# context: . +# platforms: linux/amd64,linux/arm64 +# file: cmd/${{ matrix.image }}/Dockerfile +# push: true +# tags: neurastudios/${{ matrix.image }}:nightly +# cache-from: type=gha +# cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index ca92b376c..71cc96709 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -1,138 +1,138 @@ name: release -on: - release: - types: [published] +# on: +# release: +# types: [published] -jobs: - build-binaries: - name: build binaries - runs-on: ubuntu-latest - steps: - - name: Set up Go 1.21.x - uses: actions/setup-go@v4 - with: - go-version: 1.21.x - id: go +# jobs: +# build-binaries: +# name: build binaries +# runs-on: ubuntu-latest +# steps: +# - name: Set up Go 1.21.x +# uses: actions/setup-go@v4 +# with: +# go-version: 1.21.x +# id: go - - name: Pull source - uses: actions/checkout@v1 +# - name: Pull source +# uses: actions/checkout@v1 - - name: Install gox - run: go install github.com/mitchellh/gox@master +# - name: Install gox +# run: go install github.com/mitchellh/gox@master - - name: Build release - run: > - gox -output="{{.OS}}/{{.Arch}}/{{.Dir}}" \ - -osarch='darwin/arm64 darwin/amd64 windows/arm64 windows/amd64 linux/arm64 linux/amd64' -ldflags=" - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" ./... - env: - CGO_ENABLED: 0 +# - name: Build release +# run: > +# gox -output="{{.OS}}/{{.Arch}}/{{.Dir}}" \ +# -osarch='darwin/arm64 darwin/amd64 windows/arm64 windows/amd64 linux/arm64 linux/amd64' -ldflags=" +# -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' +# -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' +# -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'" ./... +# env: +# CGO_ENABLED: 0 - - name: Install zip - uses: montudor/action-zip@v0.1.1 +# - name: Install zip +# uses: montudor/action-zip@v0.1.1 - - name: Zip binaries - run: | - zip -j gorse_linux_amd64.zip linux/amd64/gorse-* - zip -j gorse_linux_arm64.zip linux/arm64/gorse-* - zip -j gorse_windows_amd64.zip windows/amd64/gorse-* - zip -j gorse_windows_arm64.zip windows/arm64/gorse-* - zip -j gorse_darwin_amd64.zip darwin/amd64/gorse-* - zip -j gorse_darwin_arm64.zip darwin/arm64/gorse-* +# - name: Zip binaries +# run: | +# zip -j gorse_linux_amd64.zip linux/amd64/gorse-* +# zip -j gorse_linux_arm64.zip linux/arm64/gorse-* +# zip -j gorse_windows_amd64.zip windows/amd64/gorse-* +# zip -j gorse_windows_arm64.zip windows/arm64/gorse-* +# zip -j gorse_darwin_amd64.zip darwin/amd64/gorse-* +# zip -j gorse_darwin_arm64.zip darwin/arm64/gorse-* - - name: Upload release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: gorse_*_*.zip - tag: ${{ github.ref }} - overwrite: true - file_glob: true +# - name: Upload release +# uses: svenstaro/upload-release-action@v2 +# with: +# repo_token: ${{ secrets.GITHUB_TOKEN }} +# file: gorse_*_*.zip +# tag: ${{ github.ref }} +# overwrite: true +# file_glob: true - build-docker-images: - name: build docker images - runs-on: ubuntu-latest - strategy: - matrix: - image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] - steps: - - name: Pull source - uses: actions/checkout@v1 +# build-docker-images: +# name: build docker images +# runs-on: ubuntu-latest +# strategy: +# matrix: +# image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] +# steps: +# - name: Pull source +# uses: actions/checkout@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Login to DockerHub +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} - - id: get_version - uses: battila7/get-version-action@v2 +# - id: get_version +# uses: battila7/get-version-action@v2 - - name: Build docker image - if: github.event.release.prerelease == false - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64,linux/arm64 - file: cmd/${{ matrix.image }}/Dockerfile - push: true - tags: | - zhenghaoz/${{ matrix.image }}:latest - zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }} - zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }} +# - name: Build docker image +# if: github.event.release.prerelease == false +# uses: docker/build-push-action@v2 +# with: +# context: . +# platforms: linux/amd64,linux/arm64 +# file: cmd/${{ matrix.image }}/Dockerfile +# push: true +# tags: | +# zhenghaoz/${{ matrix.image }}:latest +# zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }} +# zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }} - - name: Build prerelease docker image - if: github.event.release.prerelease == true - uses: docker/build-push-action@v2 - with: - context: . - platforms: linux/amd64,linux/arm64 - file: cmd/${{ matrix.image }}/Dockerfile - push: true - tags: | - zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }} +# - name: Build prerelease docker image +# if: github.event.release.prerelease == true +# uses: docker/build-push-action@v2 +# with: +# context: . +# platforms: linux/amd64,linux/arm64 +# file: cmd/${{ matrix.image }}/Dockerfile +# push: true +# tags: | +# zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }} - build-windows-images: - name: build windows images - runs-on: windows-latest - strategy: - matrix: - image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] - steps: - - name: Pull source - uses: actions/checkout@v1 +# build-windows-images: +# name: build windows images +# runs-on: windows-latest +# strategy: +# matrix: +# image: [gorse-master, gorse-server, gorse-worker, gorse-in-one] +# steps: +# - name: Pull source +# uses: actions/checkout@v1 - - id: get_version - uses: battila7/get-version-action@v2 +# - id: get_version +# uses: battila7/get-version-action@v2 - - name: Build docker image - if: github.event.release.prerelease == false - run: | - docker login -u $env:DOCKERHUB_USERNAME -p $env:DOCKERHUB_TOKEN - docker build -f cmd/${{ matrix.image }}/Dockerfile.windows ` - -t zhenghaoz/${{ matrix.image }}:windowsservercore ` - -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }}-windowsservercore ` - -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }}-windowsservercore . - docker image push --all-tags zhenghaoz/${{ matrix.image }} - docker logout - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Build docker image +# if: github.event.release.prerelease == false +# run: | +# docker login -u $env:DOCKERHUB_USERNAME -p $env:DOCKERHUB_TOKEN +# docker build -f cmd/${{ matrix.image }}/Dockerfile.windows ` +# -t zhenghaoz/${{ matrix.image }}:windowsservercore ` +# -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.major }}.${{ steps.get_version.outputs.minor }}-windowsservercore ` +# -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }}-windowsservercore . +# docker image push --all-tags zhenghaoz/${{ matrix.image }} +# docker logout +# env: +# DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} +# DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build prerelease docker image - if: github.event.release.prerelease == true - run: | - docker login -u $env:DOCKERHUB_USERNAME -p $env:DOCKERHUB_TOKEN - docker build -f cmd/${{ matrix.image }}/Dockerfile.windows ` - -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }}-windowsservercore . - docker image push --all-tags zhenghaoz/${{ matrix.image }} - docker logout - env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Build prerelease docker image +# if: github.event.release.prerelease == true +# run: | +# docker login -u $env:DOCKERHUB_USERNAME -p $env:DOCKERHUB_TOKEN +# docker build -f cmd/${{ matrix.image }}/Dockerfile.windows ` +# -t zhenghaoz/${{ matrix.image }}:${{ steps.get_version.outputs.version-without-v }}-windowsservercore . +# docker image push --all-tags zhenghaoz/${{ matrix.image }} +# docker logout +# env: +# DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} +# DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b5f4d3501..d1f295270 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Created by https://www.gitignore.io/api/go,windows,jetbrains +.env + ### Go ### # Binaries for programs and plugins *.exe @@ -118,5 +120,4 @@ $RECYCLE.BIN/ *.lnk .vscode - -# End of https://www.gitignore.io/api/go,windows,jetbrains \ No newline at end of file +config.toml \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efb159339..f4dc8c18f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,14 +4,14 @@ Welcome and thank you for considering contributing to Gorse! Reading and following these guidelines will help us make the contribution process easy and effective for everyone involved. It also communicates that you agree to respect the time of the developers managing and developing these open source projects. In return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull requests. -* [Getting Started](#getting-started) - * [Setup Develop Environment](#setup-develop-environment) - * [Option 1: Run an All-in-one Node](#option-1-run-an-all-in-one-node) - * [Option 2: Run Nodes](#option-2-run-nodes) - * [Run Unit Tests](#run-unit-tests) -* [Your First Contribution](#your-first-contribution) - * [Contribution Workflow](#contribution-workflow) -* [Getting Help](#getting-help) +- [Getting Started](#getting-started) + - [Setup Develop Environment](#setup-develop-environment) + - [Option 1: Run an All-in-one Node](#option-1-run-an-all-in-one-node) + - [Option 2: Run Nodes](#option-2-run-nodes) + - [Run Unit Tests](#run-unit-tests) +- [Your First Contribution](#your-first-contribution) + - [Contribution Workflow](#contribution-workflow) +- [Getting Help](#getting-help) ## Getting Started @@ -56,13 +56,13 @@ go run cmd/gorse-master/main.go --config config/config.toml - Start the worker node. ```bash -go run cmd/gorse-worker/main.go +go run cmd/gorse-worker/main.go ``` - Start the server node. ```bash -go run cmd/gorse-server/main.go +go run cmd/gorse-server/main.go ``` ### Run Unit Tests @@ -76,7 +76,7 @@ go test -v ./... The default database URLs are directed to these databases in `storage/docker-compose.yml`. Test databases could be overrode by setting following environment variables: | Environment Value | Default Value | -|-------------------|----------------------------------------------| +| ----------------- | -------------------------------------------- | | `MYSQL_URI` | `mysql://root:password@tcp(127.0.0.1:3306)/` | | `POSTGRES_URI` | `postgres://gorse:gorse_pass@127.0.0.1/` | | `MONGO_URI` | `mongodb://root:password@127.0.0.1:27017/` | @@ -90,7 +90,7 @@ MYSQL_URI=mysql://root:password@tcp(127.0.0.1:4000)/ go test -v ./... ## Your First Contribution -You can start by finding an existing issue with the [help wanted](https://github.com/zhenghaoz/gorse/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) label in the Gorse repository. These issues are well suited for new contributors. Issues can be claimed by publishing an `/assign` comment. +You can start by finding an existing issue with the [help wanted](https://github.com/Neura-Studios/gorse/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) label in the Gorse repository. These issues are well suited for new contributors. Issues can be claimed by publishing an `/assign` comment. ### Contribution Workflow diff --git a/README.md b/README.md index 8190f5e58..43dda9c08 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ ![](https://img.shields.io/github/go-mod/go-version/zhenghaoz/gorse) -[![build](https://github.com/zhenghaoz/gorse/workflows/build/badge.svg)](https://github.com/zhenghaoz/gorse/actions?query=workflow%3Abuild) +[![build](https://github.com/Neura-Studios/gorse/workflows/build/badge.svg)](https://github.com/Neura-Studios/gorse/actions?query=workflow%3Abuild) [![codecov](https://codecov.io/gh/gorse-io/gorse/branch/master/graph/badge.svg)](https://codecov.io/gh/gorse-io/gorse) -[![Go Report Card](https://goreportcard.com/badge/github.com/zhenghaoz/gorse)](https://goreportcard.com/report/github.com/zhenghaoz/gorse) -[![GoDoc](https://godoc.org/github.com/zhenghaoz/gorse?status.svg)](https://godoc.org/github.com/zhenghaoz/gorse) +[![Go Report Card](https://goreportcard.com/badge/github.com/Neura-Studios/gorse)](https://goreportcard.com/report/github.com/Neura-Studios/gorse) +[![GoDoc](https://godoc.org/github.com/Neura-Studios/gorse?status.svg)](https://godoc.org/github.com/Neura-Studios/gorse) [![Discord](https://img.shields.io/discord/830635934210588743)](https://discord.gg/x6gAtNNkAE) [![Twitter Follow](https://img.shields.io/twitter/follow/gorse_io?label=Follow&style=social)](https://twitter.com/gorse_io) @@ -23,7 +23,7 @@ Gorse is an open-source recommendation system written in Go. Gorse aims to be a ## Quick Start -The playground mode has been prepared for beginners. Just set up a recommender system for GitHub repositories by the following commands. +The playground mode has been prepared for beginners. Just set up a recommender system for GitHub repositories by the following commands. - Linux/macOS: @@ -70,16 +70,16 @@ curl http://127.0.0.1:8088/api/recommend/bob?n=10 ```json [ - "mbostock:d3", - "nt1m:material-framework", - "mdbootstrap:vue-bootstrap-with-material-design", - "justice47:f2-vue", - "10clouds:cyclejs-cookie", - "academicpages:academicpages.github.io", - "accenture:alexia", - "addyosmani:tmi", - "1wheel:d3-starterkit", - "acdlite:redux-promise" + "mbostock:d3", + "nt1m:material-framework", + "mdbootstrap:vue-bootstrap-with-material-design", + "justice47:f2-vue", + "10clouds:cyclejs-cookie", + "academicpages:academicpages.github.io", + "accenture:alexia", + "addyosmani:tmi", + "1wheel:d3-starterkit", + "acdlite:redux-promise" ] ``` @@ -108,7 +108,7 @@ In addition, the administrator can perform system monitoring, data import and ex ## Contributors - + diff --git a/base/heap/pq.go b/base/heap/pq.go index badc8449f..273ea0e83 100644 --- a/base/heap/pq.go +++ b/base/heap/pq.go @@ -16,6 +16,7 @@ package heap import ( "container/heap" + "fmt" "github.com/chewxy/math32" mapset "github.com/deckarep/golang-set/v2" @@ -77,7 +78,7 @@ func NewPriorityQueue(desc bool) *PriorityQueue { // Push inserts a new element into the queue. No action is performed on duplicate elements. func (p *PriorityQueue) Push(v int32, weight float32) { if math32.IsNaN(weight) { - panic("NaN weight is forbidden") + panic(fmt.Sprintf("NaN weight is forbidden (value: %v)", v)) } else if !p.lookup.Contains(v) { newItem := Elem[int32, float32]{ Value: v, diff --git a/base/index.go b/base/index.go index d4f6cf9b2..b0d21657f 100644 --- a/base/index.go +++ b/base/index.go @@ -17,7 +17,7 @@ package base import ( "encoding/binary" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/encoding" "io" "reflect" "strconv" diff --git a/base/parallel/parallel.go b/base/parallel/parallel.go index d06e4e9e7..ad35de558 100644 --- a/base/parallel/parallel.go +++ b/base/parallel/parallel.go @@ -15,11 +15,11 @@ package parallel import ( - "github.com/zhenghaoz/gorse/base" + "github.com/Neura-Studios/gorse/base" "sync" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base/task" + "github.com/Neura-Studios/gorse/base/task" "go.uber.org/atomic" "modernc.org/mathutil" ) diff --git a/base/parallel/parallel_test.go b/base/parallel/parallel_test.go index 5b7063e11..a876e2a5e 100644 --- a/base/parallel/parallel_test.go +++ b/base/parallel/parallel_test.go @@ -20,8 +20,8 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/task" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/task" ) func TestParallel(t *testing.T) { diff --git a/base/search/bruteforce.go b/base/search/bruteforce.go index 849c23b2d..0a801c194 100644 --- a/base/search/bruteforce.go +++ b/base/search/bruteforce.go @@ -17,7 +17,8 @@ package search import ( "context" - "github.com/zhenghaoz/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/chewxy/math32" ) var _ VectorIndex = &Bruteforce{} @@ -42,9 +43,12 @@ func (b *Bruteforce) Search(q Vector, n int, prune0 bool) (values []int32, score pq := heap.NewPriorityQueue(true) for i, vec := range b.vectors { if vec != q { - pq.Push(int32(i), q.Distance(vec)) - if pq.Len() > n { - pq.Pop() + distance := math32.Abs(q.Distance(vec)) + if (!math32.IsNaN(distance)) { + pq.Push(int32(i), distance) + if pq.Len() > n { + pq.Pop() + } } } } diff --git a/base/search/hnsw.go b/base/search/hnsw.go index 597b17a43..d6208358e 100644 --- a/base/search/hnsw.go +++ b/base/search/hnsw.go @@ -23,11 +23,11 @@ import ( "github.com/chewxy/math32" mapset "github.com/deckarep/golang-set/v2" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" "go.uber.org/zap" "modernc.org/mathutil" ) diff --git a/base/search/index.go b/base/search/index.go index 12e69390b..b6a0e06c4 100644 --- a/base/search/index.go +++ b/base/search/index.go @@ -21,8 +21,8 @@ import ( "sort" "github.com/chewxy/math32" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/log" "go.uber.org/zap" "modernc.org/sortutil" ) diff --git a/base/search/index_test.go b/base/search/index_test.go index 556e890af..119ec560d 100644 --- a/base/search/index_test.go +++ b/base/search/index_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" - "github.com/zhenghaoz/gorse/model/ranking" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" + "github.com/Neura-Studios/gorse/model/ranking" ) func TestHNSW_InnerProduct(t *testing.T) { diff --git a/base/search/ivf.go b/base/search/ivf.go index 4ddd784b8..ddadccc20 100644 --- a/base/search/ivf.go +++ b/base/search/ivf.go @@ -21,12 +21,12 @@ import ( "sync" "time" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/task" "github.com/chewxy/math32" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/task" "go.uber.org/atomic" "go.uber.org/zap" "modernc.org/mathutil" @@ -108,9 +108,12 @@ func (idx *IVF) Search(q Vector, n int, prune0 bool) (values []int32, scores []f for _, c := range clusters { for _, i := range idx.clusters[c].observations { if idx.data[i] != q { - pq.Push(i, q.Distance(idx.data[i])) - if pq.Len() > n { - pq.Pop() + distance := q.Distance(idx.data[i]) + if (!math32.IsNaN(distance)) { + pq.Push(i, distance) + if pq.Len() > n { + pq.Pop() + } } } } diff --git a/base/search/ivf_test.go b/base/search/ivf_test.go index 407c61594..2b05ea9aa 100644 --- a/base/search/ivf_test.go +++ b/base/search/ivf_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/task" + "github.com/Neura-Studios/gorse/base/task" ) func TestIVFConfig(t *testing.T) { diff --git a/base/task/schedule.go b/base/task/schedule.go index 7f0bbac27..1ed329c08 100644 --- a/base/task/schedule.go +++ b/base/task/schedule.go @@ -20,7 +20,7 @@ import ( "sync" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "go.uber.org/zap" "modernc.org/mathutil" ) diff --git a/base/util.go b/base/util.go index 8c587822a..56a81c4b1 100644 --- a/base/util.go +++ b/base/util.go @@ -15,7 +15,7 @@ package base import ( - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "go.uber.org/zap" ) diff --git a/client/README.md b/client/README.md index db5ab3524..0ae0c485e 100644 --- a/client/README.md +++ b/client/README.md @@ -7,13 +7,13 @@ Go SDK for Gorse recommender system. ## Install ```bash -go get github.com/zhenghaoz/gorse/client@master +go get github.com/Neura-Studios/gorse/client@master ``` ## Usage ```go -import "github.com/zhenghaoz/gorse/client" +import "github.com/Neura-Studios/gorse/client" gorse := client.NewGorseClient("http://127.0.0.1:8087", "api_key") @@ -30,7 +30,6 @@ gorse.GetRecommend("bob", "", 10) ## Test - In the root directory of Gorse source: ```bash diff --git a/cmd/gorse-in-one/Dockerfile b/cmd/gorse-in-one/Dockerfile index 5bb2554cf..b7f70983e 100644 --- a/cmd/gorse-in-one/Dockerfile +++ b/cmd/gorse-in-one/Dockerfile @@ -7,9 +7,9 @@ COPY . gorse RUN cd gorse/cmd/gorse-in-one && \ CGO_ENABLED=0 go build -ldflags=" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" . && \ + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'" . && \ mv gorse-in-one /usr/bin RUN /usr/bin/gorse-in-one --version diff --git a/cmd/gorse-in-one/Dockerfile.windows b/cmd/gorse-in-one/Dockerfile.windows index 8b1878366..f2f979950 100644 --- a/cmd/gorse-in-one/Dockerfile.windows +++ b/cmd/gorse-in-one/Dockerfile.windows @@ -9,9 +9,9 @@ ENV CGO_ENABLED 0 RUN cd gorse/cmd/gorse-in-one; \ go build -ldflags="\" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'\"" .; \ + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'\"" .; \ mv gorse-in-one.exe /gorse-in-one.exe RUN /gorse-in-one.exe --version diff --git a/cmd/gorse-in-one/main.go b/cmd/gorse-in-one/main.go index ea9cd9297..2370eaa1c 100644 --- a/cmd/gorse-in-one/main.go +++ b/cmd/gorse-in-one/main.go @@ -32,13 +32,13 @@ import ( "github.com/juju/errors" "github.com/schollz/progressbar/v3" "github.com/spf13/cobra" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/master" - "github.com/zhenghaoz/gorse/storage" - "github.com/zhenghaoz/gorse/storage/data" - "github.com/zhenghaoz/gorse/worker" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/master" + "github.com/Neura-Studios/gorse/storage" + "github.com/Neura-Studios/gorse/storage/data" + "github.com/Neura-Studios/gorse/worker" "go.uber.org/zap" ) diff --git a/cmd/gorse-master/Dockerfile b/cmd/gorse-master/Dockerfile index 4b0fb1511..589b8a8db 100644 --- a/cmd/gorse-master/Dockerfile +++ b/cmd/gorse-master/Dockerfile @@ -3,7 +3,7 @@ ############################ # STEP 1 build executable binary ############################ -FROM golang:1.21 +FROM golang:1.21 as build WORKDIR /src @@ -16,20 +16,20 @@ COPY . ./ RUN --mount=type=cache,target=/root/.cache/go-build \ cd cmd/gorse-master && \ CGO_ENABLED=0 go build -ldflags=" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" . + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'" . RUN /src/cmd/gorse-master/gorse-master --version ############################ # STEP 2 build a small image ############################ -FROM scratch +FROM alpine -COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -COPY --from=0 /src/cmd/gorse-master/gorse-master /usr/bin/gorse-master +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=build /src/cmd/gorse-master /usr/bin +RUN /usr/bin/gorse-master --version ENV USER root diff --git a/cmd/gorse-master/Dockerfile.windows b/cmd/gorse-master/Dockerfile.windows index 923c3ad2e..2bc71ef9a 100644 --- a/cmd/gorse-master/Dockerfile.windows +++ b/cmd/gorse-master/Dockerfile.windows @@ -9,9 +9,9 @@ ENV CGO_ENABLED 0 RUN cd gorse/cmd/gorse-master; \ go build -ldflags="\" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'\"" .; \ + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'\"" .; \ mv gorse-master.exe /gorse-master.exe RUN /gorse-master.exe --version diff --git a/cmd/gorse-master/main.go b/cmd/gorse-master/main.go index e7505538b..8a69a0fce 100644 --- a/cmd/gorse-master/main.go +++ b/cmd/gorse-master/main.go @@ -18,11 +18,11 @@ import ( "os" "os/signal" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/master" "github.com/spf13/cobra" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/master" "go.uber.org/zap" ) diff --git a/cmd/gorse-server/Dockerfile b/cmd/gorse-server/Dockerfile index 43df19121..923f738a6 100644 --- a/cmd/gorse-server/Dockerfile +++ b/cmd/gorse-server/Dockerfile @@ -16,16 +16,18 @@ COPY . ./ RUN --mount=type=cache,target=/root/.cache/go-build \ cd cmd/gorse-server && \ CGO_ENABLED=0 go build -ldflags=" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" . + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'" . RUN /src/cmd/gorse-server/gorse-server --version ############################ # STEP 2 build a small image ############################ -FROM scratch +FROM alpine:latest + +RUN apk --no-cache add curl COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ diff --git a/cmd/gorse-server/Dockerfile.windows b/cmd/gorse-server/Dockerfile.windows index 7807e4d56..199e32515 100644 --- a/cmd/gorse-server/Dockerfile.windows +++ b/cmd/gorse-server/Dockerfile.windows @@ -9,9 +9,9 @@ ENV CGO_ENABLED 0 RUN cd gorse/cmd/gorse-server; \ go build -ldflags="\" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'\"" .; \ + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'\"" .; \ mv gorse-server.exe /gorse-server.exe RUN /gorse-server.exe --version diff --git a/cmd/gorse-server/main.go b/cmd/gorse-server/main.go index 4d2efc35d..f4db7a6f7 100644 --- a/cmd/gorse-server/main.go +++ b/cmd/gorse-server/main.go @@ -19,9 +19,9 @@ import ( "os/signal" "github.com/spf13/cobra" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/server" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/server" "go.uber.org/zap" ) diff --git a/cmd/gorse-worker/Dockerfile b/cmd/gorse-worker/Dockerfile index 17211a701..e1af752b2 100644 --- a/cmd/gorse-worker/Dockerfile +++ b/cmd/gorse-worker/Dockerfile @@ -3,7 +3,7 @@ ############################ # STEP 1 build executable binary ############################ -FROM golang:1.21 +FROM golang:1.21 as build WORKDIR /src @@ -16,20 +16,20 @@ COPY . ./ RUN --mount=type=cache,target=/root/.cache/go-build \ cd cmd/gorse-worker && \ CGO_ENABLED=0 go build -ldflags=" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'" . + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'" . RUN /src/cmd/gorse-worker/gorse-worker --version ############################ # STEP 2 build a small image ############################ -FROM scratch +FROM alpine -COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ - -COPY --from=0 /src/cmd/gorse-worker/gorse-worker /usr/bin/gorse-worker +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=build /src/cmd/gorse-worker /usr/bin +RUN /usr/bin/gorse-worker --version ENV USER root diff --git a/cmd/gorse-worker/Dockerfile.windows b/cmd/gorse-worker/Dockerfile.windows index de35220b9..50ff9cf23 100644 --- a/cmd/gorse-worker/Dockerfile.windows +++ b/cmd/gorse-worker/Dockerfile.windows @@ -9,9 +9,9 @@ ENV CGO_ENABLED 0 RUN cd gorse/cmd/gorse-worker; \ go build -ldflags="\" \ - -X 'github.com/zhenghaoz/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ - -X 'github.com/zhenghaoz/gorse/cmd/version.BuildTime=$(date)'\"" .; \ + -X 'github.com/Neura-Studios/gorse/cmd/version.Version=$(git describe --tags $(git rev-parse HEAD))' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.GitCommit=$(git rev-parse HEAD)' \ + -X 'github.com/Neura-Studios/gorse/cmd/version.BuildTime=$(date)'\"" .; \ mv gorse-worker.exe /gorse-worker.exe RUN /gorse-worker.exe --version diff --git a/cmd/gorse-worker/main.go b/cmd/gorse-worker/main.go index 9769138e6..395e430f4 100644 --- a/cmd/gorse-worker/main.go +++ b/cmd/gorse-worker/main.go @@ -18,9 +18,9 @@ import ( _ "net/http/pprof" "github.com/spf13/cobra" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/worker" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/worker" "go.uber.org/zap" ) diff --git a/config/config.toml b/config/config.example.toml similarity index 100% rename from config/config.toml rename to config/config.example.toml diff --git a/config/config.go b/config/config.go index 5a44e2f70..f12de5b98 100644 --- a/config/config.go +++ b/config/config.go @@ -32,8 +32,8 @@ import ( "github.com/juju/errors" "github.com/samber/lo" "github.com/spf13/viper" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/storage" "go.opentelemetry.io/otel/exporters/jaeger" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" diff --git a/config/settings.go b/config/settings.go index 0652fc4d0..d47d4c177 100644 --- a/config/settings.go +++ b/config/settings.go @@ -15,10 +15,10 @@ package config import ( - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" ) type Settings struct { diff --git a/go.mod b/go.mod index 433625da2..36f51bb85 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/zhenghaoz/gorse +module github.com/Neura-Studios/gorse go 1.21 diff --git a/justfile b/justfile new file mode 100644 index 000000000..f59772ef9 --- /dev/null +++ b/justfile @@ -0,0 +1,13 @@ +set dotenv-load + +deploy-docker: + docker login -u $JUSTFILE_DOCKER_USERNAME -p $JUSTFILE_DOCKER_TOKEN + docker build -t neurastudios/gorse-master:latest -f cmd/gorse-master/Dockerfile . + docker build -t neurastudios/gorse-server:latest -f cmd/gorse-server/Dockerfile . + docker build -t neurastudios/gorse-worker:latest -f cmd/gorse-worker/Dockerfile . + docker push neurastudios/gorse-master:latest + docker push neurastudios/gorse-server:latest + docker push neurastudios/gorse-worker:latest + +run-dev: + go run cmd/gorse-master/main.go --config master/config.toml \ No newline at end of file diff --git a/master/local_cache.go b/master/local_cache.go index 9bab0082a..57c4ba3fa 100644 --- a/master/local_cache.go +++ b/master/local_cache.go @@ -18,10 +18,10 @@ import ( "encoding/binary" std_errors "errors" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" "go.uber.org/zap" "os" "path/filepath" diff --git a/master/local_cache_test.go b/master/local_cache_test.go index 9f9307406..09be413ef 100644 --- a/master/local_cache_test.go +++ b/master/local_cache_test.go @@ -19,10 +19,10 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/model" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/model" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" ) func newRankingDataset() (*ranking.DataSet, *ranking.DataSet) { diff --git a/master/master.go b/master/master.go index d22e8764a..35c0e166c 100644 --- a/master/master.go +++ b/master/master.go @@ -27,21 +27,21 @@ import ( "github.com/ReneKroon/ttlcache/v2" "github.com/emicklei/go-restful/v3" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/sizeof" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/protocol" - "github.com/zhenghaoz/gorse/server" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/sizeof" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/protocol" + "github.com/Neura-Studios/gorse/server" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" "go.uber.org/zap" diff --git a/master/master_test.go b/master/master_test.go index a58277645..4323ea5aa 100644 --- a/master/master_test.go +++ b/master/master_test.go @@ -18,10 +18,10 @@ import ( "testing" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" ) type MasterTestSuite struct { diff --git a/master/metrics.go b/master/metrics.go index 48902d0b4..1f541bf60 100644 --- a/master/metrics.go +++ b/master/metrics.go @@ -21,7 +21,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/cache" ) const ( diff --git a/master/metrics_test.go b/master/metrics_test.go index 4a2b225ec..8c6baf8bb 100644 --- a/master/metrics_test.go +++ b/master/metrics_test.go @@ -19,7 +19,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/cache" ) func TestOnlineEvaluator(t *testing.T) { diff --git a/master/rest.go b/master/rest.go index 77e4b95c8..faead18b1 100644 --- a/master/rest.go +++ b/master/rest.go @@ -27,6 +27,17 @@ import ( "strings" "time" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/server" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "github.com/araddon/dateparse" mapset "github.com/deckarep/golang-set/v2" restfulspec "github.com/emicklei/go-restful-openapi/v2" @@ -37,17 +48,6 @@ import ( "github.com/mitchellh/mapstructure" "github.com/rakyll/statik/fs" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/server" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" "go.uber.org/zap" ) @@ -304,6 +304,7 @@ func (m *Master) dashboard(response http.ResponseWriter, request *http.Request) _, err := staticFileSystem.Open(request.RequestURI) if request.RequestURI == "/" || os.IsNotExist(err) { if !m.checkLogin(request) { + log.Logger().Info("redirect1") http.Redirect(response, request, "/login", http.StatusFound) log.Logger().Info(fmt.Sprintf("%s %s", request.Method, request.URL), zap.Int("status_code", http.StatusFound)) return @@ -347,6 +348,7 @@ func (m *Master) login(response http.ResponseWriter, request *http.Request) { server.InternalServerError(restful.NewResponse(response), err) return } else if !isValid { + log.Logger().Info("redirect2") http.Redirect(response, request, "login?msg=incorrect", http.StatusFound) log.Logger().Info("POST /login", zap.Int("status_code", http.StatusUnauthorized)) return @@ -362,12 +364,14 @@ func (m *Master) login(response http.ResponseWriter, request *http.Request) { Path: "/", } http.SetCookie(response, cookie) + log.Logger().Info("redirect3") http.Redirect(response, request, "/", http.StatusFound) log.Logger().Info("POST /login", zap.Int("status_code", http.StatusUnauthorized)) return } } else if m.Config.Master.DashboardUserName != "" || m.Config.Master.DashboardPassword != "" { if name != m.Config.Master.DashboardUserName || pass != m.Config.Master.DashboardPassword { + log.Logger().Info("redirect4") http.Redirect(response, request, "login?msg=incorrect", http.StatusFound) log.Logger().Info("POST /login", zap.Int("status_code", http.StatusUnauthorized)) return @@ -386,11 +390,13 @@ func (m *Master) login(response http.ResponseWriter, request *http.Request) { Path: "/", } http.SetCookie(response, cookie) + log.Logger().Info("redirect5") http.Redirect(response, request, "/", http.StatusFound) log.Logger().Info("POST /login", zap.Int("status_code", http.StatusFound)) return } } else { + log.Logger().Info("redirect6") http.Redirect(response, request, "/", http.StatusFound) log.Logger().Info("POST /login", zap.Int("status_code", http.StatusFound)) } @@ -407,6 +413,7 @@ func (m *Master) logout(response http.ResponseWriter, request *http.Request) { MaxAge: -1, } http.SetCookie(response, cookie) + log.Logger().Info("redirect7") http.Redirect(response, request, "/login", http.StatusFound) log.Logger().Info(fmt.Sprintf("%s %s", request.Method, request.RequestURI), zap.Int("status_code", http.StatusFound)) } diff --git a/master/rest_test.go b/master/rest_test.go index cb23f7656..ed8d04a77 100644 --- a/master/rest_test.go +++ b/master/rest_test.go @@ -34,12 +34,12 @@ import ( "github.com/samber/lo" "github.com/steinfletcher/apitest" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/server" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/server" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "google.golang.org/protobuf/proto" ) diff --git a/master/rpc.go b/master/rpc.go index 11c743829..0a57e1a48 100644 --- a/master/rpc.go +++ b/master/rpc.go @@ -21,10 +21,10 @@ import ( "strings" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/protocol" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/protocol" "go.uber.org/zap" "google.golang.org/grpc/peer" ) diff --git a/master/rpc_test.go b/master/rpc_test.go index 9c537b6a2..d0e03446d 100644 --- a/master/rpc_test.go +++ b/master/rpc_test.go @@ -23,15 +23,15 @@ import ( "github.com/ReneKroon/ttlcache/v2" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/protocol" - "github.com/zhenghaoz/gorse/server" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/protocol" + "github.com/Neura-Studios/gorse/server" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) diff --git a/master/tasks.go b/master/tasks.go index e8ba09203..9beaac170 100644 --- a/master/tasks.go +++ b/master/tasks.go @@ -26,20 +26,20 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/search" - "github.com/zhenghaoz/gorse/base/sizeof" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/search" + "github.com/Neura-Studios/gorse/base/sizeof" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "go.uber.org/atomic" "go.uber.org/zap" "google.golang.org/protobuf/proto" diff --git a/master/tasks_test.go b/master/tasks_test.go index 6750c43d0..65a4d79cb 100644 --- a/master/tasks_test.go +++ b/master/tasks_test.go @@ -21,9 +21,9 @@ import ( "time" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" ) func (s *MasterTestSuite) TestFindItemNeighborsBruteForce() { diff --git a/master/vectors.go b/master/vectors.go index b100521d8..a9cf67d35 100644 --- a/master/vectors.go +++ b/master/vectors.go @@ -19,7 +19,7 @@ import ( "github.com/bits-and-blooms/bitset" "github.com/chewxy/math32" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/search" + "github.com/Neura-Studios/gorse/base/search" "reflect" ) diff --git a/model/built_in.go b/model/built_in.go index dcb2a234e..549b82e49 100644 --- a/model/built_in.go +++ b/model/built_in.go @@ -17,7 +17,7 @@ package model import ( "archive/zip" "fmt" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "io" "net/http" "os" diff --git a/model/click/data.go b/model/click/data.go index aa2700f12..d41681699 100644 --- a/model/click/data.go +++ b/model/click/data.go @@ -24,9 +24,9 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/jsonutil" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/jsonutil" + "github.com/Neura-Studios/gorse/model" "modernc.org/mathutil" ) diff --git a/model/click/deepfm.go b/model/click/deepfm.go index f5b0a12d3..5e869e0a5 100644 --- a/model/click/deepfm.go +++ b/model/click/deepfm.go @@ -28,12 +28,12 @@ import ( "github.com/google/uuid" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" "gorgonia.org/gorgonia" "gorgonia.org/tensor" diff --git a/model/click/deepfm_test.go b/model/click/deepfm_test.go index 200559cbc..a70fbf626 100644 --- a/model/click/deepfm_test.go +++ b/model/click/deepfm_test.go @@ -21,7 +21,7 @@ import ( "github.com/samber/lo" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/model" ) func TestDeepFM_Classification_Frappe(t *testing.T) { diff --git a/model/click/evaluator.go b/model/click/evaluator.go index 39f8bbb91..b775fa518 100644 --- a/model/click/evaluator.go +++ b/model/click/evaluator.go @@ -19,7 +19,7 @@ import ( "github.com/chewxy/math32" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/copier" + "github.com/Neura-Studios/gorse/base/copier" "modernc.org/sortutil" ) diff --git a/model/click/model.go b/model/click/model.go index 9987dfaea..7757ac7c6 100644 --- a/model/click/model.go +++ b/model/click/model.go @@ -26,15 +26,15 @@ import ( "github.com/juju/errors" "github.com/samber/lo" "github.com/thoas/go-funk" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/copier" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/copier" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" ) diff --git a/model/click/model_test.go b/model/click/model_test.go index c2c8a4a24..f2f6ac27e 100644 --- a/model/click/model_test.go +++ b/model/click/model_test.go @@ -19,8 +19,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" ) const ( diff --git a/model/click/search.go b/model/click/search.go index 390964bf1..b6c6a6aa0 100644 --- a/model/click/search.go +++ b/model/click/search.go @@ -20,11 +20,11 @@ import ( "sync" "time" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" ) diff --git a/model/click/search_test.go b/model/click/search_test.go index 8dfda1d6f..6c6c1022b 100644 --- a/model/click/search_test.go +++ b/model/click/search_test.go @@ -19,9 +19,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" ) // NewMapIndexDataset creates a data set. diff --git a/model/click/unified_index.go b/model/click/unified_index.go index 26eaf8cd9..42c580ea5 100644 --- a/model/click/unified_index.go +++ b/model/click/unified_index.go @@ -21,8 +21,8 @@ import ( "strconv" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/log" ) // UnifiedIndex maps users, items and labels into a unified encoding space. diff --git a/model/model.go b/model/model.go index a1f731a4d..3c829fe9d 100644 --- a/model/model.go +++ b/model/model.go @@ -15,7 +15,7 @@ package model import ( - "github.com/zhenghaoz/gorse/base" + "github.com/Neura-Studios/gorse/base" ) // Model is the interface for all models. Any model in this diff --git a/model/params.go b/model/params.go index 37ac81fd1..89528daca 100644 --- a/model/params.go +++ b/model/params.go @@ -18,7 +18,7 @@ import ( "encoding/json" "reflect" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "go.uber.org/zap" ) diff --git a/model/ranking/data.go b/model/ranking/data.go index 2497ec828..3fcf1a364 100644 --- a/model/ranking/data.go +++ b/model/ranking/data.go @@ -24,10 +24,10 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" ) diff --git a/model/ranking/evaluator.go b/model/ranking/evaluator.go index f5a1ac07d..e1e4ea104 100644 --- a/model/ranking/evaluator.go +++ b/model/ranking/evaluator.go @@ -18,10 +18,10 @@ import ( "github.com/chewxy/math32" mapset "github.com/deckarep/golang-set/v2" "github.com/thoas/go-funk" - "github.com/zhenghaoz/gorse/base/copier" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/copier" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/parallel" ) /* Evaluate Item Ranking */ diff --git a/model/ranking/evaluator_test.go b/model/ranking/evaluator_test.go index 927138ac8..fbd3280f9 100644 --- a/model/ranking/evaluator_test.go +++ b/model/ranking/evaluator_test.go @@ -21,8 +21,8 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/model" ) const evalEpsilon = 0.00001 diff --git a/model/ranking/model.go b/model/ranking/model.go index 2e5e3c747..28340bf85 100644 --- a/model/ranking/model.go +++ b/model/ranking/model.go @@ -26,15 +26,15 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/copier" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/copier" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" ) diff --git a/model/ranking/model_test.go b/model/ranking/model_test.go index 915526e4e..431404c66 100644 --- a/model/ranking/model_test.go +++ b/model/ranking/model_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/floats" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base/floats" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" ) const ( diff --git a/model/ranking/search.go b/model/ranking/search.go index 404632d07..3480ac687 100644 --- a/model/ranking/search.go +++ b/model/ranking/search.go @@ -20,11 +20,11 @@ import ( "sync" "time" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" "go.uber.org/zap" ) diff --git a/model/ranking/search_test.go b/model/ranking/search_test.go index 169fa3774..2cb1e0fbb 100644 --- a/model/ranking/search_test.go +++ b/model/ranking/search_test.go @@ -19,9 +19,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/task" - "github.com/zhenghaoz/gorse/model" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/task" + "github.com/Neura-Studios/gorse/model" ) type mockMatrixFactorizationForSearch struct { diff --git a/protocol/decoder.go b/protocol/decoder.go index 865e10909..5883f5368 100644 --- a/protocol/decoder.go +++ b/protocol/decoder.go @@ -15,9 +15,9 @@ package protocol import ( - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" "go.uber.org/zap" "io" ) diff --git a/protocol/protocol.proto b/protocol/protocol.proto index 54c1c43ec..a87bf6a99 100644 --- a/protocol/protocol.proto +++ b/protocol/protocol.proto @@ -13,7 +13,7 @@ // limitations under the License. syntax = "proto3"; -option go_package = "github.com/zhenghaoz/gorse/protocol"; +option go_package = "github.com/Neura-Studios/gorse/protocol"; package protocol; diff --git a/protocol/task.go b/protocol/task.go index b35c563e7..aa0ca86e1 100644 --- a/protocol/task.go +++ b/protocol/task.go @@ -17,7 +17,7 @@ package protocol import ( "time" - "github.com/zhenghaoz/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/progress" ) //go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative protocol.proto diff --git a/protocol/task_test.go b/protocol/task_test.go index d1db3246b..e142e8fe5 100644 --- a/protocol/task_test.go +++ b/protocol/task_test.go @@ -19,7 +19,7 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/progress" ) func TestEncodeDecode(t *testing.T) { diff --git a/server/bench_test.go b/server/bench_test.go index 9a1a299b0..a1a129450 100644 --- a/server/bench_test.go +++ b/server/bench_test.go @@ -34,10 +34,10 @@ import ( "github.com/go-resty/resty/v2" "github.com/samber/lo" "github.com/stretchr/testify/require" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "google.golang.org/protobuf/proto" diff --git a/server/rest.go b/server/rest.go index 4616df2bb..fa8cbad43 100644 --- a/server/rest.go +++ b/server/rest.go @@ -24,6 +24,11 @@ import ( "strings" "time" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "github.com/araddon/dateparse" mapset "github.com/deckarep/golang-set/v2" restfulspec "github.com/emicklei/go-restful-openapi/v2" @@ -33,11 +38,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/samber/lo" "github.com/thoas/go-funk" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" "go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful" "go.uber.org/zap" "google.golang.org/protobuf/proto" diff --git a/server/rest_test.go b/server/rest_test.go index a30670e4e..69883d64d 100644 --- a/server/rest_test.go +++ b/server/rest_test.go @@ -27,9 +27,9 @@ import ( "github.com/steinfletcher/apitest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "google.golang.org/protobuf/proto" ) diff --git a/server/server.go b/server/server.go index 53ff83050..dfae27f0d 100644 --- a/server/server.go +++ b/server/server.go @@ -23,13 +23,13 @@ import ( "github.com/emicklei/go-restful/v3" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/protocol" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/protocol" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" "go.uber.org/zap" diff --git a/server/server_test.go b/server/server_test.go index 000c9b752..3674e1bcc 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -22,8 +22,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/protocol" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/protocol" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) diff --git a/server/swagger.go b/server/swagger.go index 3d731dd2d..6c540b663 100644 --- a/server/swagger.go +++ b/server/swagger.go @@ -16,7 +16,7 @@ package server import ( "fmt" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "net/http" "net/url" "os" diff --git a/storage/cache/database.go b/storage/cache/database.go index c4dbc5dde..716cd017c 100644 --- a/storage/cache/database.go +++ b/storage/cache/database.go @@ -27,8 +27,8 @@ import ( "github.com/go-redis/redis/v9" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/storage" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" diff --git a/storage/cache/mongodb.go b/storage/cache/mongodb.go index cfbc8195b..d72802464 100644 --- a/storage/cache/mongodb.go +++ b/storage/cache/mongodb.go @@ -20,7 +20,7 @@ import ( "time" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/storage" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/storage/cache/mongodb_test.go b/storage/cache/mongodb_test.go index 9e6a7800c..1355e67a4 100644 --- a/storage/cache/mongodb_test.go +++ b/storage/cache/mongodb_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" ) var ( diff --git a/storage/cache/redis.go b/storage/cache/redis.go index 3a914f872..03906e919 100644 --- a/storage/cache/redis.go +++ b/storage/cache/redis.go @@ -23,10 +23,10 @@ import ( "strings" "time" + "github.com/Neura-Studios/gorse/storage" "github.com/go-redis/redis/v9" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/storage" ) // Redis cache storage. @@ -254,6 +254,7 @@ func (r *Redis) SearchDocuments(ctx context.Context, collection, subset string, if len(query) == 0 { return nil, nil } + var builder strings.Builder builder.WriteString(fmt.Sprintf("@collection:{ %s } @is_hidden:[0 0]", escape(collection))) if subset != "" { @@ -276,6 +277,7 @@ func (r *Redis) SearchDocuments(ctx context.Context, collection, subset string, if err != nil { return nil, errors.Trace(err) } + return documents, nil } @@ -373,36 +375,56 @@ func (r *Redis) DeleteDocuments(ctx context.Context, collections []string, condi } func parseSearchDocumentsResult(result any) (count int64, keys []string, documents []Document, err error) { - rows, ok := result.([]any) - if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", result) - } - count, ok = rows[0].(int64) - if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[0]) + var rows []any + switch t := result.(type) { + case map[any]any: + for k, v := range t { + if key, ok := k.(string); ok && key == "results" { + rows = v.([]any) + } + } + case []any: + rows = t + default: + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 1): %v", result) } - for i := 1; i < len(rows); i += 2 { - key, ok := rows[i].(string) + + var redisRows []map[any]any + for _, row := range rows { + rowMap, ok := row.(map[any]any) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[i]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 2): %#v", row) } - keys = append(keys, key) - row, ok := rows[i+1].([]any) + + attrs, ok := rowMap["extra_attributes"].(map[any]any) + if !ok { + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 3, invalid attrs, type %T): %#v", rowMap["extra_attributes"], rowMap["extra_attributes"]) + } + + redisRows = append(redisRows, attrs) + } + + for i := 0; i < len(redisRows); i++ { + row := redisRows[i] + + key, ok := row["id"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[i+1]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 4, invalid id): %#v", row) } + + keys = append(keys, key) fields := make(map[string]any) - for j := 0; j < len(row); j += 2 { - fields[row[j].(string)] = row[j+1] + for key, val := range row { + fields[key.(string)] = val } var document Document document.Id, ok = fields["id"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["id"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 5): %#v", fields["id"]) } score, ok := fields["score"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["score"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 6): %#v", fields["score"]) } document.Score, err = strconv.ParseFloat(score, 64) if err != nil { @@ -410,7 +432,7 @@ func parseSearchDocumentsResult(result any) (count int64, keys []string, documen } categories, ok := fields["categories"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["categories"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 7): %#v", fields["categories"]) } document.Categories, err = decodeCategories(categories) if err != nil { @@ -418,7 +440,7 @@ func parseSearchDocumentsResult(result any) (count int64, keys []string, documen } timestamp, ok := fields["timestamp"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["timestamp"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 8): %#v", fields["timestamp"]) } timestampMicros, err := strconv.ParseInt(timestamp, 10, 64) if err != nil { @@ -471,21 +493,21 @@ func (r *Redis) GetTimeSeriesPoints(ctx context.Context, name string, begin, end func parseGetTimeSeriesPointsResult(result any) (count int64, keys []string, points []TimeSeriesPoint, err error) { rows, ok := result.([]any) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", result) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 9): %#v", result) } count, ok = rows[0].(int64) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[0]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 10): %#v", rows[0]) } for i := 1; i < len(rows); i += 2 { key, ok := rows[i].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[i]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 11): %#v", rows[i]) } keys = append(keys, key) row, ok := rows[i+1].([]any) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", rows[i+1]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 12): %#v", rows[i+1]) } fields := make(map[string]any) for j := 0; j < len(row); j += 2 { @@ -494,11 +516,11 @@ func parseGetTimeSeriesPointsResult(result any) (count int64, keys []string, poi var point TimeSeriesPoint point.Name, ok = fields["name"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["name"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 13): %#v", fields["name"]) } value, ok := fields["value"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["value"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 14): %#v", fields["value"]) } point.Value, err = strconv.ParseFloat(value, 64) if err != nil { @@ -506,7 +528,7 @@ func parseGetTimeSeriesPointsResult(result any) (count int64, keys []string, poi } timestamp, ok := fields["timestamp"].(string) if !ok { - return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result: %#v", fields["timestamp"]) + return 0, nil, nil, errors.Errorf("invalid FT.SEARCH result (step 15): %#v", fields["timestamp"]) } timestampMicros, err := strconv.ParseInt(timestamp, 10, 64) if err != nil { diff --git a/storage/cache/redis_test.go b/storage/cache/redis_test.go index 10b03ae05..9c4307e60 100644 --- a/storage/cache/redis_test.go +++ b/storage/cache/redis_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "google.golang.org/protobuf/proto" ) diff --git a/storage/cache/sql.go b/storage/cache/sql.go index 274291dcc..c994b566b 100644 --- a/storage/cache/sql.go +++ b/storage/cache/sql.go @@ -30,7 +30,7 @@ import ( "github.com/juju/errors" "github.com/lib/pq" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/storage" "gorm.io/gorm" "gorm.io/gorm/clause" "modernc.org/sqlite" diff --git a/storage/cache/sql_test.go b/storage/cache/sql_test.go index a8482e178..fc524498c 100644 --- a/storage/cache/sql_test.go +++ b/storage/cache/sql_test.go @@ -23,8 +23,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/storage" ) var ( diff --git a/storage/data/database.go b/storage/data/database.go index 8c4088ea9..e39025494 100644 --- a/storage/data/database.go +++ b/storage/data/database.go @@ -25,9 +25,9 @@ import ( "github.com/XSAM/otelsql" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/jsonutil" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/base/jsonutil" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/storage" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" diff --git a/storage/data/mongodb.go b/storage/data/mongodb.go index c3c35a80d..29d04f253 100644 --- a/storage/data/mongodb.go +++ b/storage/data/mongodb.go @@ -22,7 +22,7 @@ import ( mapset "github.com/deckarep/golang-set/v2" "github.com/juju/errors" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/storage" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" diff --git a/storage/data/sql.go b/storage/data/sql.go index f37af786b..98d864e2e 100644 --- a/storage/data/sql.go +++ b/storage/data/sql.go @@ -26,9 +26,9 @@ import ( "github.com/juju/errors" _ "github.com/lib/pq" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/jsonutil" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/base/jsonutil" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/storage" "gorm.io/gorm" "gorm.io/gorm/clause" _ "modernc.org/sqlite" diff --git a/storage/data/sql_test.go b/storage/data/sql_test.go index dccff5bd8..19c1106a4 100644 --- a/storage/data/sql_test.go +++ b/storage/data/sql_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/zhenghaoz/gorse/storage" + "github.com/Neura-Studios/gorse/storage" ) var ( diff --git a/storage/scheme.go b/storage/scheme.go index 03f62f825..c41e67153 100644 --- a/storage/scheme.go +++ b/storage/scheme.go @@ -22,7 +22,7 @@ import ( "github.com/go-sql-driver/mysql" "github.com/juju/errors" "github.com/samber/lo" - "github.com/zhenghaoz/gorse/base/log" + "github.com/Neura-Studios/gorse/base/log" "gorm.io/gorm" "gorm.io/gorm/schema" "moul.io/zapgorm2" diff --git a/worker/worker.go b/worker/worker.go index 88855ab5d..0b6b5faba 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -32,21 +32,21 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/samber/lo" "github.com/thoas/go-funk" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/encoding" - "github.com/zhenghaoz/gorse/base/heap" - "github.com/zhenghaoz/gorse/base/log" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/base/search" - "github.com/zhenghaoz/gorse/base/sizeof" - "github.com/zhenghaoz/gorse/cmd/version" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/protocol" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/encoding" + "github.com/Neura-Studios/gorse/base/heap" + "github.com/Neura-Studios/gorse/base/log" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/base/search" + "github.com/Neura-Studios/gorse/base/sizeof" + "github.com/Neura-Studios/gorse/cmd/version" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/protocol" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "go.uber.org/atomic" "go.uber.org/zap" "google.golang.org/grpc" diff --git a/worker/worker_test.go b/worker/worker_test.go index 0a9eae460..4f1d85e35 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -34,16 +34,16 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "github.com/thoas/go-funk" - "github.com/zhenghaoz/gorse/base" - "github.com/zhenghaoz/gorse/base/parallel" - "github.com/zhenghaoz/gorse/base/progress" - "github.com/zhenghaoz/gorse/config" - "github.com/zhenghaoz/gorse/model" - "github.com/zhenghaoz/gorse/model/click" - "github.com/zhenghaoz/gorse/model/ranking" - "github.com/zhenghaoz/gorse/protocol" - "github.com/zhenghaoz/gorse/storage/cache" - "github.com/zhenghaoz/gorse/storage/data" + "github.com/Neura-Studios/gorse/base" + "github.com/Neura-Studios/gorse/base/parallel" + "github.com/Neura-Studios/gorse/base/progress" + "github.com/Neura-Studios/gorse/config" + "github.com/Neura-Studios/gorse/model" + "github.com/Neura-Studios/gorse/model/click" + "github.com/Neura-Studios/gorse/model/ranking" + "github.com/Neura-Studios/gorse/protocol" + "github.com/Neura-Studios/gorse/storage/cache" + "github.com/Neura-Studios/gorse/storage/data" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/protobuf/proto"