Spaces:
Sleeping
Sleeping
Update download_data.R
Browse files- download_data.R +11 -11
download_data.R
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
library(httr)
|
| 2 |
|
| 3 |
token <- Sys.getenv("HF_TOKEN")
|
| 4 |
-
repo <- "BU-Baseball/
|
| 5 |
base_url <- paste0("https://huggingface.co/datasets/", repo, "/resolve/main/")
|
| 6 |
|
| 7 |
-
download_hf <- function(filename) {
|
| 8 |
-
dest
|
|
|
|
|
|
|
| 9 |
if (file.exists(dest)) {
|
| 10 |
message(filename, " already exists, skipping.")
|
| 11 |
return(invisible(NULL))
|
| 12 |
}
|
| 13 |
message("Downloading ", filename, "...")
|
| 14 |
resp <- GET(
|
| 15 |
-
paste0(base_url,
|
| 16 |
add_headers(Authorization = paste("Bearer", token)),
|
| 17 |
write_disk(dest, overwrite = TRUE),
|
| 18 |
progress()
|
|
@@ -22,12 +24,10 @@ download_hf <- function(filename) {
|
|
| 22 |
message(filename, " done.")
|
| 23 |
}
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
)
|
| 31 |
|
| 32 |
-
for (f in files) download_hf(f)
|
| 33 |
message("All model files ready.")
|
|
|
|
| 1 |
library(httr)
|
| 2 |
|
| 3 |
token <- Sys.getenv("HF_TOKEN")
|
| 4 |
+
repo <- "BU-Baseball/BU-Baseball-Data"
|
| 5 |
base_url <- paste0("https://huggingface.co/datasets/", repo, "/resolve/main/")
|
| 6 |
|
| 7 |
+
download_hf <- function(filename, url_filename = NULL) {
|
| 8 |
+
dest <- paste0("/app/", filename)
|
| 9 |
+
url_filename <- if (is.null(url_filename)) filename else url_filename
|
| 10 |
+
|
| 11 |
if (file.exists(dest)) {
|
| 12 |
message(filename, " already exists, skipping.")
|
| 13 |
return(invisible(NULL))
|
| 14 |
}
|
| 15 |
message("Downloading ", filename, "...")
|
| 16 |
resp <- GET(
|
| 17 |
+
paste0(base_url, url_filename),
|
| 18 |
add_headers(Authorization = paste("Bearer", token)),
|
| 19 |
write_disk(dest, overwrite = TRUE),
|
| 20 |
progress()
|
|
|
|
| 24 |
message(filename, " done.")
|
| 25 |
}
|
| 26 |
|
| 27 |
+
# Stuff+2.rds is encoded as Stuff%2B2.rds in the URL
|
| 28 |
+
download_hf("Stuff+2.rds", "Stuff%2B2.rds")
|
| 29 |
+
download_hf("NEW_LeagueStats2.rds")
|
| 30 |
+
download_hf("location_plus_model.rds")
|
| 31 |
+
download_hf("location_plus_league_stats_pitcher.rds")
|
|
|
|
| 32 |
|
|
|
|
| 33 |
message("All model files ready.")
|