Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging now works. Updated the DESCRIPTION #3

Merged
merged 44 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d2c8884
Packaging now works. Updated the DESCRIPTION
Kemuk Oct 31, 2024
51772b2
Commented out the environment line
Kemuk Oct 31, 2024
110d6c4
Imported the library instead of calling conda
Kemuk Oct 31, 2024
3d27693
Adjusted pkgdown.yaml to create Python Env
Kemuk Oct 31, 2024
a045981
Ammended pkgdown to work on pull request
Kemuk Oct 31, 2024
7b40bdc
Ammended MacOS testing
Kemuk Oct 31, 2024
607a854
Ammended the .Rbuildignore
Kemuk Oct 31, 2024
9d580d7
Commented out the rEpiabm line
Kemuk Oct 31, 2024
9735f13
Creating a workaround by creating a py env
Kemuk Oct 31, 2024
8774287
Created workaround in zzz.R that passed locally
Kemuk Nov 1, 2024
675bfb6
Ammended MacOS workflow
Kemuk Nov 1, 2024
7f95fc1
Ammended MacOS workflow
Kemuk Nov 1, 2024
14f6422
Fix MacOS workflow to activate environment
Kemuk Nov 1, 2024
2ccf778
Using simulation dataframe instead of tidyr
Kemuk Nov 1, 2024
04a30e8
Fixed the tidyr
Kemuk Nov 1, 2024
65739cc
Included tidyr into DESCRIPTION
Kemuk Nov 1, 2024
100a6bb
Removed print statements
Kemuk Nov 1, 2024
8181479
Ammended simulation flow check to read R directly
Kemuk Nov 1, 2024
a2a6437
Updated yaml files
Kemuk Nov 1, 2024
150c189
Updated test_windows.yml with x64 architecture
Kemuk Nov 1, 2024
941a6bb
Switched windows to 32-bit (x86 architecture)
Kemuk Nov 1, 2024
61ec97f
Made sure that Python is 64 bit in the yml
Kemuk Nov 1, 2024
3c8ac8a
Changed from 64 bit compilers to 32 bit ones
Kemuk Nov 1, 2024
a56cfcd
Disabled the multiarch
Kemuk Nov 1, 2024
7d9faa4
.Rbuildignore updated
Kemuk Nov 1, 2024
a99924a
Updated the DESCRIPTION and the ignore file
Kemuk Nov 1, 2024
b187170
Fixed Description
Kemuk Nov 1, 2024
89e7326
New attempt to get R working for windows
Kemuk Nov 1, 2024
9e7d85f
Updated rcmdcheck with multiarch
Kemuk Nov 1, 2024
e350ec6
Fixed quotation error in windows yml
Kemuk Nov 1, 2024
da8deb0
Rolled back windows.yml
Kemuk Nov 1, 2024
9c61fb8
Changed the Cache R packages step to use v2
Kemuk Jan 13, 2025
220bb75
Made "Check" the first step
Kemuk Jan 13, 2025
13fa3c7
Moved the check step back to where it was
Kemuk Jan 13, 2025
16005b9
Updated macOS github action
Kemuk Jan 13, 2025
aba9a02
Ensuring that 64 bit architecture is rcmd
Kemuk Jan 13, 2025
2fbf0c5
Fixed the cache version for windows
Kemuk Jan 13, 2025
27bf65d
Added verification steps for Windows and R
Kemuk Jan 13, 2025
598a633
Fixing MacOs
Kemuk Jan 13, 2025
54dfbba
MacOS yml changed to look like Ubuntu
Kemuk Jan 13, 2025
d4ef53f
Used reticulate to install python 3.9
Kemuk Jan 13, 2025
59b1ec5
Changed pkgdown python to 3.9
Kemuk Jan 13, 2025
0c21d71
Fixed syntax error with installing python
Kemuk Jan 13, 2025
b514f21
Forcing windows to stick to 64 bit
Kemuk Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^codecov\.yml$
^CRAN-RELEASE$
^cran-comments\.md$
^\.github$
^doc$
^Meta$
^windows\\i386\*
^i386\.*$
.lintr
17 changes: 14 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches:
- '**'
pull_request:
branches:
- '**'
release:
types: [published]
workflow_dispatch:
Expand All @@ -28,9 +32,16 @@ jobs:
extra-packages: any::pkgdown, local::., any::XML
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
- uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Setup r-reticulate env
run: reticulate::virtualenv_create("r-reticulate", Sys.which("python"))
shell: Rscript {0}

- name: Build site
run: Rscript -e "pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)"

- name: Deploy to GitHub pages
if: github.event_name != 'pull_request'
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "Unit tests: macOS"
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- '**'
Expand All @@ -22,6 +22,10 @@ jobs:

- name: Checkout repository
uses: actions/checkout@v2

- name: Install build dependencies
run: |
brew install curl

