Skip to content

Commit 31fcb9b

Browse files
mortenpipfitzseb
andauthored
fix: correctly allow for license=(:fulltext, ...) in update_dataset (#74)
* fix: correctly allow for license=(:fulltext, ...) in update_dataset * update changelog * add deprecation note to docstring * set -DEV version for now * Update src/datasets.jl Co-authored-by: Sebastian Pfitzner <[email protected]> --------- Co-authored-by: Sebastian Pfitzner <[email protected]>
1 parent 0d142ec commit 31fcb9b

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

CHANGELOG.md

Lines changed: 7 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+
## Unreleased
6+
7+
### Fixed
8+
9+
* The `JuliaHub.update_dataset` function now correctly accepts the `license=(:fulltext, ...)` argument. ([#74])
10+
511
## Version [v0.1.11] - 2024-06-27
612

713
### Added
@@ -134,3 +140,4 @@ Initial package release.
134140
[#52]: https://github.com/JuliaComputing/JuliaHub.jl/issues/52
135141
[#53]: https://github.com/JuliaComputing/JuliaHub.jl/issues/53
136142
[#58]: https://github.com/JuliaComputing/JuliaHub.jl/issues/58
143+
[#74]: https://github.com/JuliaComputing/JuliaHub.jl/issues/74

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.11"
4+
version = "0.1.12-DEV"
55

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

src/datasets.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,15 @@ const _DOCS_datasets_metadata_fields = """
465465
* `description`: description of the dataset (a string)
466466
* `tags`: an iterable of strings of all the tags of the dataset
467467
* `visibility`: a string with possible values `public` or `private`
468-
* `license`: a valid SPDX license identifier, or a tuple `(:fulltext, license_text)`, where
469-
`license_text` is the full text string of a custom license
468+
* `license`: a valid SPDX license identifier (as a string or in a
469+
`(:spdx, licence_identifier)` tuple), or a tuple `(:fulltext, license_text)`,
470+
where `license_text` is the full text string of a custom license
470471
* `groups`: an iterable of valid group names
472+
473+
!!! compat "JuliaHub.jl v0.1.12"
474+
475+
The `license = (:fulltext, ...)` form requires v0.1.12, and `license = (:text, ...)`
476+
is deprecated since that version.
471477
"""
472478

473479
"""
@@ -983,7 +989,14 @@ function update_dataset end
983989
cmd, license_value = license
984990
params["license"] = if cmd == :spdx
985991
Dict("spdx_id" => license_value)
986-
elseif cmd == :text
992+
elseif cmd in (:fulltext, :text)
993+
if cmd == :text
994+
Base.depwarn(
995+
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
996+
:update_dataset;
997+
force=true,
998+
)
999+
end
9871000
Dict("text" => license_value)
9881001
else
9891002
throw(ArgumentError("Invalid license argument: $(cmd) ∉ [:spdx, :text]"))

test/datasets.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,24 @@ end
237237
@test_throws TypeError JuliaHub.update_dataset(
238238
"example-dataset"; description=42
239239
)
240+
# Different options for `license` keyword
241+
@test JuliaHub.update_dataset("example-dataset"; license="MIT") isa JuliaHub.Dataset
242+
@test JuliaHub.update_dataset("example-dataset"; license=(:spdx, "MIT")) isa
243+
JuliaHub.Dataset
244+
@test JuliaHub.update_dataset("example-dataset"; license=(:fulltext, "...")) isa
245+
JuliaHub.Dataset
246+
# This should log a deprecation warning
247+
@test @test_logs (
248+
:warn,
249+
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
250+
) JuliaHub.update_dataset(
251+
"example-dataset"; license=(:text, "...")
252+
) isa JuliaHub.Dataset
253+
@test_throws TypeError JuliaHub.update_dataset("example-dataset"; license=1234)
254+
@test_throws ArgumentError JuliaHub.update_dataset("example-dataset"; license=(:foo, ""))
255+
@test_throws TypeError JuliaHub.update_dataset(
256+
"example-dataset"; license=(:fulltext, 1234)
257+
)
240258
end
241259
end
242260

@@ -293,6 +311,33 @@ end
293311

294312
# @test JuliaHub.upload_dataset(
295313
# "existing-dataset", @__FILE__; update=true) isa JuliaHub.Dataset
314+
315+
# Different options for `license` keyword
316+
@test JuliaHub.upload_dataset(
317+
"example-dataset-license", @__FILE__; create=true, license="MIT"
318+
) isa JuliaHub.Dataset
319+
@test JuliaHub.upload_dataset(
320+
"example-dataset-license", @__FILE__; replace=true, license=(:spdx, "MIT")
321+
) isa JuliaHub.Dataset
322+
@test JuliaHub.upload_dataset(
323+
"example-dataset-license", @__FILE__; replace=true, license=(:fulltext, "...")
324+
) isa JuliaHub.Dataset
325+
# This should log a deprecation warning
326+
@test @test_logs (
327+
:warn,
328+
"Passing license=(:text, ...) is deprecated, use license=(:fulltext, ...) instead.",
329+
) JuliaHub.upload_dataset(
330+
"example-dataset-license", @__FILE__; replace=true, license=(:text, "...")
331+
) isa JuliaHub.Dataset
332+
@test_throws TypeError JuliaHub.upload_dataset(
333+
"example-dataset-license", @__FILE__; replace=true, license=1234
334+
)
335+
@test_throws ArgumentError JuliaHub.upload_dataset(
336+
"example-dataset-license", @__FILE__; replace=true, license=(:foo, "")
337+
)
338+
@test_throws TypeError JuliaHub.upload_dataset(
339+
"example-dataset-license", @__FILE__; replace=true, license=(:fulltext, 1234)
340+
)
296341
end
297342
empty!(MOCK_JULIAHUB_STATE)
298343
end

0 commit comments

Comments
 (0)