From acff38f0db3c5d6555e72a2fb55423666ca7960a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20=C3=96cal?= <26488673+kaandocal@users.noreply.github.com> Date: Thu, 15 Feb 2024 08:03:44 +1300 Subject: [PATCH 1/8] Update Project.toml (#136) * Update Project.toml Updated BangBang.jl compatibility * Update Project.toml Co-authored-by: David Widmann * Update Project.toml --------- Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: David Widmann --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index a0ba0825..3e2c6383 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" keywords = ["markov chain monte carlo", "probablistic programming"] license = "MIT" desc = "A lightweight interface for common MCMC methods." -version = "5.0.0" +version = "5.1.0" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" @@ -20,7 +20,7 @@ TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999" [compat] -BangBang = "0.3.19" +BangBang = "0.3.19, 0.4" ConsoleProgressMonitor = "0.1" FillArrays = "1" LogDensityProblems = "2" From 8217238cef22727f032f96a8d8ab37515c716c42 Mon Sep 17 00:00:00 2001 From: Xianda Sun <5433119+sunxd3@users.noreply.github.com> Date: Mon, 26 Feb 2024 20:19:07 +0000 Subject: [PATCH 2/8] Add option to mute the logging for `setprogress!` function (#138) * add option to mute * version bump * Update Project.toml Co-authored-by: David Widmann * apply suggestion by @devmotion --------- Co-authored-by: David Widmann --- Project.toml | 2 +- src/sample.jl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 3e2c6383..97c90709 100644 --- a/Project.toml +++ b/Project.toml @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" keywords = ["markov chain monte carlo", "probablistic programming"] license = "MIT" desc = "A lightweight interface for common MCMC methods." -version = "5.1.0" +version = "5.2.0" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" diff --git a/src/sample.jl b/src/sample.jl index 58217f39..175ec8df 100644 --- a/src/sample.jl +++ b/src/sample.jl @@ -6,8 +6,10 @@ const PROGRESS = Ref(true) Enable progress logging globally if `progress` is `true`, and disable it otherwise. """ -function setprogress!(progress::Bool) - @info "progress logging is $(progress ? "enabled" : "disabled") globally" +function setprogress!(progress::Bool; silent::Bool=false) + if !silent + @info "progress logging is $(progress ? "enabled" : "disabled") globally" + end PROGRESS[] = progress return progress end From 2a77f53114c4b3c5a11a3759e39233dab9e16f9a Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:57:26 +0000 Subject: [PATCH 3/8] Update sample.jl (#139) --- src/sample.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sample.jl b/src/sample.jl index 175ec8df..d60a0739 100644 --- a/src/sample.jl +++ b/src/sample.jl @@ -2,9 +2,10 @@ const PROGRESS = Ref(true) """ - setprogress!(progress::Bool) + setprogress!(progress::Bool; silent::Bool=false) -Enable progress logging globally if `progress` is `true`, and disable it otherwise. +Enable progress logging globally if `progress` is `true`, and disable it otherwise. +Optionally disable informational message if `silent` is `true`. """ function setprogress!(progress::Bool; silent::Bool=false) if !silent From ce00d763b67d99ba10845149476b6f015b27f25b Mon Sep 17 00:00:00 2001 From: Shravan Goswami <123811742+shravanngoswamii@users.noreply.github.com> Date: Mon, 24 Jun 2024 22:24:42 +0530 Subject: [PATCH 4/8] New workflow for adding navigation bar (#141) * Update make.jl for adding Navigation bar * Update docs/make.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * added navigations bar workflow * updated workflow --------- Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/DocsNav.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/DocsNav.yml diff --git a/.github/workflows/DocsNav.yml b/.github/workflows/DocsNav.yml new file mode 100644 index 00000000..3a91f0ad --- /dev/null +++ b/.github/workflows/DocsNav.yml @@ -0,0 +1,48 @@ +name: Add Navbar + +on: + workflow_run: + workflows: ["Documentation"] # add workflow names that generates docs in this list like `workflows: ["Docs Workflow", "Previews Workflow]` + types: + - completed + workflow_dispatch: # Allows manual triggering + +jobs: + add-navbar: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + permissions: + contents: write + steps: + - name: Checkout gh-pages + uses: actions/checkout@v4 + with: + ref: gh-pages + fetch-depth: 0 + + - name: Download insert_navbar.sh + run: | + curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh + chmod +x insert_navbar.sh + + - name: Update Navbar + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + + # Update all HTML files in the current directory (gh-pages root) + ./insert_navbar.sh . + + # Remove the insert_navbar.sh file + rm insert_navbar.sh + + # Check if there are any changes + if [[ -n $(git status -s) ]]; then + git add . + git commit -m "Added navbar and removed insert_navbar.sh" + git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages + else + echo "No changes to commit" + fi \ No newline at end of file From 03203e2923c31167c79943313f8ad6a8cff85157 Mon Sep 17 00:00:00 2001 From: Shravan Goswami <123811742+shravanngoswamii@users.noreply.github.com> Date: Tue, 2 Jul 2024 20:02:49 +0530 Subject: [PATCH 5/8] Update DocsNav.yml (#142) --- .github/workflows/DocsNav.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/DocsNav.yml b/.github/workflows/DocsNav.yml index 3a91f0ad..c0c69b34 100644 --- a/.github/workflows/DocsNav.yml +++ b/.github/workflows/DocsNav.yml @@ -1,16 +1,14 @@ name: Add Navbar on: - workflow_run: - workflows: ["Documentation"] # add workflow names that generates docs in this list like `workflows: ["Docs Workflow", "Previews Workflow]` - types: - - completed + push: + branches: + - gh-pages # Triggers the workflow on push events to gh-pages branch workflow_dispatch: # Allows manual triggering jobs: add-navbar: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: contents: write steps: @@ -45,4 +43,4 @@ jobs: git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages else echo "No changes to commit" - fi \ No newline at end of file + fi From 3cb36f4837643a11318eb889fa0aa74075559db7 Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:56:26 +0100 Subject: [PATCH 6/8] Update DocsNav.yml (#143) --- .github/workflows/DocsNav.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/DocsNav.yml b/.github/workflows/DocsNav.yml index c0c69b34..440e9e61 100644 --- a/.github/workflows/DocsNav.yml +++ b/.github/workflows/DocsNav.yml @@ -1,9 +1,7 @@ name: Add Navbar on: - push: - branches: - - gh-pages # Triggers the workflow on push events to gh-pages branch + page_build: # Triggers the workflow on push events to gh-pages branch workflow_dispatch: # Allows manual triggering jobs: From e7423185b5530111f0de98e4215ed4c76d3cd3c3 Mon Sep 17 00:00:00 2001 From: Shravan Goswami <123811742+shravanngoswamii@users.noreply.github.com> Date: Sun, 14 Jul 2024 18:25:16 +0530 Subject: [PATCH 7/8] Update DocsNav.yml --- .github/workflows/DocsNav.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/DocsNav.yml b/.github/workflows/DocsNav.yml index 440e9e61..14614d1f 100644 --- a/.github/workflows/DocsNav.yml +++ b/.github/workflows/DocsNav.yml @@ -3,6 +3,8 @@ name: Add Navbar on: page_build: # Triggers the workflow on push events to gh-pages branch workflow_dispatch: # Allows manual triggering + schedule: + - cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC) jobs: add-navbar: @@ -27,9 +29,12 @@ jobs: run: | git config user.name github-actions[bot] git config user.email github-actions[bot]@users.noreply.github.com + + # Define the URL of the navbar to be used + NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/TuringNavbar.html" # Update all HTML files in the current directory (gh-pages root) - ./insert_navbar.sh . + ./insert_navbar.sh . $NAVBAR_URL # Remove the insert_navbar.sh file rm insert_navbar.sh From 8431b3124dc68214211db519f142ad48ab6894cc Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 12 Sep 2024 10:44:11 +0100 Subject: [PATCH 8/8] Add error hint for MethodErrors on LogDensityModel (#146) --- Project.toml | 4 ++-- src/AbstractMCMC.jl | 14 ++++++++++++++ test/logdensityproblems.jl | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 97c90709..60215cec 100644 --- a/Project.toml +++ b/Project.toml @@ -1,9 +1,9 @@ name = "AbstractMCMC" uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" -keywords = ["markov chain monte carlo", "probablistic programming"] +keywords = ["markov chain monte carlo", "probabilistic programming"] license = "MIT" desc = "A lightweight interface for common MCMC methods." -version = "5.2.0" +version = "5.3.0" [deps] BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" diff --git a/src/AbstractMCMC.jl b/src/AbstractMCMC.jl index dc464d42..d7374dd2 100644 --- a/src/AbstractMCMC.jl +++ b/src/AbstractMCMC.jl @@ -88,4 +88,18 @@ include("stepper.jl") include("transducer.jl") include("logdensityproblems.jl") +if isdefined(Base.Experimental, :register_error_hint) + function __init__() + Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, _ + if Base.parentmodule(exc.f) == LogDensityProblems && + any(a -> a <: LogDensityModel, argtypes) + print( + io, + "\n`AbstractMCMC.LogDensityModel` is a wrapper and does not itself implement the LogDensityProblems.jl interface. To use LogDensityProblems.jl methods, access the inner type with (e.g.) `logdensity(model.logdensity, params)` instead of `logdensity(model, params)`.", + ) + end + end + end +end + end # module AbstractMCMC diff --git a/test/logdensityproblems.jl b/test/logdensityproblems.jl index 181d2645..4a3a22d5 100644 --- a/test/logdensityproblems.jl +++ b/test/logdensityproblems.jl @@ -22,6 +22,15 @@ @test model.logdensity === ℓ @test_throws ArgumentError AbstractMCMC.LogDensityModel(mylogdensity) + + try + LogDensityProblems.logdensity(model, ones(10)) + catch exc + @test exc isa MethodError + if isdefined(Base.Experimental, :register_error_hint) + @test occursin("is a wrapper", sprint(showerror, exc)) + end + end end @testset "fallback for log densities" begin