Skip to content

Commit cab107b

Browse files
authored
Merge pull request #22 from JuliaAI/dev
For a 0.3.2 release
2 parents 738790c + 59bdb42 commit cab107b

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
julia-version:
18-
- "1.0"
18+
- "1.6"
1919
- "1"
2020
- "nightly"
2121
os:

Project.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
name = "OpenML"
22
uuid = "8b6db2d4-7670-4922-a472-f9537c81ab66"
33
authors = ["Diego Arenas <[email protected]>", "Anthony D. Blaom <[email protected]>"]
4-
version = "0.3.0"
4+
version = "0.3.2"
55

66
[deps]
77
ARFFFiles = "da404889-ca92-49ff-9e8b-0aa6b4d38dc8"
88
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
99
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1010
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1111
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
12+
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1213

1314
[compat]
1415
ARFFFiles = "1.4.1"
15-
HTTP = "0.8, 0.9,1"
16+
HTTP = "0.8, 0.9, 1"
1617
JSON = "0.21"
17-
julia = "1"
18+
julia = "1.6"
1819

1920
[extras]
2021
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
2122
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
23+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2224

2325
[targets]
24-
test = ["Tables", "Test"]
26+
test = ["Tables", "Test", "Logging"]

src/OpenML.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ using HTTP
44
using JSON
55
import ARFFFiles
66
using Markdown
7-
if VERSION > v"1.3.0"
8-
using Pkg.Artifacts
9-
end
7+
using Scratch
108

119
export OpenML
1210

11+
download_cache = ""
12+
1313
include("data.jl")
1414

15+
function __init__()
16+
global download_cache = @get_scratch!("datasets")
17+
end
18+
1519
end # module

src/data.jl

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,12 @@ peek_table = OpenML.load(61, maxbytes = 1024) # load only the first 1024 bytes o
6767
```
6868
"""
6969
function load(id::Int; maxbytes = nothing)
70-
if VERSION > v"1.3.0"
71-
dir = first(Artifacts.artifacts_dirs())
72-
toml = joinpath(dir, "OpenMLArtifacts.toml")
73-
hash = artifact_hash(string(id), toml)
74-
if hash === nothing || !artifact_exists(hash)
75-
hash = Artifacts.create_artifact() do artifact_dir
76-
url = load_Dataset_Description(id)["data_set_description"]["url"]
77-
download(url, joinpath(artifact_dir, "$id.arff"))
78-
end
79-
bind_artifact!(toml, string(id), hash)
80-
end
81-
filename = joinpath(artifact_path(hash), "$id.arff")
82-
else
83-
url = load_Dataset_Description(id)["data_set_description"]["url"]
84-
filename = tempname()
85-
download(url, filename)
70+
fname = joinpath(download_cache, "$id.arff")
71+
if !isfile(fname)
72+
@info "Downloading dataset $id."
73+
download(load_Dataset_Description(id)["data_set_description"]["url"], fname)
8674
end
87-
ARFFFiles.load(x -> ARFFFiles.readcolumns(x; maxbytes = maxbytes), filename)
75+
ARFFFiles.load(x -> ARFFFiles.readcolumns(x; maxbytes = maxbytes), fname)
8876
end
8977

9078

test/data.jl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,22 @@ end
4040
@test length(filters_test["data"]["dataset"][1]) == offset
4141
end
4242

43-
if VERSION > v"1.3.0"
44-
using Pkg
45-
@testset "artifacts" begin
46-
dir = first(Pkg.Artifacts.artifacts_dirs())
47-
toml = joinpath(dir, "OpenMLArtifacts.toml")
48-
hash = Pkg.Artifacts.artifact_hash("61", toml)
49-
@test Pkg.Artifacts.artifact_exists(hash)
43+
@testset "scratch" begin
44+
OpenML.load(61)
45+
fname = joinpath(OpenML.download_cache, "61.arff")
46+
@test isfile(fname)
47+
using Logging
48+
io = IOBuffer()
49+
logger = SimpleLogger(io)
50+
with_logger(logger) do
51+
OpenML.load(61)
5052
end
53+
@test match(r"Downloading dataset 61", String(take!(io))) === nothing
54+
rm(fname)
55+
with_logger(logger) do
56+
OpenML.load(61)
57+
end
58+
@test match(r"Downloading dataset 61", String(take!(io))) !== nothing
5159
end
5260

5361
end
54-
true

0 commit comments

Comments
 (0)