Skip to content

Commit 5245c71

Browse files
authored
Upgrade to JSON v1 (#215)
* Upgrade to JSON v1 * Update documenter compat * Warn only on missing docs etc
1 parent 00faf62 commit 5245c71

8 files changed

Lines changed: 18 additions & 17 deletions

File tree

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name = "XGBoost"
22
uuid = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"
3-
version = "2.5.2"
3+
version = "2.5.3"
44

55
[deps]
66
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
88
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
9-
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
9+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1212
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -29,13 +29,13 @@ XGBoostTermExt = "Term"
2929
AbstractTrees = "0.4"
3030
CEnum = "0.4, 0.5"
3131
CUDA = "3, 4, 5"
32-
JSON3 = "1"
32+
JSON = "1.4.0"
3333
OrderedCollections = "1"
3434
SparseMatricesCSR = "0.6"
3535
Tables = "1"
3636
Term = "1, 2"
37-
XGBoost_jll = "2.1"
3837
XGBoost_GPU_jll = "2.1"
38+
XGBoost_jll = "2.1"
3939
julia = "1.6"
4040

4141
[extras]

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9"
44

55
[compat]
6-
Documenter = "0.27"
6+
Documenter = "1"

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ makedocs(;
1717
"Additional Features" => "features.md",
1818
"API" => "api.md",
1919
],
20+
warnonly = [:missing_docs, :autodocs_block, :docs_block, :cross_references]
2021
)
2122

2223
deploydocs(repo="github.com/dmlc/XGBoost.jl.git", devbranch="master")

src/XGBoost.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SparseMatricesCSR
77
using SparseMatricesCSR: SparseMatrixCSR
88
using AbstractTrees
99
using OrderedCollections
10-
using JSON3
10+
using JSON
1111
using Tables
1212
using Statistics: mean, std
1313

src/booster.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function save(b::Booster, fname::AbstractString; kw...)
196196
fname
197197
end
198198
function save(b::Booster, ::Type{Vector{UInt8}}; format::AbstractString="json")
199-
cfg = JSON3.write(Dict("format"=>format))
199+
cfg = JSON.json(Dict("format"=>format))
200200
olen = Ref{Lib.bst_ulong}()
201201
o = Ref{Ptr{Int8}}()
202202
xgbcall(XGBoosterSaveModelToBuffer, b.handle, cfg, olen, o)
@@ -234,7 +234,7 @@ function dump(b::Booster;
234234
with_stats::Bool=false,
235235
)
236236
strs = dumpraw(b; fmap, with_stats)
237-
JSON3.read.(strs)
237+
JSON.parse.(strs)
238238
end
239239

240240
"""
@@ -302,7 +302,7 @@ function predict_nocopy(b::Booster, Xy::DMatrix;
302302
"iteration_end"=>ntree_limit,
303303
"strict_shape"=>false,
304304
"training"=>training,
305-
) |> JSON3.write
305+
) |> JSON.json
306306
oshape = Ref{Ptr{Lib.bst_ulong}}()
307307
odim = Ref{Lib.bst_ulong}()
308308
o = Ref{Ptr{Cfloat}}()

src/dmatrix.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function load(::Type{DMatrix}, fname::AbstractString;
193193
# docs are inconsistent and don't explain this, so it's disabled
194194
#"data_split_mode"=>string(data_split_mode),
195195
)
196-
xgbcall(XGDMatrixCreateFromURI, JSON3.write(cfg), o)
196+
xgbcall(XGDMatrixCreateFromURI, JSON.json(cfg), o)
197197
DMatrix(o[], kw...)
198198
end
199199

@@ -361,7 +361,7 @@ function getdata(dm::DMatrix)
361361
rowptr = Vector{UInt64}(undef, m+1)
362362
colval = Vector{UInt32}(undef, nnonmissing(dm))
363363
data = Vector{Float32}(undef, nnonmissing(dm))
364-
cfg = JSON3.write(Dict())
364+
cfg = JSON.json(Dict())
365365
xgbcall(XGDMatrixGetDataAsCSR, dm.handle, cfg, rowptr, colval, data)
366366
SparseMatrixCSR{0}(m, n, rowptr, UInt64.(colval), data)
367367
end
@@ -496,9 +496,9 @@ function numpy_json_dict(x::AbstractArray; read_only::Bool=false)
496496
)
497497
end
498498

499-
numpy_json_info(x::AbstractArray; kw...) = JSON3.write(numpy_json_dict(x; kw...))
499+
numpy_json_info(x::AbstractArray; kw...) = JSON.json(numpy_json_dict(x; kw...))
500500

501-
numpy_json_infos(cols::Tables.Columns; kw...) = JSON3.write(map(x -> numpy_json_dict(x; kw...), cols))
501+
numpy_json_infos(cols::Tables.Columns; kw...) = JSON.json(map(x -> numpy_json_dict(x; kw...), cols))
502502

503503
#TODO: still a little worried about ownership here
504504
#TODO: sparse data for iterator and proper missings handling
@@ -597,7 +597,7 @@ function _dmatrix_caching_config_json(;cache_prefix::AbstractString,
597597
repr(missing_value)
598598
end
599599
# xgboost allows nan and inf which JSON3 thinks is invalid
600-
replace(JSON3.write(d), "\"__NAN_STR__\""=>nanstr)
600+
replace(JSON.json(d), "\"__NAN_STR__\""=>nanstr)
601601
end
602602

603603
function DMatrix(itr::DataIterator;

src/introspection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ importances and [`importancereport`](@ref) for a convenient text display of it.
2828
function importance(b::Booster, type::AbstractString="gain")
2929
getnrounds(b) == 0 && return OrderedDict{String,Vector{Float32}}()
3030

31-
cfg = JSON3.write(Dict("importance_type"=>type))
31+
cfg = JSON.json(Dict("importance_type"=>type))
3232

3333
olen_fnames = Ref{Lib.bst_ulong}()
3434
o_fnames = Ref{Ptr{Ptr{Cchar}}}()

test/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using JSON3
1+
using JSON
22

33

44
function testfilepath(name::AbstractString)
@@ -27,7 +27,7 @@ end
2727

2828
function load_classification()
2929
fname = joinpath(@__DIR__,"..","assets","data","blobs.json")
30-
o = JSON3.read(String(open(read, fname)))
30+
o = JSON.parse(String(open(read, fname)))
3131
X = Matrix{Float32}([o[:X1] o[:X2] o[:X3]])
3232
y = o[:y]
3333
(X, y)

0 commit comments

Comments
 (0)