Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ docs-manifest:
docs: docs/Manifest.toml
${JULIA} --project=docs/ docs/make.jl

fix-doctests: docs/Manifest.toml
${JULIA} --project=docs/ docs/make.jl --fix-doctests

changelog:
${JULIA} --project=docs/ docs/changelog.jl

Expand Down
4 changes: 2 additions & 2 deletions docs/src/guides/datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ When downloading, you can also specify the version you wish to download (with th
```jldoctest example-dataset; filter = r"\"/.+/mydata\""
julia> ds.versions
2-element Vector{JuliaHub.DatasetVersion}:
JuliaHub.DatasetVersion(dataset = ("username", "example-dataset"), version = 1)
JuliaHub.DatasetVersion(dataset = ("username", "example-dataset"), version = 2)
JuliaHub.dataset(("username", "example-dataset")).versions[1]
JuliaHub.dataset(("username", "example-dataset")).versions[2]

julia> ds.versions[1]
DatasetVersion: example-dataset @ v1
Expand Down
31 changes: 21 additions & 10 deletions src/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ Objects have the following properties:
- `.size :: Int`: size of the dataset version in bytes
- `.timestamp :: ZonedDateTime`: dataset version timestamp

```
julia> JuliaHub.datasets()
```jldoctest
julia> dataset = JuliaHub.dataset("example-dataset")
Dataset: example-dataset (Blob)
owner: username
description: An example dataset
versions: 2
size: 388 bytes
tags: tag1, tag2

julia> dataset.versions
2-element Vector{JuliaHub.DatasetVersion}:
JuliaHub.dataset(("username", "example-dataset")).versions[1]
JuliaHub.dataset(("username", "example-dataset")).versions[2]

julia> dataset.versions[end]
DatasetVersion: example-dataset @ v2
owner: username
timestamp: 2022-10-14T01:39:43.237-04:00
size: 331 bytes
```

See also: [`Dataset`](@ref), [`datasets`](@ref), [`dataset`](@ref).
Expand All @@ -52,14 +69,8 @@ end

function Base.show(io::IO, dsv::DatasetVersion)
owner, name = dsv._dsref
print(
io,
"JuliaHub.DatasetVersion(dataset = (\"",
owner,
"\", \"",
name,
"\"), version = $(dsv.id))",
)
dsref = string("(\"", owner, "\", \"", name, "\")")
print(io, "JuliaHub.dataset($dsref).versions[$(dsv.id)]")
end
function Base.show(io::IO, ::MIME"text/plain", dsv::DatasetVersion)
owner, name = dsv._dsref
Expand Down
14 changes: 14 additions & 0 deletions test/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ end
@test ds.versions[2].id == 2
@test ds.versions[2].size == 331

# Test that .versions repr()-s to a valid array
# and DatasetVersion reprs to a valid JuliaHub.dataset().versions[...]
# call.
let versions = eval(Meta.parse(string(ds.versions)))
@test versions isa Vector{JuliaHub.DatasetVersion}
@test length(versions) == 2
@test versions == ds.versions
end
let expr = Meta.parse(string(ds.versions[1]))
@test expr == :((JuliaHub.dataset(("username", "example-dataset"))).versions[1])
version = eval(expr)
@test version == ds.versions[1]
end

ds_updated = JuliaHub.dataset("example-dataset")
@test ds_updated isa JuliaHub.Dataset
@test ds_updated.name == ds.name
Expand Down
Loading