Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dpbuild
Title: A package to manage building of data products
Version: 0.3.1
Version: 0.4.0
Authors@R:
person(given = "Afshin",
family = "Mashadi-Hossein",
Expand Down Expand Up @@ -34,7 +34,6 @@ Imports:
yaml
Suggests:
httr,
qs,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# dpbuild 0.4.0

* Remove qs dependency and tooling

# dpbuild 0.3.1

* Fixed the bug related to the daap pin version not being captured properly in the log file
Expand Down
4 changes: 2 additions & 2 deletions R/dp_commit.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ dp_commit <- function(project_path = fs::path_wd(),
get_data_object_path <- function(project_path) {
# Define possible formats and their paths
possible_formats <- list(
RDS = fs::path_tidy(glue::glue("{project_path}/output_files/RDS_format/data_object.RDS")),
QS = fs::path_tidy(glue::glue("{project_path}/output_files/qs_format/data_object.qs"))
RDS = fs::path_tidy(glue::glue("{project_path}/output_files/RDS_format/data_object.RDS")) #,
# QS = fs::path_tidy(glue::glue("{project_path}/output_files/qs_format/data_object.qs"))
)

# Iterate through the list and check if the file exists
Expand Down
38 changes: 19 additions & 19 deletions R/dp_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ save_object <- function(data_object, project_path, type = "rds"){
# Check if directories for other types exist
# Create a mapping of type names to their directory format names
format_dirs <- list(
"rds" = "RDS_format",
"qs" = "qs_format"
"rds" = "RDS_format" #,
# "qs" = "qs_format"
# Add new formats here in the future
)

Expand All @@ -94,26 +94,26 @@ save_object <- function(data_object, project_path, type = "rds"){
}

switch(type,
rds = write_rds(data_object, project_path),
qs = write_qs(data_object, project_path)
rds = write_rds(data_object, project_path) # ,
# qs = write_qs(data_object, project_path)
)

}

#' @title Write qs object
#' @description Write qs object to `output_files/qs_format/` directory,
#' will create the directory if it does not exist
#' @noRd
write_qs <- function(data_object, project_path) {
rlang::check_installed("qs")
dataobj_path <- glue::glue(
"{project_path}/",
"output_files/qs_format/data_object.qs"
)
check_dir(dataobj_path)
qs::qsave(data_object, dataobj_path)
return(dataobj_path)
}
# #' @title Write qs object
# #' @description Write qs object to `output_files/qs_format/` directory,
# #' will create the directory if it does not exist
# #' @noRd
# write_qs <- function(data_object, project_path) {
# rlang::check_installed("qs")
# dataobj_path <- glue::glue(
# "{project_path}/",
# "output_files/qs_format/data_object.qs"
# )
# check_dir(dataobj_path)
# qs::qsave(data_object, dataobj_path)
# return(dataobj_path)
# }

#' @title Write rds object
#' @description Write rds object to `output_files/RDS_format/` directory,
Expand All @@ -129,7 +129,7 @@ write_rds <- function(data_object, project_path) {
return(dataobj_path)
}

object_types <- c("rds", "qs")
object_types <- c("rds") #, "qs")

#' @title Check directory
#' @description Checks if directory exists and will create one if it does not exist
Expand Down
28 changes: 14 additions & 14 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,21 @@ check_pins_compatibility <- function(project_path = "."){
#' @description read the output data object, for now only rds and qs are supported
#' @noRd
object_read <- function(project_path, type) {
type <- rlang::arg_match0(type, c("rds", "qs"))
type <- rlang::arg_match0(type, c("rds")) #, "qs"))
switch(type,
rds = readRDS(file = glue::glue("{project_path}/output_files/RDS_format/data_object.RDS")),
qs = read_qs(project_path)
rds = readRDS(file = glue::glue("{project_path}/output_files/RDS_format/data_object.RDS"))
# qs = read_qs(project_path)
)
}

#' @title Reas qs object
#' @description Read in qs object
#' @noRd
read_qs <- function(path) {
rlang::check_installed("qs")
dataobj_path <- glue::glue(
"{path}/",
"output_files/qs_format/data_object.qs"
)
qs::qread(dataobj_path)
}
# #' @title Reas qs object
# #' @description Read in qs object
# #' @noRd
# read_qs <- function(path) {
# rlang::check_installed("qs")
# dataobj_path <- glue::glue(
# "{path}/",
# "output_files/qs_format/data_object.qs"
# )
# qs::qread(dataobj_path)
# }
48 changes: 24 additions & 24 deletions tests/testthat/test-dp_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ test_that("properly creates data object paths", {
save_object(data_object, path, type = 'rds'),
file.path(path, "output_files/RDS_format/data_object.RDS"))
unlink(file.path(path, "output_files/RDS_format/"), recursive = TRUE)
expect_equal(
save_object(data_object, path, type = 'qs'),
file.path(path, "output_files/qs_format/data_object.qs"))
# expect_equal(
# save_object(data_object, path, type = 'qs'),
# file.path(path, "output_files/qs_format/data_object.qs"))

})

test_that("properly errors when different format directory exists", {
# Set up temporary project path
path <- withr::local_tempdir()
data_object <- structure(list(), class = "dp")
# test_that("properly errors when different format directory exists", {
# # Set up temporary project path
# path <- withr::local_tempdir()
# data_object <- structure(list(), class = "dp")

# Mock validation function
local_mocked_bindings(is_valid_dp_repository = function(path) TRUE)
# # Mock validation function
# local_mocked_bindings(is_valid_dp_repository = function(path) TRUE)

# Create directory structure for RDS format first
dir.create(file.path(path, "output_files/RDS_format"), recursive = TRUE)
# # Create directory structure for RDS format first
# dir.create(file.path(path, "output_files/RDS_format"), recursive = TRUE)

# Now try to save as qs format, which should error
expect_error(
save_object(data_object, path, type = 'qs'),
"Directory for RDS format already exists while trying to save as qs. Please try again with the existing daap format."
)
# # Now try to save as qs format, which should error
# expect_error(
# save_object(data_object, path, type = 'qs'),
# "Directory for RDS format already exists while trying to save as qs. Please try again with the existing daap format."
# )

# Clean up and test the reverse case
unlink(file.path(path, "output_files/RDS_format"), recursive = TRUE)
dir.create(file.path(path, "output_files/qs_format"), recursive = TRUE)
# # Clean up and test the reverse case
# unlink(file.path(path, "output_files/RDS_format"), recursive = TRUE)
# dir.create(file.path(path, "output_files/qs_format"), recursive = TRUE)

expect_error(
save_object(data_object, path, type = 'rds'),
"Directory for qs format already exists while trying to save as RDS. Please try again with the existing daap format."
)
})
# expect_error(
# save_object(data_object, path, type = 'rds'),
# "Directory for qs format already exists while trying to save as RDS. Please try again with the existing daap format."
# )
# })
Loading