Skip to content

Commit

Permalink
version 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ycli1995 authored and cran-robot committed Nov 6, 2023
1 parent bc57d04 commit c9f75fa
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 168 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: hdf5r.Extra
Type: Package
Title: Extensions for 'HDF5' R Interfaces
Version: 0.0.2
Date: 2023-09-21
Version: 0.0.3
Date: 2023-10-19
Authors@R: person(given = "Yuchen", family = "Li", email = "ycli1995@outlook.com", role = c("aut", "cre"))
Description: Some methods to manipulate 'HDF5' files, extending the 'hdf5r' package. Reading and writing R objects to 'HDF5' formats follow the specification of 'AnnData' <https://anndata.readthedocs.io/en/latest/fileformat-prose.html>.
Depends: R (>= 4.1.0), hdf5r (>= 1.3.8), methods, utils
Expand All @@ -13,8 +13,8 @@ Encoding: UTF-8
URL: https://github.com/ycli1995/hdf5r.Extra
BugReports: https://github.com/ycli1995/hdf5r.Extra/issues
NeedsCompilation: no
Packaged: 2023-09-22 05:07:50 UTC; mydocker
Packaged: 2023-11-06 09:22:01 UTC; mydocker
Author: Yuchen Li [aut, cre]
Maintainer: Yuchen Li <ycli1995@outlook.com>
Repository: CRAN
Date/Publication: 2023-09-22 07:30:02 UTC
Date/Publication: 2023-11-06 09:40:02 UTC
16 changes: 8 additions & 8 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
092ba5a9d231d26ff9318433cb2a6a22 *DESCRIPTION
04a31218bca95f9e969271734505e1c3 *DESCRIPTION
1285b0f228eef791319304295b0184fc *LICENSE
46afd66ee3b76c30a741a802b42432f8 *NAMESPACE
8a70b484241314a464dc9a908c33d14f *NEWS.md
7a1b18844d91d0cb08d4cd1f6e3b69b4 *NAMESPACE
ee4f0fd399ca4698fe3e0e88795ff60a *NEWS.md
5350e6ab1434ccd0a70dfa1562af2f8b *R/AllGenerics.R
8bbd664ea2fa7923921b15716f4a0f26 *R/hdf5-functions.R
f2b9c56104d1562ca1a4675b6e7fb968 *R/hdf5-internal.R
0a7c3b98617a7270176c9337603aa092 *R/hdf5-methods.R
4fd2186b9ebae5f440e8c0299788cc27 *R/hdf5-functions.R
743f008608c7e7f7959c63dac97460e1 *R/hdf5-internal.R
872bf803358ce542a8bca26d661777c4 *R/hdf5-methods.R
c79087585c3cb97e93603e4637db4e6d *R/zzz.R
d3f437597544eedce65892287c06d94b *README.md
e28ff15653d6ad6c23682246a76fcd04 *inst/extdata/pbmc_small.h5ad
3148c7d9176dc65616bee55654c3451e *man/H5-attributs.Rd
3463e52b5f70b410cb148b854de4c130 *man/H5-dataset-info.Rd
993517368aa1f3d01bde03c4c28d8188 *man/H5-dataset-info.Rd
be8266f09349e8e3a2a843a179b4e213 *man/h5AbsLinkName.Rd
4e8da2fb480dcb9b99bc18111d78eb8f *man/h5Backup.Rd
4002d9bfe316fb247f5249b556b6fc22 *man/h5Class.Rd
Expand All @@ -26,7 +26,7 @@ b633edf99a57afe4ba05d9d70151e28f *man/h5CreateGroup.Rd
3faf6f1047eb373131a5c5d6b85c71c6 *man/h5Open.Rd
d43a4069a214e44352f0d002d2285e50 *man/h5Overwrite.Rd
4d76f73f11d9b95609dddac3717dbd7e *man/h5Prep.Rd
73c480de6c10480475c89ec27c4b988a *man/h5Read.Rd
734515a6178bc598a0348f01f820f304 *man/h5Read.Rd
c0052eb84def831ed64408f2c40576a7 *man/h5ReadDataset.Rd
4fbea9b7744d9241d9fef19df2ffbc41 *man/h5TryOpen.Rd
23d1d84660aea5b80a04f30d5c6147c0 *man/h5Write.Rd
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export(h5WriteDataset)
export(h5WriteScalar)
export(is.H5D)
export(is.H5Group)
importClassesFrom(Matrix,dgCMatrix)
importClassesFrom(Matrix,dgRMatrix)
importFrom(Matrix,sparseMatrix)
importFrom(MatrixExtra,t_shallow)
Expand All @@ -116,7 +117,6 @@ importFrom(hdf5r,guess_chunks)
importFrom(hdf5r,guess_dtype)
importFrom(hdf5r,h5attr_names)
importFrom(hdf5r,h5const)
importFrom(hdf5r,h5garbage_collect)
importFrom(methods,is)
importFrom(methods,slot)
importFrom(rlang,.data)
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# hdf5r.Extra 0.0.3
## Bug fixes
* Fixed bugs caused by `h5Write` when transform an S4 object to list.

