Skip to content

Commit

Permalink
add progress bar to db() update
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmorgan committed Sep 10, 2024
1 parent 525c4aa commit 1526e3b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cellxgenedp
Title: Discover and Access Single Cell Data Sets in the CELLxGENE Data Portal
Version: 1.9.0
Version: 1.9.1
Authors@R:
c(person(
given = "Martin",
Expand All @@ -21,7 +21,7 @@ Encoding: UTF-8
Collate: db.R collections.R datasets.R files.R facets.R keys.R
cellxgene.R utilities.R publisher_metadata.R cxg.R
Depends: dplyr
Imports: httr, curl, utils, tools, shiny, DT, rjsoncons
Imports: httr, curl, utils, tools, cli, shiny, DT, rjsoncons
Suggests:
zellkonverter,
SingleCellExperiment,
Expand All @@ -36,6 +36,6 @@ biocViews: SingleCell, DataImport, ThirdPartyClient
URL: https://mtmorgan.github.io/cellxgenedp/, https://github.com/mtmorgan/cellxgenedp
BugReports: https://github.com/mtmorgan/cellxgenedp/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
VignetteBuilder: knitr
Config/testthat/edition: 3
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export(publisher_metadata)
importFrom(DT,datatable)
importFrom(DT,formatStyle)
importFrom(DT,renderDataTable)
importFrom(cli,cli_progress_bar)
importFrom(cli,cli_progress_done)
importFrom(cli,cli_progress_update)
importFrom(curl,nslookup)
importFrom(dplyr,.data)
importFrom(dplyr,across)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# cellxgenedp 1.10

SIGNIFICANT USER-VISIBLE CHANGES

* (v.1.9.1) Add progress bar when updated `db()`

# cellxgenedp 1.8

SIGNIFICANT USER-VISIBLE CHANGES
Expand Down
26 changes: 18 additions & 8 deletions R/db.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@
bind_rows()
}

#' @importFrom cli cli_progress_bar cli_progress_update
#' cli_progress_done
.db_detail <-
function(id, overwrite)
function(collection_id, overwrite)
{
## be sure to return a result & check for errors
tryCatch({
uri <- paste0(.COLLECTIONS, id)
path <- .cellxgene_cache_get(uri, overwrite = overwrite)
readLines(path)
}, error = identity)
n_collections <- length(collection_id)
result <- vector("list", n_collections)
cli_progress_bar("Collections", total = n_collections)
for (i in seq_len(n_collections)) {
## be sure to return a result & check for errors
result[[i]] <- tryCatch({
uri <- paste0(.COLLECTIONS, collection_id[[i]])
path <- .cellxgene_cache_get(uri, overwrite = overwrite)
readLines(path)
}, error = identity)
cli_progress_update()
}
cli_progress_done()
result
}

.db_first <- local({
Expand Down Expand Up @@ -81,7 +91,7 @@ db <-
if (overwrite)
message("updating database and collections...")
db <- .db(overwrite)
details <- lapply(db$collection_id, .db_detail, overwrite = overwrite)
details <- .db_detail(db$collection_id, overwrite)
errors <- vapply(details, inherits, logical(1), "error")
if (any(errors)) {
stop(
Expand Down

0 comments on commit 1526e3b

Please sign in to comment.