Skip to content

Commit

Permalink
[CI] Fix CI errors (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyuanjia authored Nov 20, 2022
1 parent 35b73c9 commit 7cf5e0e
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
config:
- {os: windows-latest, r: 'release', not_cran: false}
- {os: macOS-latest, r: 'release', not_cran: false}
- {os: ubuntu-latest, r: 'release', not_cran: true}
- {os: ubuntu-latest, r: 'release', not_cran: true, _EPLUSR_SKIP_TESTS_TRANSITION_: true, _EPLUSR_SKIP_TESTS_DOWNLOAD_EPW_: true, _EPLUSR_SKIP_TESTS_DOWNLOAD_IDD_: true, _EPLUSR_SKIP_TESTS_BASEMENT_: true}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
NOT_CRAN: true
RGL_USE_NULL: true

steps:
Expand All @@ -47,6 +46,6 @@ jobs:
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Build site without deploying
if: github.event_name == 'pull_request'
if: ${{ github.event_name == 'pull_request' && !contains(github.event.head_commit.message, '[skip-website]') }}
run: |
Rscript -e 'pkgdown::build_site(preview = FALSE, install = FALSE)'
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: eplusr
Title: A Toolkit for Using Whole Building Simulation Program
'EnergyPlus'
Version: 0.15.2
Version: 0.15.2.9001
Authors@R: c(
person(given = "Hongyuan",
family = "Jia",
Expand Down Expand Up @@ -46,7 +46,7 @@ Suggests:
Encoding: UTF-8
Roxygen: list(markdown = TRUE, roclets = c("rd", "namespace",
"collate"))
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
SystemRequirements: EnergyPlus (optional)
(<https://energyplus.net>); udunits2
Collate:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ importFrom(lubridate,force_tz)
importFrom(lubridate,hours)
importFrom(lubridate,leap_year)
importFrom(lubridate,make_date)
importFrom(lubridate,make_datetime)
importFrom(lubridate,mday)
importFrom(lubridate,minutes)
importFrom(lubridate,month)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# eplusr (development version)

## Bug fixes

* Fix EPW parsing error due to an update of lubridate (#532).

# eplusr 0.15.2

## New features
Expand Down
11 changes: 6 additions & 5 deletions R/impl-epw.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @importFrom stringi stri_isempty stri_match_first_regex stri_replace_all_charclass
#' @importFrom stringi stri_split_charclass stri_split_fixed stri_sub "stri_sub<-"
#' @importFrom stringi stri_trans_tolower stri_trans_totitle stri_trans_toupper
#' @importFrom lubridate as_datetime make_date make_datetime force_tz tz
#' @importFrom lubridate as_datetime make_date force_tz tz
#' @importFrom lubridate days_in_month minutes hours days years leap_year
#' @importFrom lubridate mday month yday year "year<-" parse_date_time
#' @importFrom data.table "%chin%" chmatch copy fread fwrite as.data.table
Expand Down Expand Up @@ -187,7 +187,7 @@ parse_epw_file <- function (path, idd = NULL, encoding = "unknown") {
set(epw_data, NULL, "line", seq_len(nrow(epw_data)))

# parse date time
epw_data[, datetime := lubridate::make_datetime(year, month, day, hour, tz = "UTC")]
epw_data[, datetime := stringi::stri_datetime_create(year, month, day, hour, tz = "UTC", lenient = TRUE)]

# match date time
matched <- match_epw_data(epw_data, epw_header)
Expand Down Expand Up @@ -2223,10 +2223,11 @@ merge_epw_new_data <- function (epw_data, epw_header, matched, data, target_peri
# }}}

# check if the datetime is valid
expect_start <- make_datetime(
expect_start <- stringi::stri_datetime_create(
lubridate::year(start), lubridate::month(start), lubridate::mday(start),
# hour # minute
0L, step
0L, step,
tz = "UTC", lenient = TRUE
)
if (start != expect_start) {
abort(paste0("Invalid starting date time found in input data. ",
Expand Down Expand Up @@ -2336,7 +2337,7 @@ merge_epw_new_data <- function (epw_data, epw_header, matched, data, target_peri
set(data, NULL, "hour", data$hour + 1L)

# ignore minute when validation
set(data, NULL, "datetime", lubridate::make_datetime(data$year, data$month, data$day, data$hour, tz = lubridate::tz(data$datetime)))
set(data, NULL, "datetime", stringi::stri_datetime_create(data$year, data$month, data$day, data$hour, tz = lubridate::tz(data$datetime), lenient = TRUE))
}

m <- match_epw_data(data, header, target_period)
Expand Down
5 changes: 3 additions & 2 deletions R/impl-sql.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @importFrom RSQLite SQLite dbConnect dbDisconnect dbGetQuery dbListTables dbReadTable
#' @importFrom data.table setDT setcolorder setorder
#' @importFrom lubridate year force_tz make_datetime
#' @importFrom lubridate year force_tz
NULL

# RPFREQ {{{
Expand Down Expand Up @@ -400,7 +400,8 @@ create_sql_datetime <- function (time, first_day = NULL, year = NULL, tz = "UTC"
}

set(time, NULL, "datetime",
lubridate::make_datetime(time$year, time$month, time$day, time$hour, time$minute, tz = tz)
# see https://github.com/tidyverse/lubridate/issues/1098
stringi::stri_datetime_create(time$year, time$month, time$day, time$hour, time$minute, tz = tz, lenient = TRUE)
)

set(time, NULL, "year", NULL)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test_that("Assertion functions", {
file.create(file.path(tempdir(), "energyplus.exe"))
is_eplus_path(tempdir())
})
unlink(file.path(tempdir(), c("Energy+.idd", "energyplus", "energyplus.exe")))

expect_false(is_idd(1))
expect_true(is_idd(use_idd(8.8, download = "auto")))
Expand Down
80 changes: 42 additions & 38 deletions tests/testthat/test-run.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ test_that("ExpandObjects()", {
test_that("Basement()", {
skip_on_cran()

skip_if(Sys.getenv("_EPLUSR_SKIP_TESTS_BASEMENT_") != "")
out_dir <- file.path(tempdir(), "Basement")
if (!dir.exists(out_dir)) dir.create(out_dir)

Expand Down Expand Up @@ -298,6 +299,7 @@ test_that("Basement()", {
test_that("Slab()", {
skip_on_cran()

skip_if(Sys.getenv("_EPLUSR_SKIP_TESTS_BASEMENT_") != "")
out_dir <- file.path(tempdir(), "Basement")
if (!dir.exists(out_dir)) dir.create(out_dir)

Expand Down Expand Up @@ -603,44 +605,46 @@ test_that("energyplus()", {
expect_true(is.na(files["experr"]))
unlink(c(path_exp, out_dir), recursive = TRUE)

# can run Basement
path_base <- copy_eplus_example(8.8, "LgOffVAVusingBasement.idf")
expect_error(energyplus(path_base, NULL, out_dir, echo = FALSE))
# modify the input in order to reduce the simulation time
l <- read_lines(path_base)
l[grepl("IYRS: Maximum number of yearly iterations", string), string := "1;"]
write_lines(l, path_base)
res_base <- energyplus(path_base, weather, out_dir, design_day = TRUE, echo = FALSE)
expect_equal(length(res_base$file), 57L)
expect_equal({files <- unlist(res_base$file); files <- files[!is.na(files)]; length(files)}, 27L)
expect_equal(sum(!file.exists(file.path(out_dir, files))), 0L)
expect_equal(sort(unname(files[names(files) != "epw"])), list.files(out_dir, "LgOffVAVusingBasement"))
expect_equal(res_base$run[program == "Basement", exit_status], list(0L))
expect_true(file.exists(file.path(out_dir, files["expidf"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_idf"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_csv"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_out"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_audit"])))
unlink(c(path_base, out_dir), recursive = TRUE)

# can run Slab
path_slab <- copy_eplus_example(8.8, "5ZoneAirCooledWithSlab.idf")
expect_error(energyplus(path_slab, NULL, out_dir, echo = FALSE))
# modify the input in order to reduce the simulation time
l <- read_lines(path_slab)
l[grepl("IYRS: Number of years to iterate", string), string := "1,"]
l[grepl("ConvTol: Convergence Tolerance", string), string := "1;"]
write_lines(l, path_slab)
res_slab <- energyplus(path_slab, weather, out_dir, echo = FALSE)
expect_equal(length(res_slab$file), 57L)
expect_equal({files <- unlist(res_slab$file); files <- files[!is.na(files)]; length(files)}, 26L)
expect_equal(sum(!file.exists(file.path(out_dir, files))), 0L)
expect_equal(sort(unname(files[names(files) != "epw"])), list.files(out_dir, "5ZoneAirCooledWithSlab"))
expect_equal(res_slab$run[program == "Slab", exit_status], list(0L))
expect_true(file.exists(file.path(out_dir, files["slab_ger"])))
expect_true(file.exists(file.path(out_dir, files["slab_gtp"])))
expect_true(file.exists(file.path(out_dir, files["slab_out"])))
unlink(c(path_slab, out_dir), recursive = TRUE)
if(Sys.getenv("_EPLUSR_SKIP_TESTS_BASEMENT_") == "") {
# can run Basement
path_base <- copy_eplus_example(8.8, "LgOffVAVusingBasement.idf")
expect_error(energyplus(path_base, NULL, out_dir, echo = FALSE))
# modify the input in order to reduce the simulation time
l <- read_lines(path_base)
l[grepl("IYRS: Maximum number of yearly iterations", string), string := "1;"]
write_lines(l, path_base)
res_base <- energyplus(path_base, weather, out_dir, design_day = TRUE, echo = FALSE)
expect_equal(length(res_base$file), 57L)
expect_equal({files <- unlist(res_base$file); files <- files[!is.na(files)]; length(files)}, 27L)
expect_equal(sum(!file.exists(file.path(out_dir, files))), 0L)
expect_equal(sort(unname(files[names(files) != "epw"])), list.files(out_dir, "LgOffVAVusingBasement"))
expect_equal(res_base$run[program == "Basement", exit_status], list(0L))
expect_true(file.exists(file.path(out_dir, files["expidf"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_idf"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_csv"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_out"])))
expect_true(file.exists(file.path(out_dir, files["bsmt_audit"])))
unlink(c(path_base, out_dir), recursive = TRUE)

# can run Slab
path_slab <- copy_eplus_example(8.8, "5ZoneAirCooledWithSlab.idf")
expect_error(energyplus(path_slab, NULL, out_dir, echo = FALSE))
# modify the input in order to reduce the simulation time
l <- read_lines(path_slab)
l[grepl("IYRS: Number of years to iterate", string), string := "1,"]
l[grepl("ConvTol: Convergence Tolerance", string), string := "1;"]
write_lines(l, path_slab)
res_slab <- energyplus(path_slab, weather, out_dir, echo = FALSE)
expect_equal(length(res_slab$file), 57L)
expect_equal({files <- unlist(res_slab$file); files <- files[!is.na(files)]; length(files)}, 26L)
expect_equal(sum(!file.exists(file.path(out_dir, files))), 0L)
expect_equal(sort(unname(files[names(files) != "epw"])), list.files(out_dir, "5ZoneAirCooledWithSlab"))
expect_equal(res_slab$run[program == "Slab", exit_status], list(0L))
expect_true(file.exists(file.path(out_dir, files["slab_ger"])))
expect_true(file.exists(file.path(out_dir, files["slab_gtp"])))
expect_true(file.exists(file.path(out_dir, files["slab_out"])))
unlink(c(path_slab, out_dir), recursive = TRUE)
}

# can convert eso to IP
path_ip <- copy_eplus_example(8.8, "1ZoneUncontrolled.idf")
Expand Down

0 comments on commit 7cf5e0e

Please sign in to comment.