Skip to content

Commit d2f39f2

Browse files
committed
* skip test: test_inference_numerical_issues.R (#577)
* update test-covereage.yaml
1 parent 60e241f commit d2f39f2

File tree

2 files changed

+79
-82
lines changed

2 files changed

+79
-82
lines changed

.github/workflows/test-coverage.yaml

+49-52
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,73 @@
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: any::covr, any::xml2
29+
needs: coverage
3830

39-
- name: Install dependencies
40-
run: |
41-
install.packages(c("remotes"))
42-
remotes::install_deps(dependencies = TRUE)
43-
remotes::install_cran("covr")
44-
shell: Rscript {0}
31+
- name: Install package + deps
32+
run: remotes::install_local(dependencies = TRUE, force = TRUE)
4533

46-
###
47-
- name: Install Miniconda
34+
- name: Install greta deps
4835
run: |
49-
install.packages(c("remotes", "keras"))
50-
reticulate::install_miniconda()
51-
shell: Rscript {0}
36+
library(greta)
37+
greta::install_greta_deps(timeout = 50)
38+
39+
- name: Situation Report on greta install
40+
run: greta::greta_sitrep()
5241

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
5742

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
43+
- name: Test coverage
6144
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"))
45+
cov <- covr::package_coverage(
46+
quiet = FALSE,
47+
clean = FALSE,
48+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
49+
)
50+
covr::to_cobertura(cov)
6451
shell: Rscript {0}
6552

66-
- name: Python + TF details
53+
- uses: codecov/codecov-action@v4
54+
with:
55+
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
56+
file: ./cobertura.xml
57+
plugin: noop
58+
disable_search: true
59+
token: ${{ secrets.CODECOV_TOKEN }}
60+
61+
- name: Show testthat output
62+
if: always()
6763
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-
###
64+
## --------------------------------------------------------------------
65+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
66+
shell: bash
7367

74-
- name: Test coverage
75-
run: covr::codecov()
76-
shell: Rscript {0}
68+
- name: Upload test results
69+
if: failure()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: coverage-test-failures
73+
path: ${{ runner.temp }}/package
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)