Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

modernize CI and fix documentation #275

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 8 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: CI
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
tags: '*'
jobs:
test:
Expand All @@ -29,20 +29,11 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: "3"
JULIA_NUM_THREADS: 4,1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand All @@ -52,23 +43,10 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
with:
version: '1.6'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --color=yes --project=docs/ -e '
using UnROOT
# using Pkg; Pkg.activate("docs")
using Documenter: DocMeta, doctest
DocMeta.setdocmeta!(UnROOT, :DocTestSetup, :(using UnROOT); recursive=true)
doctest(UnROOT)'
- run: julia --project=docs docs/make.jl
- uses: actions/checkout@v2
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-docdeploy@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ AbstractTrees = "^0.3.0, 0.4"
ArraysOfArrays = "^0.5.3, ^0.6"
Arrow = "2 - 2.5"
BitIntegers = "^0.2.6, ^0.3"
CodecLz4 = "^0.3.0, ^0.4.0"
CodecXz = "^0.6.0, ^0.7.0"
CodecZstd = "^0.6.0, ^0.7.0"
CodecLz4 = "^0.3, ^0.4"
CodecXz = "^0.6, ^0.7"
CodecZstd = "^0.6, ^0.7, ^0.8"
HTTP = "^0.9.7, 1"
IterTools = "^1"
LRUCache = "^1.3.0"
Expand Down
7 changes: 4 additions & 3 deletions src/RNTuple/highlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
function RNTupleField(rn::R, field::F) where {R, F}
O = _field_output_type(F)
E = eltype(O)
buffers = Vector{O}(undef, Threads.nthreads())
thread_locks = [ReentrantLock() for _ in 1:Threads.nthreads()]
buffer_ranges = [0:-1 for _ in 1:Threads.nthreads()]
Nthreads = _maxthreadid()
buffers = Vector{O}(undef, Nthreads)
thread_locks = [ReentrantLock() for _ in 1:Nthreads]
buffer_ranges = [0:-1 for _ in 1:Nthreads]

Check warning on line 25 in src/RNTuple/highlevel.jl

View check run for this annotation

Codecov / codecov/patch

src/RNTuple/highlevel.jl#L22-L25

Added lines #L22 - L25 were not covered by tests
new{R, F, O, E}(rn, field, buffers, thread_locks, buffer_ranges)
end
end
Expand Down
7 changes: 7 additions & 0 deletions src/UnROOT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ include("RNTuple/displays.jl")
# show(devnull, df)
# show(devnull, df[1])
# end
#

_maxthreadid() = @static if VERSION < v"1.9"
Threads.nthreads()
else
Threads.maxthreadid()
end

if VERSION >= v"1.9"
let
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@ TH2F(io, tkey::TKey, refs) = TH(io, tkey, refs)
TH1D(io, tkey::TKey, refs) = TH(io, tkey, refs)
TH2D(io, tkey::TKey, refs) = TH(io, tkey, refs)

"""
TH(io, tkey::TKey, refs)

Internal function used to form a `fields = Dict{Symbol, Any}()` that represents the fields of a
`TH` (histogram) in C++ ROOT.
"""
function TH(io, tkey::TKey, refs)
fields = Dict{Symbol, Any}()

Expand Down
7 changes: 4 additions & 3 deletions src/iteration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ mutable struct LazyBranch{T,J,B} <: AbstractVector{T}
_buffer = VectorOfVectors(T(), Int32[1])
T = SubArray{eltype(T), 1, T, Tuple{UnitRange{Int64}}, true}
end
Nthreads = _maxthreadid()
return new{T,J,typeof(_buffer)}(f, b, length(b),
b.fBasketEntry,
[_buffer for _ in 1:Threads.nthreads()],
[ReentrantLock() for _ in 1:Threads.nthreads()],
[0:-1 for _ in 1:Threads.nthreads()])
[_buffer for _ in 1:Nthreads],
[ReentrantLock() for _ in 1:Nthreads],
[0:-1 for _ in 1:Nthreads])
end
end
LazyBranch(f::ROOTFile, s::AbstractString) = LazyBranch(f, f[s])
Expand Down
2 changes: 1 addition & 1 deletion src/root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function Base.hash(rf::ROOTFile, h::UInt)
return hash(rf.fobj, h)
end

const HEAD_BUFFER_SIZE = 2048
"""
ROOTFile(filename::AbstractString; customstructs = Dict("TLorentzVector" => LorentzVector{Float64}))

Expand All @@ -61,7 +62,6 @@ test/samples/NanoAODv5_sample.root
└─ "⋮"
```
"""
const HEAD_BUFFER_SIZE = 2048
function ROOTFile(filename::AbstractString; customstructs = Dict("TLorentzVector" => LorentzVector{Float64}))
fobj = if startswith(filename, r"https?://")
HTTPStream(filename)
Expand Down
11 changes: 10 additions & 1 deletion test/rntuple_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,17 @@ end
Threads.@threads for i in eachindex(field)
@inbounds accumulator[Threads.threadid()] += field[i]
end

# test we've hit each thread's buffer
@test all(!isempty, field.buffers)
@test all(
map(eachindex(field.buffers)) do b
if !isassigned(field.buffers, b)
return true
else
return !isempty(field.buffers[b])
end

end)
@test sum(accumulator) == sum(1:5e4)

accumulator .= 0
Expand Down
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using StaticArrays
using InteractiveUtils
using MD5

const nthreads = Threads.nthreads()
const nthreads = UnROOT._maxthreadid()
nthreads == 1 && @warn "Running on a single thread. Please re-run the test suite with at least two threads (`julia --threads 2 ...`)"

const SAMPLES_DIR = joinpath(@__DIR__, "samples")
Expand Down Expand Up @@ -766,13 +766,13 @@ end


if get(ENV, "CI", "false") == "true"
if nthreads >= 1
@test Threads.nthreads()>1
else
@warn "CI wasn't run with multi thread"
if nthreads == 1
@warn "CI wasn't run with multiple threads"
end
end
nmus = zeros(Int, Threads.nthreads())

nmus = zeros(Int, nthreads)

Threads.@threads for i in 1:length(t)
nmus[Threads.threadid()] += length(t.Muon_pt[i])
end
Expand Down
Loading