- name: Setup R
uses: r-lib/actions/setup-r@v2
Expand Down Expand Up @@ -49,6 +53,7 @@ jobs:
install.packages(c("devtools"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
reticulate::install_python(version = "3.9:latest")
shell: Rscript {0}

- name: Check
Expand All @@ -62,4 +67,4 @@ jobs:
- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "Unit tests: Ubuntu"
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- '**'
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name: "Unit tests: Windows"
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- '**'

jobs:

test:
name: tests on Windows with R ${{ matrix.R }}
runs-on: windows-latest
Expand All @@ -19,6 +18,13 @@ jobs:
R: [ '4.1.0' ]

steps:
- name: Check Windows architecture
run: |
if (-not [Environment]::Is64BitOperatingSystem) { throw "Not 64-bit Windows" }
Write-Host "OS Architecture: $([Environment]::Is64BitOperatingSystem)"
Write-Host "Process Architecture: $([Environment]::Is64BitProcess)"
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
shell: pwsh

- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -28,22 +34,31 @@ jobs:
with:
r-version: ${{ matrix.R }}
Ncpus: 2

r-arch: 'x64'

- name: Verify R architecture
run: |
Rscript -e "if(R.version$arch != 'x64') stop('R architecture is not 64-bit!')"
Rscript -e "cat('R Architecture:', R.version$arch, '\n')"
Rscript -e "cat('.Machine$sizeof.pointer:', .Machine$sizeof.pointer, '\n')"
Rscript -e "cat('Using R at:', R.home(), '\n')"
shell: cmd

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: cache R installed packages
- name: Cache R packages
uses: actions/[email protected]
id: cache
with:
path: |
${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-R${{ matrix.R }}-2-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-R${{ matrix.R }}-2-

- name: Install packages
run: |
install.packages(c("devtools"))
Expand All @@ -56,10 +71,10 @@ jobs:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check")
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran" ,'--no-multiarch'), error_on = "error", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
shell: bash
17 changes: 10 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: R-Wrapper of Epiabm
Version: 0.0.2
Authors@R: c(
person('Anita', 'Applegarth', role = c('aut', 'cre', 'cph'), email = 'anita.applegarth@reub.ox.ac.uk'),
person('Anita', 'Applegarth', role = c('aut', 'cre', 'cph'), email = 'anita.applegarth@reuben.ox.ac.uk'),
person('Kingsley', 'Oguma', role = 'aut', email = "[email protected]")
)
Description: Wraps the epiabm Python module in R.
Expand All @@ -12,20 +12,23 @@ Encoding: UTF-8
Archs: x64
SystemRequirements: Python (>= 2.7.0)
Suggests: tinytest
Imports: ggplot2, here
Depends:
reticulate (>= 1.14),
R (>= 3.3.0)
Imports:
ggplot2,
here,
tidyr,
reticulate (>= 1.14)
Depends: R (>= 3.3.0)
Config/reticulate:
list(
packages = list(
list(package = "numpy", pip = TRUE),
list(package = "pandas", pip = TRUE),
list(package = "pandas", pip = TRUE),
list(package = "matplotlib", pip = TRUE),
list(
package = "pyEpiabm",
pip = TRUE,
pip_options = "--index-url git+https://github.com/SABS-R3-Epidemiology/epiabm.git@main#egg=pyEpiabm&subdirectory=pyEpiabm"
pip_options = "--extra-index-url https://github.com/SABS-R3-Epidemiology/epiabm.git@main#egg=pyEpiabm&subdirectory=pyEpiabm"
)
)
)
RoxygenNote: 7.3.2
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
import(reticulate)
# Generated by roxygen2: do not edit by hand

export(check_python_env)
export(initialize_python_env)
35 changes: 19 additions & 16 deletions R/simulation_flow_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
# Example simulation script with data output
#
# Import dependencies
source("R/zzz.R")
initialize_python_env()
check_python_env()

library(reticulate)
#library(rEpiabm)
library(here)
library(tidyr)

os <- import("os")
logging <- import("logging")
pd <- import("pandas")
plt <- import("matplotlib.pyplot")
pe <- import("pyEpiabm")
os <- import("os", delay_load = TRUE)
logging <- import("logging", delay_load = TRUE)
pd <- import("pandas", delay_load = TRUE)
plt <- import("matplotlib.pyplot", delay_load = TRUE)
pe <- import("pyEpiabm", delay_load = TRUE)

# Set working directory for relative directory references
base_dir <- here()
Expand Down Expand Up @@ -91,12 +96,8 @@ sim$compress_csv()

# Create dataframe for plots
filename <- here("simulation_outputs", "output.csv")
df <- pd$read_csv(filename)
df <- read.csv(filename)

# Convert pandas dataframe to R dataframe
df_r <- as.data.frame(df)

# Load library for plotting
library(ggplot2)

# Reshape the data from wide to long format using base R
Expand All @@ -105,13 +106,15 @@ status_columns <- c("InfectionStatus.Susceptible",
"InfectionStatus.Recovered",
"InfectionStatus.Dead")

df_long <- data.frame(
time = rep(df_r$time, length(status_columns)),
Status = factor(rep(status_columns, each = nrow(df_r)),
levels = status_columns,
labels = c("Susceptible", "Infected", "Recovered", "Dead")),
Count = unlist(df_r[status_columns])
df_long <- pivot_longer(
df,
cols = all_of(status_columns),
names_to = "Status",
values_to = "Count"
)
df_long$Status <- factor(df_long$Status,
levels = status_columns,
labels = c("Susceptible", "Infected", "Recovered", "Dead"))

# Create the plot
p <- ggplot(df_long, aes(x = time, y = Count, color = Status)) +
Expand Down
Loading
Loading