Skip to content

Commit c28b3a2

Browse files
Use Turing Actions for Documenter site and Navbar and upgrade package to use latest compats (#151)
* Use Turing Actions for Documenter site and Navbar * only 1 process at a time to fix docs * update CI * debump formatter checkout * more debump formatter checkout * Ohh, shame on me -- I was changing version without v * support latest Julia versions * fix tests and update few more things * remove Julia 1.6 from CI * fix docs * format * ignore size thresold in docs * address all copilot suggestions
1 parent b962f5c commit c28b3a2

File tree

16 files changed

+108
-100
lines changed

16 files changed

+108
-100
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
matrix:
1717
version:
1818
- '1'
19-
- '1.6'
2019
- 'nightly'
2120
os:
2221
- ubuntu-latest
@@ -28,12 +27,12 @@ jobs:
2827
arch: x64
2928
coverage: true
3029
steps:
31-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v6
3231
- uses: julia-actions/setup-julia@v1
3332
with:
3433
version: ${{ matrix.version }}
3534
arch: ${{ matrix.arch }}
36-
- uses: actions/cache@v1
35+
- uses: actions/cache@v5
3736
env:
3837
cache-name: cache-artifacts
3938
with:

.github/workflows/DocNav.yml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
1-
name: Add Navbar
1+
name: Rebuild docs with newest navbar
22

33
on:
4-
page_build: # Triggers the workflow on push events to gh-pages branch
5-
workflow_dispatch: # Allows manual triggering
4+
# 3:25 AM UTC every Sunday -- choose an uncommon time to avoid
5+
# periods of heavy GitHub Actions usage
66
schedule:
7-
- cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC)
7+
- cron: '25 3 * * 0'
8+
# Whenever needed
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
813

914
jobs:
10-
add-navbar:
15+
update-navbar:
1116
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
17+
1418
steps:
15-
- name: Checkout gh-pages
16-
uses: actions/checkout@v4
19+
- name: Checkout gh-pages branch
20+
uses: actions/checkout@v6
1721
with:
1822
ref: gh-pages
19-
fetch-depth: 0
2023

21-
- name: Download insert_navbar.sh
22-
run: |
23-
curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh
24-
chmod +x insert_navbar.sh
24+
- name: Insert navbar
25+
uses: TuringLang/actions/DocsNav@main
26+
with:
27+
doc-path: '.'
28+
navbar-url: https://raw.githubusercontent.com/JuliaGaussianProcesses/.github/refs/heads/main/DocumenterNavbar/JuliaGPNavbar.html
2529

26-
- name: Update Navbar
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Commit and push changes
2931
run: |
30-
git config user.name github-actions[bot]
31-
git config user.email github-actions[bot]@users.noreply.github.com
32-
33-
# Define the URL of the navbar to be used
34-
NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/JuliaGPNavbar.html"
35-
36-
# Update all HTML files in the current directory (gh-pages root)
37-
./insert_navbar.sh . $NAVBAR_URL
38-
39-
# Remove the insert_navbar.sh file
40-
rm insert_navbar.sh
41-
42-
# Check if there are any changes
4332
if [[ -n $(git status -s) ]]; then
44-
git add .
45-
git commit -m "Added navbar and removed insert_navbar.sh"
46-
git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
33+
git config user.name github-actions[bot]
34+
git config user.email github-actions[bot]@users.noreply.github.com
35+
git add -A
36+
git commit -m "Update navbar (automated)"
37+
git push
4738
else
4839
echo "No changes to commit"
4940
fi

.github/workflows/Docs.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ on:
66
- master
77
tags: '*'
88
pull_request:
9+
workflow_dispatch:
10+
11+
concurrency:
12+
# Skip intermediate builds: always.
13+
# Cancel intermediate builds: only if it is a pull request build.
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
920

1021
jobs:
11-
build:
22+
docs:
1223
runs-on: ubuntu-latest
24+
1325
steps:
14-
- uses: actions/checkout@v2
15-
- uses: julia-actions/setup-julia@latest
16-
with:
17-
version: '1.6'
18-
- name: Install dependencies
19-
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
20-
- name: Build and deploy
26+
- name: Build and deploy Documenter.jl docs
2127
env:
2228
GKSwstype: nul # turn off GR's interactive plotting for notebooks
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
24-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
25-
JULIA_DEBUG: Documenter # Print `@debug` statements (https://github.com/JuliaDocs/Documenter.jl/issues/955)
26-
run: julia --project=docs/ docs/make.jl
29+
uses: TuringLang/actions/DocsDocumenter@main
30+
with:
31+
julia-version: '1'
32+
navbar-url: https://raw.githubusercontent.com/JuliaGaussianProcesses/.github/refs/heads/main/DocumenterNavbar/JuliaGPNavbar.html