## Improvement
* Clarify usage of `toS4.func` for `h5Read`.

# hdf5r.Extra 0.0.2
## Bug fixes
* Fixed bugs caused by `H5Backup` in old R release platform.
* Fixed bugs caused by `h5Backup` in old R release platform.
* Fixed bugs caused by not using `tempfile` in examples.

## Improvement
Expand Down
35 changes: 19 additions & 16 deletions R/hdf5-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#' @export
h5AbsLinkName <- function(name) {
name <- name[1]
name <- gsub(pattern = "\\/*$", replacement = "", x = name)
if (!any(isValidCharacters(x = name))) {
name <- ""
}
Expand Down Expand Up @@ -136,7 +137,7 @@ h5TryOpen <- function(
if (!do.retry) {
stop(e)
}
message("Keep retrying per minute with 'timeout' set to ", timeout, " s")
message("Keep retrying per minute with 'timeout': ", timeout, " s")
time <- 0
while(time < timeout) {
Sys.sleep(time = interval)
Expand All @@ -149,7 +150,10 @@ h5TryOpen <- function(
}
time <- time + interval
}
stop("Reach a timeout after ", time, " s. Cannot open '", filename, "'")
stop(
"Reach a timeout after ", time, " s. ",
"Cannot open '", filename, "': \n", e
)
}
))
}
Expand Down Expand Up @@ -359,13 +363,13 @@ h5Move <- function(
h5fh <- h5TryOpen(filename = file, mode = "r+")
on.exit(expr = h5fh$close())
if (!h5Exists(x = h5fh, name = from.name)) {
stop("Cannot move a non-existing object: ", from.name)
stop("Source object doesn't exist: ", from.name)
}
if (h5Exists(x = h5fh, name = to.name)) {
if (!overwrite) {
warning(
"Destination object already exists. ",
"Set 'overwrite = TRUE' to remove it.",
"Destination object already exists: ", to.name,
"\nSet 'overwrite = TRUE' to remove it.",
immediate. = TRUE
)
return(invisible(x = NULL))
Expand All @@ -375,8 +379,8 @@ h5Move <- function(
}
h5fh$link_delete(name = to.name)
}
h5CreateGroup(
x = h5fh,
.h5group_create_group(
h5group = h5fh,
name = dirname(path = to.name),
show.warnings = FALSE
)
Expand Down Expand Up @@ -441,10 +445,10 @@ h5Backup <- function(
)
}
if (identical(x = from.file, y = to.file)) {
stop("\n The source file and the target file are identical.")
stop("\nThe source file and the target file are identical.")
}
if (!overwrite && file.exists(to.file)) {
stop("The destination file exists, please set 'overwrite = TRUE'")
stop("\nThe destination file exists, please set 'overwrite = TRUE'")
}
h5fh <- h5TryOpen(filename = from.file, mode = "r")
all_links <- h5List(
Expand All @@ -463,7 +467,7 @@ h5Backup <- function(
file.copy(from = from.file, to = to.file, overwrite = TRUE)
return(to.file)
}
on.exit(expr = h5fh$close())
on.exit(expr = h5fh$close(), add = TRUE)
all_links <- all_links[all_links$name %in% keep_links, , drop = FALSE]

to.h5fh <- h5TryOpen(filename = to.file, mode = "w")
Expand Down Expand Up @@ -558,7 +562,7 @@ h5Overwrite <- function(file, name, overwrite) {
immediate. = TRUE
)
h5fh <- h5TryOpen(filename = file, mode = "w")
on.exit(expr = h5fh$close())
h5fh$close()
return(file)
}
if (!h5Exists(x = file, name = name)) {
Expand All @@ -578,20 +582,19 @@ h5Overwrite <- function(file, name, overwrite) {
"\n File: ", file,
"\n Object: ", name
)
file.rename(from = file, to = tmp.file)
tryCatch(
expr = {
h5Backup(
from.file = tmp.file,
to.file = file,
from.file = file,
to.file = tmp.file,
exclude = name,
overwrite = TRUE,
verbose = FALSE
)
unlink(x = tmp.file)
file.rename(from = tmp.file, to = file)
},
error = function(e) {
file.rename(from = tmp.file, to = file)
unlink(x = tmp.file)
stop(e)
}
)
Expand Down

0 comments on commit c9f75fa

Please sign in to comment.