Skip to content

Commit

Permalink
Updating the compat helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
codetalker7 committed Sep 17, 2024
1 parent 74dd70a commit ab7e6b5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
37 changes: 33 additions & 4 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,43 @@ on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
4 changes: 2 additions & 2 deletions test/search/ranking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ end
D = rand(Float32, 128, sum(doclens)) # document vectors, each of size 128
pids = collect(1:1000)
scores = maxsim(Q, D, pids, doclens)
@test length(scores) == length(pids)
@test scores isa Vector{Float32}
@test length(scores) == length(pids)
@test scores isa Vector{Float32}
end
13 changes: 6 additions & 7 deletions test/searching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ using ColBERT: _build_emb2pid

@testset "_build_emb2pid" begin
# Test 1: A single document
doclens = rand(1:1000, 1)
doclens = rand(1:1000, 1)
emb2pid = _build_emb2pid(doclens)
@test emb2pid == ones(Int, doclens[1])
@test emb2pid == ones(Int, doclens[1])

# Test 2: Small test with a custom output
doclens = [3, 2, 4]
Expand All @@ -28,16 +28,15 @@ using ColBERT: _build_emb2pid
@test emb2pid == Int[]

# Test 5: Range of values, shapes and type
doclens = rand(0:100, rand(1:500))
non_zero_docs = findall(>(0), doclens)
zero_docs = findall(==(0), doclens)
doclens = rand(0:100, rand(1:500))
non_zero_docs = findall(>(0), doclens)
zero_docs = findall(==(0), doclens)
emb2pid = _build_emb2pid(doclens)
@test all(in(non_zero_docs), emb2pid)
@test issorted(emb2pid)
for pid in non_zero_docs
@test count(==(pid), emb2pid) == doclens[pid]
end
@test length(emb2pid) == sum(doclens[non_zero_docs])
@test length(emb2pid) == sum(doclens[non_zero_docs])
@test emb2pid isa Vector{Int}
end

0 comments on commit ab7e6b5

Please sign in to comment.