Skip to content

Commit 6799ba1

Browse files
pfitzsebmortenpi
andauthored
feat: add progress kwarg for upload_dataset (#48)
* feat: add progress kwarg for upload_dataset progress=false disables rclone's progress printing * Update Project.toml * Update CHANGELOG.md * Update src/datasets.jl Co-authored-by: Morten Piibeleht <[email protected]> * update docstring --------- Co-authored-by: Morten Piibeleht <[email protected]>
1 parent 129d1c5 commit 6799ba1

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## Version v0.1.8 - 2024-02-21
6+
7+
### Added
8+
9+
* The progress output printing in `JuliaHub.upload_dataset` can now be disabled by setting `progress=false`. (#48)
10+
511
## Version v0.1.7 - 2024-01-22
612

713
### Fixed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "JuliaHub"
22
uuid = "bc7fa6ce-b75e-4d60-89ad-56c957190b6e"
33
authors = ["JuliaHub Inc."]
4-
version = "0.1.7"
4+
version = "0.1.8"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/datasets.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ If a dataset already exists, then these fields are updated as if [`update_datase
495495
496496
The function will throw an `ArgumentError` for invalid argument combinations.
497497
498+
Use the `progress` keyword argument to suppress upload progress from being printed.
499+
498500
!!! note
499501
Presently, it is only possible to upload datasets for the currently authenticated user.
500502
"""
@@ -503,6 +505,7 @@ function upload_dataset end
503505
@_authuser function upload_dataset(
504506
dsref::_DatasetRefTuple,
505507
local_path::AbstractString;
508+
progress::Bool=true,
506509
# Operation type
507510
create::Bool=true,
508511
update::Bool=false,
@@ -604,7 +607,7 @@ function upload_dataset end
604607
end
605608
# Upload the actual data
606609
try
607-
_upload_dataset(upload_config, local_path)
610+
_upload_dataset(upload_config, local_path; progress)
608611
catch e
609612
throw(JuliaHubError("Data upload failed", e, catch_backtrace()))
610613
end
@@ -679,7 +682,7 @@ function _open_dataset_version(name; auth::Authentication=__auth__())::_RESTResp
679682
_restcall(auth, :POST, "user", "datasets", name, "versions")
680683
end
681684

682-
function _upload_dataset(upload_config, local_path)
685+
function _upload_dataset(upload_config, local_path; progress::Bool)
683686
type = upload_config["upload_type"]
684687
vendor = upload_config["vendor"]
685688
if type != "S3" || vendor != "aws"
@@ -704,13 +707,20 @@ function _upload_dataset(upload_config, local_path)
704707
# --s3-upload-cutoff 1M --s3-chunk-size 5M
705708

706709
# FIXME: remove `--s3-no-head` once policies are figured out (again)
710+
args = [
711+
"--s3-no-check-bucket",
712+
"--s3-no-head",
713+
"--no-check-dest",
714+
]
715+
716+
if progress
717+
pushfirst!(args, "--progress")
718+
end
719+
707720
run(```
708721
$rclone_exe copyto $local_path "juliahub_remote:$remote_path"
709722
--config $rclone_conf_path
710-
--progress
711-
--s3-no-check-bucket
712-
--s3-no-head
713-
--no-check-dest
723+
$args
714724
```)
715725
end
716726
end

0 commit comments

Comments
 (0)