Skip to content

Commit

Permalink
Adding check to main and cran versions of epiworldRShiny (#21)
Browse files Browse the repository at this point in the history
* Adding check to main and cran versions of epiworldRShiny

* Adding environment

* Correcting env

* Handling prev versiono of epiworldRShiny

* Adding missing comma

* Addressing issues

* Avoiding building manuals

* Adding step to save the built package

* Update r.yml

* Update r.yml

* Updating who is the maintainer

* Adding given and family explicitly

* Fix bug in description

* Updating news and makefile [skip ci]
  • Loading branch information
gvegayon authored Oct 7, 2024
1 parent 8bd6b18 commit 6ea9a61
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN \
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb && \
dpkg -i pandoc-3.2.1-1-amd64.deb

RUN install2.r cpp11 rmarkdown roxygen2 tinytest data.table netplot
RUN install2.r cpp11 rmarkdown roxygen2 tinytest data.table netplot \
devtools

RUN apt-get install -y --no-install-recommends && \
install2.r languageserver
Expand Down
56 changes: 51 additions & 5 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ on:

name: R-CMD-check-final

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

jobs:

R-CMD-check:
runs-on: ${{ matrix.config.os }}

Expand All @@ -26,7 +30,7 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'devel', http-user-agent: 'release'}
- {os: windows-latest, r: 'devel', http-user-agent: 'release'}
# Use older ubuntu to maximise backward compatibility
# se older ubuntu to maximise backward compatibility
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}
Expand Down Expand Up @@ -68,14 +72,56 @@ jobs:
check-dir: '"check"'
error-on: '"warning"'

# Upload the built package as an artifact
- name: Build the package
if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') }}
run: R CMD build .

- uses: actions/upload-artifact@v4
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' }}
if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') }}
with:
name: epiworldR-built-package-${{ matrix.config.os }}-${{ matrix.config.r }}
path: epiworldR_*.tar.gz
retention-days: 7

epiworldShiny:
runs-on: ubuntu-latest
container: rocker/tidyverse:4.4.0

