Skip to content

Commit

Permalink
Added pretty printing for checks + option to error on failures + fixe…
Browse files Browse the repository at this point in the history
…d docs (#13)

* added pretty printing of checks using PrettyTables.jl

* deprecate check_grads in favour of check

* proper depwarn for check_grads

* fixed depwarn message

* properly propagate kwargs from benchmark_model + updated docstringss

* added option of erroring on failed checks and/or backends

* bumped patch version

* renamed docuemnter yaml

* removed Manifest.toml from docs

* added preview cleanup action for docs

* fixed the url for docs + added preview of docs

* added back mistakenly removed line from previous commit

* fixed typo in args to deploydocs

* added some additional configuration for docs action

* added compat entry for PrettyTables.jl

* fixed ordering of adbackends in checks

* added an example in docs

* some minor style changes

* updated Project.toml for docs

* added compat entry for Documenter
  • Loading branch information
torfjelde committed Sep 20, 2023
1 parent e0d3e35 commit c4bbd65
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 182 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Documentation

on:
push:
branches:
- main
tags: '*'
pull_request:
branches:
- main
merge_group:
types: [checks_requested]

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
JULIA_DEBUG: Documenter # Print `@debug` statements (https://github.com/JuliaDocs/Documenter.jl/issues/955)
run: julia --project=docs/ docs/make.jl
26 changes: 26 additions & 0 deletions .github/workflows/DocsPreivewCleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: DocsPreviewCleanup

on:
pull_request:
types: [closed]

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
if [ -d "previews/PR$PRNUM" ]; then
git config user.name "Documenter.jl"
git config user.email "documenter@juliadocs.github.io"
git rm -rf "previews/PR$PRNUM"
git commit -m "delete preview"
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi
env:
PRNUM: ${{ github.event.number }}
27 changes: 0 additions & 27 deletions .github/workflows/documenter.yml

This file was deleted.

5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name = "TuringBenchmarking"
uuid = "0db1332d-5c25-4deb-809f-459bc696f94f"
authors = ["Tor Erlend Fjelde <tor.erlend95@gmail.com> and contributors"]
version = "0.3.1"
version = "0.3.2"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DynamicPPL = "366bfd00-2699-11ea-058f-f148b4cae6d8"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
Expand All @@ -25,6 +27,7 @@ BridgeStan = "2"
DynamicPPL = "0.23"
LogDensityProblems = "2"
LogDensityProblemsAD = "1"
PrettyTables = "2"
Requires = "1"
ReverseDiff = "1.14"
Turing = "0.29"
Expand Down
120 changes: 0 additions & 120 deletions docs/Manifest.toml

This file was deleted.

6 changes: 5 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
TuringBenchmarking = "0db1332d-5c25-4deb-809f-459bc696f94f"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"

[compat]
Documenter = "1"
Turing = "0.29"
7 changes: 4 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ DocMeta.setdocmeta!(TuringBenchmarking, :DocTestSetup, :(using TuringBenchmarkin
makedocs(;
modules=[TuringBenchmarking],
authors="Tor Erlend Fjelde <torfjelde.github@gmail.com> and contributors",
repo="https://github.com/turinglang/TuringBenchmarking.jl/blob/{commit}{path}#{line}",
repo="https://github.com/TuringLang/TuringBenchmarking.jl/blob/{commit}{path}#{line}",
sitename="TuringBenchmarking.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://turinglang.github.io/TuringBenchmarking.jl",
canonical="https://turinglang.org/TuringBenchmarking.jl",
edit_link="main",
assets=String[],
),
Expand All @@ -20,6 +20,7 @@ makedocs(;
)

deploydocs(;
repo="github.com/turinglang/TuringBenchmarking.jl",
repo="github.com/TuringLang/TuringBenchmarking.jl",
devbranch="main",
push_preview=true,
)
30 changes: 28 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,35 @@
CurrentModule = TuringBenchmarking
```

# TuringBenchmarking
# TuringBenchmarking.jl

Documentation for [TuringBenchmarking](https://github.com/torfjelde/TuringBenchmarking.jl).
A useful package for benchmarking and checking [Turing.jl](https://github.com/TuringLang/Turing.jl) models.

## Example

```@repl
using TuringBenchmarking, Turing
@model function demo(x)
s ~ InverseGamma(2, 3)
m ~ Normal(0, sqrt(s))
for i in 1:length(x)
x[i] ~ Normal(m, sqrt(s))
end
end
model = demo([1.5, 2.0]);
benchmark_model(
model;
# Check correctness of computations
check=true,
# Automatic differentiation backends to check and benchmark
adbackends=[:forwarddiff, :reversediff, :reversediff_compiled, :zygote]
)
```

## API

```@index
```
Expand Down
Loading

2 comments on commit c4bbd65

@torfjelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/91789

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" c4bbd6571e41171310c9ec5c7d9ac83568f88954
git push origin v0.3.2

Please sign in to comment.