Skip to content

Commit

Permalink
Merge pull request #21 from robinhasse/tidyIAMCfastTrack
Browse files Browse the repository at this point in the history
BRICK input, mappings, indentation linter
  • Loading branch information
robinhasse authored Nov 24, 2023
2 parents 27ebd27 + 684a335 commit efc530b
Show file tree
Hide file tree
Showing 92 changed files with 3,733 additions and 341 deletions.
4 changes: 2 additions & 2 deletions .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ValidationKey: '786800'
ValidationKey: '984200'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
AcceptedNotes: ~
AcceptedNotes: 'Unexported object imported by a .:::. call: .GDPuc:::wb_wdi.'
allowLinterWarnings: no
97 changes: 25 additions & 72 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Run CI for R using https://eddelbuettel.github.io/r-ci/

name: check

on:
Expand All @@ -8,92 +6,45 @@ on:
pull_request:
branches: [main, master]

env:
USE_BSPM: "true"
_R_CHECK_FORCE_SUGGESTS_: "false"
NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")'

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Bootstrap
run: |
sudo chown runner -R .
sudo locale-gen en_US.UTF-8
sudo add-apt-repository -y ppa:ubuntugis/ppa
curl -OLs https://eddelbuettel.github.io/r-ci/run.sh
chmod 0755 run.sh
./run.sh bootstrap
rm -f bspm_*.tar.gz
- name: Enable r-universe repo, modify bspm integration
run: |
# install packages from https://pik-piam.r-universe.dev and CRAN
echo '
options(repos = c(universe = "https://pik-piam.r-universe.dev",
CRAN = "https://cloud.r-project.org"))
' >> .Rprofile
cat .Rprofile
# modify bspm integration to never install binary builds of PIK CRAN packages
sudo sed -i '/bspm::enable()/d' /etc/R/Rprofile.site
# need double % because of printf, %s is replaced with "$NO_BINARY_INSTALL_R_PACKAGES" (see "env:" above)
printf '
local({
expr <- quote({
if (!is.null(repos)) {
noBinaryInstallRPackages <- %s
pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]),
pkgs[pkgs %%in%% noBinaryInstallRPackages])
}
type <- "source"
})
trace(utils::install.packages, expr, print = FALSE)
})
' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null
cat /etc/R/Rprofile.site
- name: Set up Pandoc
uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-pandoc@v2

- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: r-lib/actions/setup-r@v2
with:
python-version: 3.9
use-public-rspm: true
extra-repositories: "https://rse.pik-potsdam.de/r/packages"

- name: Cache R libraries
if: ${{ !env.ACT }} # skip when running locally via nektos/act
uses: pat-s/always-upload-cache@v3
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: /usr/local/lib/R/
key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }}
restore-keys: |
3-${{ runner.os }}-usr-local-lib-R-
- name: Restore R library permissions
run: |
sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library
- name: Install dependencies
run: |
./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev
./run.sh install_all
./run.sh install_r_binary covr rstudioapi
./run.sh install_r lucode2
extra-packages: |
gamstransfer=?ignore
any::lucode2
any::covr
any::madrat
any::magclass
any::citation
any::gms
any::goxygen
any::GDPuc
# piam packages also available on CRAN (madrat, magclass, citation,
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest version

- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install python dependencies if applicable
run: |
[ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true
[ -f requirements.txt ] && pip install -r requirements.txt || true
- name: Remove bspm integration # to get rid of error when running install.packages
run: |
sudo sed -i '/ trace(utils::install.packages, expr, print = FALSE)/d' /etc/R/Rprofile.site
cat /etc/R/Rprofile.site
- name: Verify validation key
shell: Rscript {0}
run: lucode2:::validkey(stopIfInvalid = TRUE)
Expand All @@ -106,6 +57,8 @@ jobs:
- name: Test coverage
shell: Rscript {0}
run: covr::codecov(quiet = FALSE)
run: |
nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps"))
if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE)
env:
NOT_CRAN: "true"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9013
rev: v0.3.2.9025
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mredgebuildings: Prepare data to be used by the EDGE-Buildings model'
version: 0.4.0
date-released: '2023-11-09'
version: 0.5.0
date-released: '2023-11-23'
abstract: Prepare data to be used by the EDGE-Buildings model.
authors:
- family-names: Hasse
Expand Down
15 changes: 9 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
Type: Package
Package: mredgebuildings
Title: Prepare data to be used by the EDGE-Buildings model
Version: 0.4.0
Date: 2023-11-09
Version: 0.5.0
Date: 2023-11-23
Authors@R: c(
person("Robin", "Hasse", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1818-3186")),
person("Pascal", "Führlich", , "[email protected]", role = "aut"),
person("Antoine", "Levesque", role = "aut"),
person("Hagen", "Tockhorn", role="aut")
person("Hagen", "Tockhorn", role = "aut")
)
Description: Prepare data to be used by the EDGE-Buildings model.
License: MIT + file LICENSE
URL: https://github.com/pik-piam/mredgebuildings
Depends:
madrat (>= 2.8.1),
magclass,
magclass (>= 6.11.0),
mrdrivers (>= 1.0.0),
mrcommons (>= 1.7.1)
mrcommons (>= 1.35.0),
mrremind
Imports:
brick (>= 0.1.3),
dplyr,
GDPuc,
openxlsx,
plyr,
quadprog,
quitte,
readxl,
rlang,
tidyr,
zoo
Suggests:
Expand Down
32 changes: 29 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# Generated by roxygen2: do not edit by hand

export(calcBuildingStock)
export(calcCarrierPrices)
export(calcCostConstruction)
export(calcCostDemolition)
export(calcCostRenovation)
export(calcFEdemandBuildings)
export(calcFloorspacePast)
export(calcHDDCDD)
export(calcHeatingCapacity)
export(calcHeatingSystem)
export(calcHouseholdSize)
export(calcIEAPFU)
export(calcLifetimeParams)
export(calcMatchingReference)
export(calcRenovationAlternatives)
export(calcPopulationBuildings)
export(calcRenovationCostModel)
export(calcShareETP)
export(calcShareOdyssee)
export(calcSharesBuildingDemand)
export(calcSurface)
export(calcUEdemand)
export(calcUValue)
export(convertCensusHub)
export(convertDaioglou)
export(convertDeetman2020)
export(convertEEAfloorspace)
export(convertEUBuildingsDB)
export(convertEnergiforsk2016)
Expand All @@ -27,6 +39,8 @@ export(fullEDGEBUILDINGS)
export(getFEbyEUEC)
export(readCensusHub)
export(readDaioglou)
export(readDeetman2020)
export(readECEMF)
export(readEEAfloorspace)
export(readEHI)
export(readEUBuildingsDB)
Expand All @@ -39,12 +53,15 @@ export(readHotmaps)
export(readIEAfloorspace)
export(readOdyssee)
export(readUNHouseholds)
export(toolCountryFillAvg)
export(toolDisaggregate)
export(toolUnitConversion)
import(madrat)
import(magclass)
import(mrcommons)
import(mrdrivers)
import(mrremind)
importFrom(brick,getBrickMapping)
importFrom(dplyr,"%>%")
importFrom(dplyr,.data)
importFrom(dplyr,across)
Expand All @@ -54,24 +71,31 @@ importFrom(dplyr,any_of)
importFrom(dplyr,arrange)
importFrom(dplyr,as_tibble)
importFrom(dplyr,bind_rows)
importFrom(dplyr,cross_join)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
importFrom(dplyr,group_modify)
importFrom(dplyr,inner_join)
importFrom(dplyr,last_col)
importFrom(dplyr,left_join)
importFrom(dplyr,matches)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,reframe)
importFrom(dplyr,relocate)
importFrom(dplyr,rename)
importFrom(dplyr,right_join)
importFrom(dplyr,select)
importFrom(dplyr,semi_join)
importFrom(dplyr,slice)
importFrom(dplyr,summarise)
importFrom(dplyr,syms)
importFrom(dplyr,ungroup)
importFrom(madrat,calcOutput)
importFrom(madrat,readSource)
importFrom(madrat,toolAggregate)
importFrom(madrat,toolCountry2isocode)
importFrom(madrat,toolCountryFill)
importFrom(madrat,toolGetMapping)
Expand All @@ -93,6 +117,8 @@ importFrom(magclass,mbind)
importFrom(magclass,mselect)
importFrom(magclass,setNames)
importFrom(magclass,setYears)
importFrom(magclass,time_interpolate)
importFrom(openxlsx,read.xlsx)
importFrom(plyr,revalue)
importFrom(quadprog,solve.QP)
importFrom(quitte,as.quitte)
Expand All @@ -105,17 +131,17 @@ importFrom(quitte,removeColNa)
importFrom(quitte,replace_column)
importFrom(quitte,revalue.levels)
importFrom(readxl,read_xlsx)
importFrom(rlang,.data)
importFrom(rlang,syms)
importFrom(stats,coef)
importFrom(stats,lm)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,nls)
importFrom(stats,predict)
importFrom(stats,pweibull)
importFrom(tidyr,complete)
importFrom(tidyr,gather)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,replace_na)
importFrom(tidyr,separate)
importFrom(tidyr,spread)
Expand Down
Loading

0 comments on commit efc530b

Please sign in to comment.