.github/workflows/DocsPreviewCleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout gh-pages branch
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v6
1313
with:
1414
ref: gh-pages
1515
- name: Delete preview and history + push changes

.github/workflows/Format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
format:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v6
1111
- uses: julia-actions/setup-julia@latest
1212
with:
1313
version: 1

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ PDMats = "0.11"
3838
Reexport = "1"
3939
SpecialFunctions = "1, 2"
4040
StatsBase = "0.33, 0.34"
41-
julia = "1.6"
41+
julia = "1"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44

55
[compat]
66
ApproximateGPs = "0.3,0.4"
7-
Documenter = "0.27"
7+
Documenter = "1"

docs/make.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using JuliaGPsDocs
66

77
using ApproximateGPs
88

9-
JuliaGPsDocs.generate_examples(ApproximateGPs)
9+
JuliaGPsDocs.generate_examples(ApproximateGPs; ntasks=1)
1010

1111
### Build documentation
1212
using Documenter
@@ -23,19 +23,20 @@ DocMeta.setdocmeta!(
2323

2424
makedocs(;
2525
sitename="ApproximateGPs.jl",
26-
format=Documenter.HTML(),
26+
format=Documenter.HTML(;
27+
size_threshold_ignore=[
28+
"examples/a-regression/index.md",
29+
"examples/b-classification/index.md",
30+
"examples/c-comparisons/index.md",
31+
],
32+
),
2733
modules=[ApproximateGPs],
2834
pages=[
2935
"Home" => "index.md",
3036
"userguide.md",
3137
"API" => joinpath.(Ref("api"), ["index.md", "sparsevariational.md", "laplace.md"]),
3238
"Examples" => JuliaGPsDocs.find_generated_examples(ApproximateGPs),
3339
],
34-
strict=true,
3540
checkdocs=:exports,
3641
doctestfilters=JuliaGPsDocs.DOCTEST_FILTERS,
3742
)
38-
39-
deploydocs(;
40-
repo="github.com/JuliaGaussianProcesses/ApproximateGPs.jl.git", push_preview=true
41-
)

examples/a-regression/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
1010
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1111
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1212
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
13+
14+
[compat]
15+
Flux = "0.14, 0.15, 0.16"

examples/a-regression/script.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct SVGPModel
8181
A # square-root of variational covariance
8282
end
8383

84-
Flux.@functor SVGPModel (k, z, m, A);
84+
Flux.@layer SVGPModel trainable=(k, z, m, A)
8585

8686
# Set the observation noise for our model, along with a `jitter` term
8787
# to help with numerical stability.
@@ -167,15 +167,14 @@ plot!(-1:0.001:1, init_post; label="Initial Posterior", color=4)
167167
#
168168
# Training the model now simply proceeds with the usual `Flux.jl` training loop.
169169

170-
opt = ADAM(0.001) # Define the optimiser
171-
params = Flux.params(model); # Extract the model parameters
170+
opt = Flux.Adam(0.001)
172171

173172
# One of the major advantages of the SVGP model is that it allows stochastic
174173
# estimation of the ELBO by using minibatching of the training data. This is
175174
# very straightforward to achieve with `Flux.jl`'s utilities:
176175

177176
b = 100 # minibatch size
178-
data_loader = Flux.Data.DataLoader((x, y); batchsize=b)
177+
data_loader = Flux.DataLoader((x, y); batchsize=b)
179178

180179
# The loss (negative ELBO) before training
181180

@@ -186,12 +185,13 @@ loss(model, x, y)
186185

187186
using IterTools: ncycle
188187

188+
params = Flux.params(model)
189189
Flux.train!(
190190
(x, y) -> loss(model, x, y; num_data=N),
191191
params,
192192
ncycle(data_loader, 300), # Train for 300 epochs
193193
opt,
194-
);
194+
)
195195

196196
# Negative ELBO after training
197197

0 commit comments

Comments
 (0)