Skip to content

Commit

Permalink
disable multiplex in another function for CTIS
Browse files Browse the repository at this point in the history
  • Loading branch information
rfhb committed Aug 28, 2024
1 parent 79a78be commit 30d3b7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
3 changes: 0 additions & 3 deletions R/ctrLoadQueryIntoDbCtgov2.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ ctrLoadQueryIntoDbCtgov2 <- function(
tmp <- ctrMultiDownload(
urlToDownload,
fTrialJson,
progress = TRUE,
verbose = verbose)

# inform user
Expand Down Expand Up @@ -362,7 +361,6 @@ ctrLoadQueryIntoDbCtgov2 <- function(
tmp <- ctrMultiDownload(
urls = urls,
destfiles = files,
resume = FALSE,
verbose = verbose
)

Expand Down Expand Up @@ -456,7 +454,6 @@ ctrLoadQueryIntoDbCtgov2 <- function(
tmp <- ctrMultiDownload(
urls = urls,
destfiles = files,
resume = FALSE,
verbose = verbose
)

Expand Down
22 changes: 8 additions & 14 deletions R/ctrLoadQueryIntoDbCtis.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ ctrLoadQueryIntoDbCtis <- function(
## create empty temporary directory
tempDir <- ctrTempDir(verbose)

## output mangle helper -----------------------------------------------

mangleText <- function(t) {

stringi::stri_replace_all_fixed(str = t, pattern = "'", replacement = "&apos;")

}

## ctis api -----------------------------------------------------------

# https://euclinicaltrials.eu/ctis-public/assets/i18n/en.json
Expand All @@ -54,18 +46,18 @@ ctrLoadQueryIntoDbCtis <- function(
# - 1 trial overview - post method
"/search",
#
# - 2 trial information - %s is ctNumber
"/retrieve/%s", # partI and partsII
# - 2 trial information, partI and partsII
"/retrieve/%s", # %s is ctNumber
#
# - 3 download files
"/documents/%s/%s/download" # trial _id, document[].uuid
"/documents/%s/%s/download" # %s are trial _id, document[].uuid
#
)
)

## api_1: overviews ---------------------------------------------------------

# this is for importing overview (recruitment, status etc.) into database
# for importing overview (recruitment, status etc.) into database
message("* Checking trials in CTIS...")

# "HTTP server doesn't seem to support byte ranges. Cannot resume."
Expand Down Expand Up @@ -218,7 +210,7 @@ ctrLoadQueryIntoDbCtis <- function(
# this is imported as the main data into the database

message("(2/4) Downloading and processing trial data... (",
"estimate: ", signif(length(idsTrials) * 376 / 5117, 1L), " Mb)")
"estimate: ", signif(length(idsTrials) * 405 / 5505, 1L), " Mb)")

urls <- sprintf(ctisEndpoints[2], idsTrials)

Expand All @@ -227,7 +219,9 @@ ctrLoadQueryIntoDbCtis <- function(
}

# "HTTP server doesn't seem to support byte ranges. Cannot resume."
tmp <- ctrMultiDownload(urls, fPartIPartsIIJson(idsTrials), verbose = verbose)
tmp <- ctrMultiDownload(
urls, fPartIPartsIIJson(idsTrials),
multiplex = FALSE, verbose = verbose)

# convert partI and partsII details into ndjson file(s),
# each approximately 10MB for nRecords = 100L
Expand Down
5 changes: 3 additions & 2 deletions R/util_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ ctrMultiDownload <- function(
destfiles,
progress = TRUE,
resume = FALSE,
multiplex = TRUE,
verbose = TRUE) {

stopifnot(length(urls) == length(destfiles))
Expand Down Expand Up @@ -844,7 +845,7 @@ ctrMultiDownload <- function(
# remove any duplicates
downloadValue <- unique(downloadValue)

# does not error in case any of the individual requests fail
# does not error in case any of the individual requests fail.
# inspect the return value to find out which were successful
# make no more than 3 attempts to complete downloading
while (any(toDo) && numI < 3L) {
Expand All @@ -855,7 +856,7 @@ ctrMultiDownload <- function(
resume = canR,
progress = progress,
timeout = Inf,
multiplex = TRUE,
multiplex = multiplex,
c(getOption("httr_config")[["options"]],
accept_encoding = "gzip,deflate,zstd,br")
)
Expand Down

0 comments on commit 30d3b7d

Please sign in to comment.