Skip to content

Commit 0ac3c4c

Browse files
authored
Merge pull request #157 from bluegreen-labs/patch-file-format
Patch file format inconsistencies
2 parents 805226f + 8f20247 commit 0ac3c4c

6 files changed

+46
-13
lines changed

DESCRIPTION

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ecmwfr
22
Title: Interface to 'ECMWF' and 'CDS' Data Web Services
3-
Version: 2.0.4
3+
Version: 2.0.3
44
Authors@R: c(person(
55
family = "Hufkens",
66
given = "Koen",
@@ -39,7 +39,8 @@ Imports:
3939
memoise,
4040
getPass,
4141
R6,
42-
keyring
42+
keyring,
43+
tools
4344
License: AGPL-3
4445
ByteCompile: true
4546
RoxygenNote: 7.3.1

NEWS.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# ecmwfr 2.0.4
1+
# ecmwfr 2.0.3
22

33
* fix of Addin conversion issue (edge case)
44
* documentation corrections by @Rafnuss
5-
6-
# ecmwfr 2.0.3
7-
85
* fix of feedback on failed downloads
96

107
# ecmwfr 2.0.2

R/service-ds.R

+33-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ ds_service <- R6::R6Class("ecmwfr_ds",
156156
) {
157157

158158
# Check if download is actually needed
159-
if (private$downloaded == TRUE & file.exists(private$file) & !force_redownload) {
159+
if (private$downloaded == TRUE & !force_redownload) {
160160
if (private$verbose) message("File already downloaded")
161161
return(self)
162162
}
@@ -191,8 +191,40 @@ ds_service <- R6::R6Class("ecmwfr_ds",
191191
)
192192
}
193193

194+
# flag as downloaded
194195
private$downloaded <- TRUE
195196

197+
# no target file provided
198+
# use temp file name (assignment
199+
# of extension see below)
200+
if(length(private$file) == 0){
201+
private$file <- temp_file
202+
}
203+
204+
# check extension
205+
if(tools::file_ext(private$file_url) != tools::file_ext(private$file)){
206+
207+
# list old and new name
208+
old_file <- private$file
209+
new_file <- paste0(
210+
tools::file_path_sans_ext(private$file),".",
211+
tools::file_ext(private$file_url)
212+
)
213+
214+
# assign to internal variable
215+
private$file <- new_file
216+
217+
# provide feedback
218+
if (private$verbose){
219+
message(
220+
sprintf(
221+
"- renaming output format -> %s to %s",
222+
old_file, new_file
223+
)
224+
)
225+
}
226+
}
227+
196228
# Copy data from temporary file to final location
197229
move <- suppressWarnings(file.rename(temp_file, private$file))
198230

R/wf_request.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' used to retrieve the token set by \code{\link[ecmwfr]{wf_set_key}}
1313
#' @param path path were to store the downloaded data
1414
#' @param time_out how long to wait on a download to start (default =
15-
#' \code{3*3600} seconds).
15+
#' \code{3600} seconds).
1616
#' @param retry polling frequency of submitted request for downloading (default =
1717
#' \code{30} seconds).
1818
#' @param transfer logical, download data TRUE or FALSE (default = TRUE)

cran-comments.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
## New release v2.0.4
1+
## New release v2.0.3
22

33
Dear CRAN team,
44

55
This small update fixes an edge case in the RStudio Addin for conversion
66
of ECMWF python to R queries. Mention of the keyword `dataset` was filtered
77
properly only to select the first instance, not allowing multiple selections
8-
which as cause for an error. No further changes were made.
8+
which as cause for an error. In addition, the CDS API now returns zip or
9+
netCDF/grib files depending on the requested data. To address this dynamic
10+
naming the requested file name is now renamed automatically if not matching the
11+
extension on the download url. A small typo in the documentation is also fixed.
912

1013
Stats on code coverage and test routines remain the same as per previous
11-
v2.0.3 release.
14+
v2.0.2 release.
1215

1316
Kind regards,
1417
Koen Hufkens
@@ -18,7 +21,7 @@ http://cran.r-project.org/web/packages/policies.html
1821

1922
## test environments, local, CI and r-hub
2023

21-
- local Ubuntu 22.04 install on R 4.4.1
24+
- local Ubuntu 22.04 install on R 4.4.2
2225
- Ubuntu 22.04 on github actions (devel / release / macos / windows)
2326
- codecove.io code coverage at ~70%
2427

man/wf_request.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)