Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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).

## Unreleased

### Fixed

* The `JuliaHub.update_dataset` function now correctly accepts the `license=(:fulltext, ...)` argument. ([#74])

## Version [v0.1.11] - 2024-06-27

### Added
Expand Down Expand Up @@ -134,3 +140,4 @@ Initial package release.
[#52]: https://github.com/JuliaComputing/JuliaHub.jl/issues/52
[#53]: https://github.com/JuliaComputing/JuliaHub.jl/issues/53
[#58]: https://github.com/JuliaComputing/JuliaHub.jl/issues/58
[#74]: https://github.com/JuliaComputing/JuliaHub.jl/issues/74
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaHub"
uuid = "bc7fa6ce-b75e-4d60-89ad-56c957190b6e"
authors = ["JuliaHub Inc."]
version = "0.1.11"
version = "0.1.12-DEV"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
19 changes: 16 additions & 3 deletions src/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,15 @@ const _DOCS_datasets_metadata_fields = """
* `description`: description of the dataset (a string)
* `tags`: an iterable of strings of all the tags of the dataset
* `visibility`: a string with possible values `public` or `private`
* `license`: a valid SPDX license identifier, or a tuple `(:fulltext, license_text)`, where
`license_text` is the full text string of a custom license
* `license`: a valid SPDX license identifier (as a string or in a
`(:spdx, licence_identifier)` tuple), or a tuple `(:fulltext, license_text)`,
where `license_text` is the full text string of a custom license
* `groups`: an iterable of valid group names

!!! compat "JuliaHub.jl v0.1.12"

The `license = (:fulltext, ...)` form requires v0.1.12, and `license = (:text, ...)`
is deprecated since that version.
"""

"""
Expand Down Expand Up @@ -983,7 +989,14 @@ function update_dataset end
cmd, license_value = license
params["license"] = if cmd == :spdx
Dict("spdx_id" => license_value)
elseif cmd == :text
elseif cmd in (:fulltext, :text)
if cmd == :text
Base.depwarn(
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
:update_dataset;
force=true,
)
end
Dict("text" => license_value)
else
throw(ArgumentError("Invalid license argument: $(cmd) ∉ [:spdx, :text]"))
Expand Down
45 changes: 45 additions & 0 deletions test/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ end
@test_throws TypeError JuliaHub.update_dataset(
"example-dataset"; description=42
)
# Different options for `license` keyword
@test JuliaHub.update_dataset("example-dataset"; license="MIT") isa JuliaHub.Dataset
@test JuliaHub.update_dataset("example-dataset"; license=(:spdx, "MIT")) isa
JuliaHub.Dataset
@test JuliaHub.update_dataset("example-dataset"; license=(:fulltext, "...")) isa
JuliaHub.Dataset
# This should log a deprecation warning
@test @test_logs (
:warn,
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
) JuliaHub.update_dataset(
"example-dataset"; license=(:text, "...")
) isa JuliaHub.Dataset
@test_throws TypeError JuliaHub.update_dataset("example-dataset"; license=1234)
@test_throws ArgumentError JuliaHub.update_dataset("example-dataset"; license=(:foo, ""))
@test_throws TypeError JuliaHub.update_dataset(
"example-dataset"; license=(:fulltext, 1234)
)
end
end

Expand Down Expand Up @@ -293,6 +311,33 @@ end

# @test JuliaHub.upload_dataset(
# "existing-dataset", @__FILE__; update=true) isa JuliaHub.Dataset

# Different options for `license` keyword
@test JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; create=true, license="MIT"
) isa JuliaHub.Dataset
@test JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=(:spdx, "MIT")
) isa JuliaHub.Dataset
@test JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=(:fulltext, "...")
) isa JuliaHub.Dataset
# This should log a deprecation warning
@test @test_logs (
:warn,
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
) JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=(:text, "...")
) isa JuliaHub.Dataset
@test_throws TypeError JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=1234
)
@test_throws ArgumentError JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=(:foo, "")
)
@test_throws TypeError JuliaHub.upload_dataset(
"example-dataset-license", @__FILE__; replace=true, license=(:fulltext, 1234)
)
end
empty!(MOCK_JULIAHUB_STATE)
end
Loading