steps:
- uses: actions/checkout@v4
with:
name: ${{ matrix.config.os }}-pkg
path: ${{ github.workspace }}/*.tar.gz
repository: 'UofUEpiBio/epiworldRShiny'
ref: 'main'
fetch-depth: 1

- name: Install dependencies
run: |
install2.r -n 2 shinyjs shinydashboard DT shinycssloaders plotly
installGithub.r UofUEpiBio/epiworldR@${{ github.sha }}
- name: Check the package
run: |
R CMD build .
R CMD check --no-manual epiworldRShiny_*tar.gz
epiworldRShiny-cran:
runs-on: ubuntu-latest
container: rocker/tidyverse:4.4.0

steps:
- name: Get epiworldRShiny
run: |
wget \
https://cran.r-project.org/src/contrib/epiworldRShiny_0.1-0.tar.gz
- name: Install dependencies
run: |
install2.r -n 2 shinyjs shinydashboard DT shinycssloaders plotly
installGithub.r UofUEpiBio/epiworldR@${{ github.sha }}
- name: Check the package
run: |
R CMD check --no-manual epiworldRShiny_*tar.gz
Expand Down
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Type: Package
Title: Fast Agent-Based Epi Models
Version: 0.3-2
Authors@R: c(
person("Derek", "Meyer", role=c("aut","cre"),
email="derekmeyer37@gmail.com", comment = c(ORCID = "0009-0005-1350-6988")),
person("George", "Vega Yon", role=c("aut"),
person(given="George", family="Vega Yon", role=c("aut","cre"),
email="g.vegayon@gmail.com", comment = c(ORCID = "0000-0002-3171-0844")),
person("Susan", "Holmes", role = "rev", comment =
person(given="Derek", family="Meyer", role=c("aut"),
email="derekmeyer37@gmail.com", comment = c(ORCID = "0009-0005-1350-6988")),
person(given="Susan", family="Holmes", role = "rev", comment =
c(what = "JOSS reviewer", ORCID="0000-0002-2208-8168")),
person("Abinash", "Satapathy", role = "rev", comment =
person(given="Abinash", family="Satapathy", role = "rev", comment =
c(what = "JOSS reviewer", ORCID="0000-0002-2955-2744")),
person("Carinogurjao", role = "rev"),
person(given="Carinogurjao", role = "rev"),
person("Centers for Disease Control and Prevention", role="fnd", comment = "Award number 1U01CK000585; 75D30121F00003"
))
Description: A flexible framework for Agent-Based Models (ABM), the 'epiworldR' package provides methods for prototyping disease outbreaks and transmission models using a 'C++' backend, making it very fast. It supports multiple epidemiological models, including the Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), and others, involving arbitrary mitigation policies and multiple-disease models. Users can specify infectiousness/susceptibility rates as a function of agents' features, providing great complexity for the model dynamics. Furthermore, 'epiworldR' is ideal for simulation studies featuring large populations.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ check: build
cd .. && R CMD check epiworldR_*.tar.gz

clean:
Rscript --vanilla -e 'devtools::clean_dll()'
rm -f src/*.dll src/*.so src/*.o
sed -i -E 's/@useDynLib\s+[a-zA-Z]+/@useDynLib epiworldR/g' R/epiworldR-package.R
sed -i -E 's/useDynLib\(+[a-zA-Z]+/useDynLib(epiworldR/g' NAMESPACE
sed -i -E 's/^Package:.+/Package: epiworldR/g' DESCRIPTION
# sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldR/g' man/epiworldR-package.Rd
sed -i -E 's/^library\(epiworldRdev\)/library(epiworldR)/g' README.*

docs:
Rscript --vanilla -e 'devtools::document()'
Rscript --vanilla -e 'roxygen2::roxigenize()'

.PHONY: build update check clean docs docker-debug

Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# epiworldR 0.3-2 (dev)
# epiworldR 0.3-2

* Starting version 0.3-0, `epiworldR` is versioned using the same version as the C++ library, `epiworld`.

Expand All @@ -17,7 +17,7 @@
among agents: `distribute_viruses`, `distribute_tools`, and `distribute_entities`.


# epiworldR 0.1-0`
# epiworldR 0.1-0

* Force model to update agents' states when running a simulation.
This was causing issues when calling `run_multiple()` after a single
Expand Down
35 changes: 32 additions & 3 deletions R/tool.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ tool <- function(
death_reduction
) {

uses_deprecated <- FALSE
if (missing(prevalence)) {

warning(
"Starting version 0.3-0, the 'prevalence' argument is required.",
" It will be set to be 0.5. Next versions will fail with an error."
)

prevalence <- 0.5
as_proportion <- TRUE
uses_deprecated <- TRUE

}

structure(
tool_cpp(
name,
Expand All @@ -86,7 +100,12 @@ tool <- function(
recovery_enhancer,
death_reduction
),
class = "epiworld_tool"
class = "epiworld_tool",
uses_deprecated = uses_deprecated,
deprecated_args = list(
prevalence = prevalence,
as_proportion = as_proportion
)
)

}
Expand Down Expand Up @@ -168,8 +187,18 @@ add_tool <- function(model, tool, proportion) {
)

set_distribution_tool(
tool,
distribute_tool_randomly(proportion, TRUE)
tool = tool,
distfun = distribute_tool_randomly(proportion, TRUE)
)

} else if (isTRUE(attr(tool, "uses_deprecated"))) {

set_distribution_tool(
tool = tool,
distfun = distribute_tool_randomly(
prevalence = attr(tool, "deprecated_args")$prevalence,
as_proportion = attr(tool, "deprecated_args")$as_proportion
)
)

}
Expand Down
49 changes: 39 additions & 10 deletions R/virus.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,29 @@
#' @export
#' @aliases epiworld_virus
virus <- function(
name,
prevalence,
as_proportion,
prob_infecting,
recovery_rate = 0.5,
prob_death = 0.0,
post_immunity = -1.0,
incubation = 7.0
) {
name,
prevalence,
as_proportion,
prob_infecting,
recovery_rate = 0.5,
prob_death = 0.0,
post_immunity = -1.0,
incubation = 7.0
) {

uses_deprecated <- FALSE
if (missing(prevalence)) {

warning(
"Starting version 0.3-0, the 'prevalence' argument is required.",
" It will be set to be 0.5. Next versions will fail with an error."
)

prevalence <- 0.5
as_proportion <- TRUE
uses_deprecated <- TRUE

}

structure(
virus_cpp(
Expand All @@ -84,7 +98,12 @@ virus <- function(
post_immunity,
incubation
),
class = "epiworld_virus"
class = "epiworld_virus",
uses_deprecated = uses_deprecated,
deprecated_args = list(
prevalence = prevalence,
as_proportion = as_proportion
)
)

}
Expand Down Expand Up @@ -172,6 +191,16 @@ add_virus <- function(model, virus, proportion) {
distfun=distribute_virus_randomly(proportion, as_proportion = TRUE)
)

} else if (isTRUE(attr(tool, "uses_deprecated"))) {

set_distribution_virus(
virus = tool,
distfun = distribute_virus_randomly(
prevalence = attr(tool, "deprecated_args")$prevalence,
as_proportion = attr(tool, "deprecated_args")$as_proportion
)
)

}

UseMethod("add_virus")
Expand Down

0 comments on commit 6ea9a61

Please sign in to comment.