generated from greta-dev/greta.template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from hrlai/olivuntu-zip-zinb
Refactor ZIP and ZINB
- Loading branch information
Showing
16 changed files
with
877 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,89 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
branches: [main, master] | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
branches: [main, master] | ||
|
||
name: test-coverage | ||
name: test-coverage.yaml | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: macOS-latest | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v1 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v1 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Query dependencies | ||
run: | | ||
install.packages('remotes') | ||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | ||
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") | ||
shell: Rscript {0} | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- name: Restore R package cache | ||
uses: actions/cache@v2 | ||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
path: ${{ env.R_LIBS_USER }} | ||
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} | ||
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | ||
extra-packages: | | ||
any::covr | ||
any::xml2 | ||
any::remotes | ||
needs: coverage | ||
|
||
- name: Install dependencies | ||
- name: Install system dependencies | ||
if: runner.os == 'Linux' | ||
shell: bash | ||
run: | | ||
install.packages(c("remotes")) | ||
remotes::install_deps(dependencies = TRUE) | ||
remotes::install_cran("covr") | ||
. /etc/os-release | ||
while read -r cmd | ||
do | ||
echo "$cmd" | ||
sudo $cmd | ||
done < <(Rscript -e "writeLines(remotes::system_requirements('$ID-$VERSION_ID'))") | ||
- name: Install package + deps | ||
run: remotes::install_local(dependencies = TRUE, force = TRUE) | ||
shell: Rscript {0} | ||
|
||
### | ||
- name: Install Miniconda | ||
- name: Install greta deps | ||
run: | | ||
install.packages(c("remotes", "keras")) | ||
reticulate::install_miniconda() | ||
library(greta) | ||
greta::install_greta_deps(timeout = 50) | ||
shell: Rscript {0} | ||
|
||
- name: Set options for conda binary for macOS | ||
if: runner.os == 'macOS' | ||
run: | | ||
echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile | ||
- name: Situation Report on greta install | ||
run: greta::greta_sitrep() | ||
shell: Rscript {0} | ||
|
||
# Perhaps here is where we can install / change the environment that we are | ||
# installing into? Can we call our own greta install functions here? | ||
- name: Install TensorFlow | ||
- name: Test coverage | ||
run: | | ||
reticulate::conda_create(envname = "greta-env",python_version = "3.7") | ||
reticulate::conda_install(envname = "greta-env", packages = c("numpy==1.16.4", "tensorflow-probability==0.7.0", "tensorflow==1.14.0")) | ||
cov <- covr::package_coverage( | ||
quiet = FALSE, | ||
clean = FALSE, | ||
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") | ||
) | ||
covr::to_cobertura(cov) | ||
shell: Rscript {0} | ||
|
||
- name: Python + TF details | ||
- uses: codecov/codecov-action@v4 | ||
with: | ||
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} | ||
file: ./cobertura.xml | ||
plugin: noop | ||
disable_search: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Show testthat output | ||
if: always() | ||
run: | | ||
Rscript -e 'tensorflow::tf_config()' | ||
Rscript -e 'tensorflow::tf_version()' | ||
Rscript -e 'reticulate::py_module_available("tensorflow_probability")' | ||
Rscript -e 'reticulate::py_config()' | ||
### | ||
## -------------------------------------------------------------------- | ||
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true | ||
shell: bash | ||
|
||
- name: Test coverage | ||
run: covr::codecov() | ||
shell: Rscript {0} | ||
- name: Upload test results | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-test-failures | ||
path: ${{ runner.temp }}/package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(zero_inflated_negative_binomial) | ||
export(zero_inflated_poisson) | ||
importFrom(R6,R6Class) | ||
importFrom(greta,.internals) | ||
importFrom(tensorflow,tf) | ||
importFrom(utils,globalVariables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' @title Extends Distributions Available in the `greta` package | ||
#' @name greta.distributions | ||
#' | ||
#' @description describe your package here, you can re-use the text from DESCRIPTION | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @importFrom tensorflow tf | ||
#' @importFrom greta .internals | ||
#' @importFrom R6 R6Class | ||
#' @importFrom utils globalVariables | ||
## usethis namespace: end | ||
NULL | ||
|
||
globalVariables( | ||
c( | ||
"as_2d_array", | ||
"as_data", | ||
"calculate", | ||
"initials", | ||
"prep_initials", | ||
"variable" | ||
) | ||
) |
Oops, something went wrong.