Skip to content

Commit

Permalink
Merge branch 'release-0.1.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHeun committed Aug 18, 2023
2 parents 08ec74d + 4a58866 commit d4a4c00
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 71 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: PFUSetup
Title: Functions to Set Up the Directory Structure of the PFU Database
Version: 0.1.13
Date: 2023-04-24
Version: 0.1.15
Date: 2023-08-18
Authors@R:
person(given = "Matthew",
family = "Heun",
Expand Down
17 changes: 16 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,22 @@ title: "Release notes for `PFUSetup`"
output: html_document
---

# PFUSetup 0.1.13 (2023-04-24)

Cite all releases with doi [10.5281/zenodo.5228359](https://doi.org/10.5281/zenodo.5228359),
which always resolves to the latest release.


# PFUSetup 0.1.14 (2023-08-18)

* Now uses DOI for long-term citation.
* Relative paths if `home_path` and `cloud_storage_path` are both
set to an empty string (`""`).
* New tests for relative paths.
- Now at 58 tests, all passing.
- Test coverage remains at 100%.


# PFUSetup 0.1.13 (2023-04-24) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7859068.svg)](https://doi.org/10.5281/zenodo.7859068)

* Now defaulting to 2022 release of IEA World Extended Energy Balance (WEEB) data.
* No new tests.
Expand Down
108 changes: 70 additions & 38 deletions R/path_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@
#'
#' The default argument for `home_path` gets the value for `fs::path_home()`.
#'
#' Although this function is called [get_abs_paths()],
#' it can return relative paths if both `home_path` and `cloud_storage_path`
#' are set to "" (an empty string) and
#' `project_path` is set to the root folder of the project.
#' In that event, the leading file separator (`fsep`) is removed
#' from the path (if it exists).
#'
#' @param home_path The absolute path to the user's home directory.
#' @param dropbox_path The path to the user's Dropbox directory, relative to `home_path`.
#' @param cloud_storage_path The path to the user's cloud storage directory, relative to `home_path`.
#' @param project_path The path to the project directory, relative to `home_path`.
#' @param iea_year The year of IEA data release, as a string.
#' @param iea_folder_path The path to the IEA data directory, relative to `home_path`.
#' @param iea_data_path The path to the IEA data file, relative to `home_path`.
#' @param version The version of the input data.
#' @param input_data_path The path to the input data directory.
#' @param output_data_path The path to the output data directory.
#' @param input_data_path The path to the input data directory, relative to `home_path`.
#' @param output_data_path The path to the output data directory, relative to `home_path`.
#' @param fao_data_path The path to the FAO live animals data file, relative to `home_path`.
#' @param ilo_data_path The path to the ILO employment data file, relative to `home_path`.
#' @param ilo_employment_data_path The path to the ILO employment data file, relative to `home_path`.
#' @param ilo_working_hours_data_path The path to the ILO working hours data file, relative to `home_path`.
#' @param hmw_analysis_data_path The path to the human muscle work analysis file, relative to `home_path`.
#' @param amw_analysis_data_path The path to the animal muscle work file, relative to `home_path`.
#' @param mw_concordance_path The path to the muscle work country concordance file, relative to `home_path`.
Expand All @@ -27,24 +36,27 @@
#' @param ceda_data_folder The path to the folder containing CEDA (Centre for Environmental Data Analysis) data, relative to `home_path`.
#' @param reports_source_folders A string vector of paths to folders containing report sources.
#' @param reports_dest_folder The path to the folder into which reports will be written, relative to `home_path`.
#' @param pipeline_caches_folder The path to a folder containing zipped versions of the pipeline cache.
#' @param pipeline_caches_folder The path to a folder containing zipped versions of the pipeline cache, relative to `home_path`.
#' Data are stored as .zip files
#' Default is "PipelineCaches" relative to `project_path`.
#' @param pipeline_releases_folder The path to a folder containing released versions of the PSUT target data frame.
#' @param pipeline_releases_folder The path to a folder containing released versions of the PSUT target data frame, relative to `home_path`.
#' Data are stored using the `pins` package.
#' Default is "PipelineReleases" relative to `project_path`.
#' @param fsep The file separator used when constructing paths.
#' Default is `.Platform$file.sep`.
#'
#' @return A named list containing paths to important directories and files, including:
#' \itemize{
#' \item{home_path}{The absolute path to the user's home.}
#' \item{dropbox_path}{The absolute path of the user's Dropbox folder.}
#' \item{cloud_storage_path}{The absolute path of the user's cloud storage folder.}
#' \item{project_path}{The absolute path to the project folder.}
#' \item{iea_folder_path}{The absolute path to a folder containing IEA data.}
#' \item{iea_data_path}{The absolute path to the IEA data file for the OECD countries.}
#' \item{input_data_path}{The absolute path to the input data directory.}
#' \item{output_data_path}{The absolute path to the output data directory.}
#' \item{fao_data_path}{The absolute path to the FAO live animals data file.}
#' \item{ilo_data_path}{The absolute path to the ILO employment data file.}
#' \item{ilo_employment_data_path}{The absolute path to the ILO employment data file.}
#' \item{ilo_working_hours_data_path}{The absolute path to the ILO working hours data file.}
#' \item{hmw_analysis_data_path}{The absolute path to the human muscle work analysis file.}
#' \item{amw_analysis_data_path}{The absolute path to the animal muscle work file.}
#' \item{mw_concordance_path}{The absolute path to the muscle work country concordance file.}
Expand All @@ -67,20 +79,25 @@
#'
#' @examples
#' get_abs_paths()
#' # Set relative paths with empty strings
#' get_abs_paths(home_path = "", cloud_storage_path = "",
#' project_path = "my_project_path")
get_abs_paths <- function(home_path = fs::path_home() %>% as.character(),
dropbox_path = "Dropbox",
project_path = file.path(dropbox_path,
cloud_storage_path = "Dropbox",
project_path = file.path(cloud_storage_path,
"Fellowship 1960-2015 PFU database"),
iea_year = "2022",
iea_folder_path = file.path(project_path,
"IEA extended energy balance data",
"IEA 2022 energy balance data"),
paste("IEA", iea_year, "energy balance data")),
iea_data_path = file.path(iea_folder_path,
"IEA Extended Energy Balances 2022 (TJ).csv"),
paste("IEA Extended Energy Balances", iea_year, "(TJ).csv")),
version = "v1.1",
input_data_path = file.path(project_path, "InputData", version),
output_data_path = file.path(project_path, "OutputData"),
fao_data_path = file.path(input_data_path, "fao_qcl_data.rds"),
ilo_data_path = file.path(input_data_path, "ilo_hmw_data.rds"),
ilo_employment_data_path = file.path(input_data_path, "ilo_employment_data.rds"),
ilo_working_hours_data_path = file.path(input_data_path, "ilo_working_hours_data.rds"),
hmw_analysis_data_path = file.path(input_data_path, "hmw_analysis_data.xlsx"),
amw_analysis_data_path = file.path(input_data_path, "amw_analysis_data.xlsx"),
mw_concordance_path = file.path(input_data_path, "FAO_ISO_MW_Mapping.xlsx"),
Expand All @@ -89,34 +106,49 @@ get_abs_paths <- function(home_path = fs::path_home() %>% as.character(),
phi_constants_path = file.path(input_data_path, "phi_constants.xlsx"),
exemplar_table_path = file.path(input_data_path, "Exemplar_Table.xlsx"),
fu_analysis_folder = file.path(input_data_path, "FU analysis data"),
ceda_data_folder = file.path(input_data_path, "CEDA Data"),
machine_data_folder = file.path(input_data_path, "Machines - Data"),
ceda_data_folder = file.path(input_data_path, "CEDA Data"),
reports_source_folders = "reports",
reports_dest_folder = file.path(output_data_path, "Reports"),
pipeline_caches_folder = file.path(output_data_path, "PipelineCaches"),
pipeline_releases_folder = file.path(output_data_path, "PipelineReleases")) {
pipeline_releases_folder = file.path(output_data_path, "PipelineReleases"),
fsep = .Platform$file.sep) {

list(home_path = home_path,
dropbox_path = file.path(home_path, dropbox_path),
project_path = file.path(home_path, project_path),
iea_folder_path = file.path(home_path, iea_folder_path),
input_data_path = file.path(home_path, input_data_path),
output_data_path = file.path(home_path, output_data_path),
iea_data_path = file.path(home_path, iea_data_path),
fao_data_path = file.path(home_path, fao_data_path),
ilo_data_path = file.path(home_path, ilo_data_path),
hmw_analysis_data_path = file.path(home_path, hmw_analysis_data_path),
amw_analysis_data_path = file.path(home_path, amw_analysis_data_path),
mw_concordance_path = file.path(home_path, mw_concordance_path),
country_concordance_path = file.path(home_path, country_concordance_path),
aggregation_mapping_path = file.path(home_path, aggregation_mapping_path),
exemplar_table_path = file.path(home_path, exemplar_table_path),
phi_constants_path = file.path(home_path, phi_constants_path),
fu_analysis_folder = file.path(home_path, fu_analysis_folder),
machine_data_folder = file.path(home_path, machine_data_folder),
ceda_data_folder = file.path(home_path, ceda_data_folder),
reports_source_folders = reports_source_folders,
reports_dest_folder = file.path(home_path, reports_dest_folder),
pipeline_caches_folder = file.path(home_path, pipeline_caches_folder),
pipeline_releases_folder = file.path(home_path, pipeline_releases_folder))
if (home_path == "" & cloud_storage_path == "") {
csp <- ""
remove_leading_file_seps <- TRUE
} else {
csp <- file.path(home_path, cloud_storage_path)
remove_leading_file_seps <- FALSE
}
out <- list(home_path = home_path,
cloud_storage_path = csp,
project_path = file.path(home_path, project_path, fsep = fsep),
iea_folder_path = file.path(home_path, iea_folder_path, fsep = fsep),
input_data_path = file.path(home_path, input_data_path, fsep = fsep),
output_data_path = file.path(home_path, output_data_path, fsep = fsep),
iea_data_path = file.path(home_path, iea_data_path, fsep = fsep),
fao_data_path = file.path(home_path, fao_data_path, fsep = fsep),
ilo_employment_data_path = file.path(home_path, ilo_employment_data_path, fsep = fsep),
ilo_working_hours_data_path = file.path(home_path, ilo_working_hours_data_path, fsep = fsep),
hmw_analysis_data_path = file.path(home_path, hmw_analysis_data_path, fsep = fsep),
amw_analysis_data_path = file.path(home_path, amw_analysis_data_path, fsep = fsep),
mw_concordance_path = file.path(home_path, mw_concordance_path, fsep = fsep),
country_concordance_path = file.path(home_path, country_concordance_path, fsep = fsep),
aggregation_mapping_path = file.path(home_path, aggregation_mapping_path, fsep = fsep),
exemplar_table_path = file.path(home_path, exemplar_table_path, fsep = fsep),
phi_constants_path = file.path(home_path, phi_constants_path, fsep = fsep),
fu_analysis_folder = file.path(home_path, fu_analysis_folder, fsep = fsep),
machine_data_folder = file.path(home_path, machine_data_folder, fsep = fsep),
ceda_data_folder = file.path(home_path, ceda_data_folder, fsep = fsep),
reports_source_folders = reports_source_folders,
reports_dest_folder = file.path(home_path, reports_dest_folder, fsep = fsep),
pipeline_caches_folder = file.path(home_path, pipeline_caches_folder, fsep = fsep),
pipeline_releases_folder = file.path(home_path, pipeline_releases_folder, fsep = fsep))
if (remove_leading_file_seps) {
out <- lapply(out, FUN = function(path) {
gsub(pattern = paste0("^", fsep), replacement = "", x = path)
})
}
return(out)
}
10 changes: 5 additions & 5 deletions docs/reference/get_abs_paths.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ citEntry(entry = "Manual",
title = "PFUSetup: Automated setup for the PFU database project.",
author = personList(as.person("Matthew Kuperus Heun")),
year = "2023",
note = "R package version 0.1.13",
url = "https://EnergyEconomyDecoupling.github.io/PFUSetup/",
note = "R package version 0.1.14",
url = "https://doi.org/10.5281/zenodo.5228359",
doi = "10.5281/zenodo.5228359",

textVersion =
paste("Matthew Kuperus Heun (2023).",
"PFUSetup: Automated setup for the PFU database project.",
"R package version 0.1.13.",
"R package version 0.1.14.",
"https://EnergyEconomyDecoupling.github.io/PFUSetup/",
"https://doi.org/10.5281/zenodo.5228359")
)
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Centre
CMD
Codecov
DOI
doi
dest
dropbox
EnergyEconomyDecoupling
Expand Down Expand Up @@ -34,3 +35,4 @@ PipelineReleases
PSUT
Sys
WEEB
zenodo
Loading

0 comments on commit d4a4c00

Please sign in to comment.