Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -1999,29 +1999,19 @@ observeEvent(input$upload_hf_btn, {
|
|
| 1999 |
arrow::write_parquet(combined, tmp)
|
| 2000 |
|
| 2001 |
result <- tryCatch({
|
| 2002 |
-
|
| 2003 |
-
|
| 2004 |
-
|
| 2005 |
-
|
| 2006 |
-
|
| 2007 |
-
|
| 2008 |
-
|
| 2009 |
-
|
| 2010 |
-
|
| 2011 |
-
|
| 2012 |
-
|
| 2013 |
-
|
| 2014 |
-
|
| 2015 |
-
), stdout = TRUE, stderr = TRUE)
|
| 2016 |
-
|
| 2017 |
-
file.remove(header_file)
|
| 2018 |
-
resp_text <- paste(resp, collapse = "\n")
|
| 2019 |
-
|
| 2020 |
-
if (grepl("commitOid", resp_text)) {
|
| 2021 |
-
paste0("Done! ", nrow(combined), " total rows in dataset.")
|
| 2022 |
-
} else {
|
| 2023 |
-
paste0("Upload response: ", resp_text)
|
| 2024 |
-
}
|
| 2025 |
}, error = function(e) {
|
| 2026 |
paste("Upload error:", e$message)
|
| 2027 |
})
|
|
|
|
| 1999 |
arrow::write_parquet(combined, tmp)
|
| 2000 |
|
| 2001 |
result <- tryCatch({
|
| 2002 |
+
library(reticulate)
|
| 2003 |
+
hf <- import("huggingface_hub")
|
| 2004 |
+
api <- hf$HfApi()
|
| 2005 |
+
api$token <- hf_token
|
| 2006 |
+
|
| 2007 |
+
api$upload_file(
|
| 2008 |
+
path_or_fileobj = tmp,
|
| 2009 |
+
path_in_repo = filename,
|
| 2010 |
+
repo_id = repo_id,
|
| 2011 |
+
repo_type = "dataset"
|
| 2012 |
+
)
|
| 2013 |
+
|
| 2014 |
+
paste0("Done! ", nrow(combined), " total rows in dataset.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2015 |
}, error = function(e) {
|
| 2016 |
paste("Upload error:", e$message)
|
| 2017 |
})
|