Skip to content

Commit 05c1d7c

Browse files
committed
Merged upstream/master into abstract-error-checkers-529
2 parents 16a6b2e + 6a541bc commit 05c1d7c

File tree

3 files changed

+93
-80
lines changed

3 files changed

+93
-80
lines changed

.github/workflows/test-coverage.yaml

+62-49
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,89 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on:
24
push:
3-
branches:
4-
- main
5-
- master
5+
branches: [main, master]
66
pull_request:
7-
branches:
8-
- main
9-
- master
7+
branches: [main, master]
108

11-
name: test-coverage
9+
name: test-coverage.yaml
10+
11+
permissions: read-all
1212

1313
jobs:
1414
test-coverage:
15-
runs-on: macOS-latest
15+
runs-on: ubuntu-latest
1616
env:
1717
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
18+
1819
steps:
19-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2021

2122
- uses: r-lib/actions/setup-r@v2
23+
with:
24+
use-public-rspm: true
2225

23-
- uses: r-lib/actions/setup-pandoc@v2
24-
25-
- name: Query dependencies
26-
run: |
27-
install.packages('remotes')
28-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
29-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
30-
shell: Rscript {0}
31-
32-
- name: Restore R package cache
33-
uses: actions/cache@v2
26+
- uses: r-lib/actions/setup-r-dependencies@v2
3427
with:
35-
path: ${{ env.R_LIBS_USER }}
36-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
37-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
28+
extra-packages: |
29+
any::covr
30+
any::xml2
31+
any::remotes
32+
needs: coverage
3833

39-
- name: Install dependencies
34+
- name: Install system dependencies
35+
if: runner.os == 'Linux'
36+
shell: bash
4037
run: |
41-
install.packages(c("remotes"))
42-
remotes::install_deps(dependencies = TRUE)
43-
remotes::install_cran("covr")
38+
. /etc/os-release
39+
while read -r cmd
40+
do
41+
echo "$cmd"
42+
sudo $cmd
43+
done < <(Rscript -e "writeLines(remotes::system_requirements('$ID-$VERSION_ID'))")
44+
45+
- name: Install package + deps
46+
run: remotes::install_local(dependencies = TRUE, force = TRUE)
4447
shell: Rscript {0}
4548

46-
###
47-
- name: Install Miniconda
49+
- name: Install greta deps
4850
run: |
49-
install.packages(c("remotes", "keras"))
50-
reticulate::install_miniconda()
51+
library(greta)
52+
greta::install_greta_deps(timeout = 50)
5153
shell: Rscript {0}
5254

53-
- name: Set options for conda binary for macOS
54-
if: runner.os == 'macOS'
55-
run: |
56-
echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
55+
- name: Situation Report on greta install
56+
run: greta::greta_sitrep()
57+
shell: Rscript {0}
5758

58-
# Perhaps here is where we can install / change the environment that we are
59-
# installing into? Can we call our own greta install functions here?
60-
- name: Install TensorFlow
59+
- name: Test coverage
6160
run: |
62-
reticulate::conda_create(envname = "greta-env",python_version = "3.7")
63-
reticulate::conda_install(envname = "greta-env", packages = c("numpy==1.16.4", "tensorflow-probability==0.7.0", "tensorflow==1.14.0"))
61+
cov <- covr::package_coverage(
62+
quiet = FALSE,
63+
clean = FALSE,
64+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
65+
)
66+
covr::to_cobertura(cov)
6467
shell: Rscript {0}
6568

66-
- name: Python + TF details
69+
- uses: codecov/codecov-action@v4
70+
with:
71+
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
72+
file: ./cobertura.xml
73+
plugin: noop
74+
disable_search: true
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
77+
- name: Show testthat output
78+
if: always()
6779
run: |
68-
Rscript -e 'tensorflow::tf_config()'
69-
Rscript -e 'tensorflow::tf_version()'
70-
Rscript -e 'reticulate::py_module_available("tensorflow_probability")'
71-
Rscript -e 'reticulate::py_config()'
72-
###
80+
## --------------------------------------------------------------------
81+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
82+
shell: bash
7383

74-
- name: Test coverage
75-
run: covr::codecov()
76-
shell: Rscript {0}
84+
- name: Upload test results
85+
if: failure()
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: coverage-test-failures
89+
path: ${{ runner.temp }}/package

tests/testthat/test-print_calculate.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
test_that("calculate print method is different for different inputs", {
22
# ensure print method is the new MCMC one
33
skip_on_cran()
4-
skip_on_os(os = "mac")
4+
skip_on_ci()
55

66
x <- normal(0,1)
77
m <- model(x)
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
set.seed(2020 - 02 - 11)
2-
3-
test_that("numerical issues are handled in mcmc", {
4-
skip_if_not(check_tf_version())
5-
6-
# this should have a cholesky decomposition problem at some point
7-
alpha <- normal(0, 1)
8-
# x <- matrix(rnorm(6), 3, 2)
9-
x <- matrix(rnorm(12), 4, 3)
10-
# y <- t(rnorm(3))
11-
y <- t(rnorm(4))
12-
z <- alpha * x
13-
sigma <- z %*% t(z)
14-
# distribution(y) <- multivariate_normal(zeros(1, 3), sigma)
15-
distribution(y) <- multivariate_normal(zeros(1, 4), sigma)
16-
m <- model(alpha)
17-
18-
# running with bursts should error informatively
19-
expect_snapshot(
20-
error = TRUE,
21-
draws <- mcmc(m, verbose = FALSE)
22-
)
23-
24-
# setting one_by_one = TRUE should handle those errors as bad samples
25-
expect_no_error(draws <- mcmc(m,
26-
warmup = 100, n_samples = 10,
27-
one_by_one = TRUE,
28-
verbose = FALSE
29-
))
30-
})
1+
# set.seed(2020 - 02 - 11)
2+
#
3+
# test_that("numerical issues are handled in mcmc", {
4+
# skip_if_not(check_tf_version())
5+
#
6+
# # this should have a cholesky decomposition problem at some point
7+
# alpha <- normal(0, 1)
8+
# # x <- matrix(rnorm(6), 3, 2)
9+
# x <- matrix(rnorm(12), 4, 3)
10+
# # y <- t(rnorm(3))
11+
# y <- t(rnorm(4))
12+
# z <- alpha * x
13+
# sigma <- z %*% t(z)
14+
# # distribution(y) <- multivariate_normal(zeros(1, 3), sigma)
15+
# distribution(y) <- multivariate_normal(zeros(1, 4), sigma)
16+
# m <- model(alpha)
17+
#
18+
# # running with bursts should error informatively
19+
# expect_snapshot(
20+
# error = TRUE,
21+
# draws <- mcmc(m, verbose = FALSE)
22+
# )
23+
#
24+
# # setting one_by_one = TRUE should handle those errors as bad samples
25+
# expect_no_error(draws <- mcmc(m,
26+
# warmup = 100, n_samples = 10,
27+
# one_by_one = TRUE,
28+
# verbose = FALSE
29+
# ))
30+
# })

0 commit comments

Comments
 (0)