Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for file download #41

Merged
merged 4 commits into from
Sep 29, 2019
Merged

Conversation

eliocamp
Copy link
Collaborator

@eliocamp eliocamp commented Sep 6, 2019

Checks if data is ready without downloading the entire file and only when it is, it downloads directly to disk. (Closes #39)

The result is:

library(ecmwfr)
request <- list(stream = "oper",
                levtype = "sfc",
                param = "167.128",
                dataset = "interim",
                step = "0",
                grid = "0.75/0.75",
                time = "00",
                date = "2014-07-01/to/2014-07-02",
                type = "an",
                class = "ei",
                area = "50/10/51/11",
                format = "netcdf",
                target = "tmp.nc")

wf_request(request = request)

#> Requesting data to the webapi service with username eliocampitelli@gmail.com
#> - staging data transfer at url endpoint or request id:
#>   https://api.ecmwf.int/v1/datasets/interim/requests/5d72a1f713e01cd44c6f4858
#> 
#> - timeout set to 1.0 hours
#> - polling server for a data transfer
#> Downloading file
#> |=================================================================================================| 100%
#> - file not copied and removed (path == tempdir())
#> - request purged from queue!

This uses the somewhat hacky function retrieve_header. If curl or httr decide to implement the --head argument, then it could be changed to a cleaner solution.

@khufkens khufkens merged commit 13d466a into bluegreen-labs:master Sep 29, 2019
@khufkens
Copy link
Member

CI failed in branch, image didn't compile nicely. Will see if it works in master.

@eliocamp eliocamp mentioned this pull request Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notify when download starts
2 participants