Skip to content

Commit 8b3d15b

Browse files
committed
compat with v1.0
1 parent 00bb922 commit 8b3d15b

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/OpenML.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ using JSON
55
import ARFFFiles
66
import ScientificTypes: Continuous, Count, Textual, Multiclass, coerce, autotype
77
using Markdown
8-
using Pkg.Artifacts
8+
if VERSION > v"1.3.0"
9+
using Pkg.Artifacts
10+
end
911

1012
export OpenML
1113

src/data.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,24 @@ df = DataFrame(table);
5454
```
5555
"""
5656
function load(id::Int; parser = :arff)
57-
dir = first(Artifacts.artifacts_dirs())
58-
toml = joinpath(dir, "OpenMLArtifacts.toml")
59-
hash = artifact_hash(string(id), toml)
60-
if hash === nothing || !artifact_exists(hash)
61-
hash = Artifacts.create_artifact() do artifact_dir
62-
url = load_Dataset_Description(id)["data_set_description"]["url"]
63-
download(url, joinpath(artifact_dir, "$id.arff"))
57+
if VERSION > v"1.3.0"
58+
dir = first(Artifacts.artifacts_dirs())
59+
toml = joinpath(dir, "OpenMLArtifacts.toml")
60+
hash = artifact_hash(string(id), toml)
61+
if hash === nothing || !artifact_exists(hash)
62+
hash = Artifacts.create_artifact() do artifact_dir
63+
url = load_Dataset_Description(id)["data_set_description"]["url"]
64+
download(url, joinpath(artifact_dir, "$id.arff"))
65+
end
66+
bind_artifact!(toml, string(id), hash)
6467
end
65-
bind_artifact!(toml, string(id), hash)
68+
filename = joinpath(artifact_path(hash), "$id.arff")
69+
else
70+
url = load_Dataset_Description(id)["data_set_description"]["url"]
71+
filename = tempname()
72+
download(url, filename)
6673
end
67-
data = ARFFFiles.load(joinpath(artifact_path(hash), "$id.arff"))
74+
data = ARFFFiles.load(filename)
6875
if parser == :auto
6976
return coerce(data, autotype(data))
7077
else

test/data.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using Test
44
using HTTP
55
using OpenML
66
import Tables.istable
7-
using Pkg.Artifacts
87

98
response_test = OpenML.load_Dataset_Description(61)
109
ntp_test = OpenML.load(61)
@@ -41,13 +40,15 @@ end
4140
@test length(filters_test["data"]["dataset"][1]) == offset
4241
end
4342

44-
@testset "artifacts" begin
45-
dir = first(Artifacts.artifacts_dirs())
46-
toml = joinpath(dir, "OpenMLArtifacts.toml")
47-
hash = artifact_hash("61", toml)
48-
@test artifact_exists(hash)
43+
if VERSION > v"1.3.0"
44+
using Pkg.Artifacts
45+
@testset "artifacts" begin
46+
dir = first(Artifacts.artifacts_dirs())
47+
toml = joinpath(dir, "OpenMLArtifacts.toml")
48+
hash = artifact_hash("61", toml)
49+
@test artifact_exists(hash)
50+
end
4951
end
5052

51-
5253
end
5354
true

0 commit comments

Comments
 (0)