Skip to content

Commit 845b3c6

Browse files
committed
depr code and warns
1 parent d40d848 commit 845b3c6

File tree

3 files changed

+55
-33
lines changed

3 files changed

+55
-33
lines changed

src/Deprecated.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ end
6363
## Deprecate before v0.20
6464
##=================================================================================
6565

66+
67+
# Need to implement this to allow Unmarshal to deserialize Nullable UUIDs and ZonedDateTimes
68+
# TODO: Move to JSON3.
69+
# import Unmarshal: unmarshal
70+
71+
function unmarshal(::Type{Union{UUID, Nothing}}, x, verbose :: Bool = false, verboseLvl :: Int = 0)
72+
if x !== nothing
73+
return UUID(x)
74+
else
75+
return nothing
76+
end
77+
end
78+
function unmarshal(::Type{Union{ZonedDateTime, Nothing}}, x, verbose :: Bool = false, verboseLvl :: Int = 0)
79+
if x !== nothing
80+
return ZonedDateTime(x)
81+
else
82+
return nothing
83+
end
84+
end
85+
6686
export DefaultDFG
6787

6888
const DefaultDFG = GraphsDFG

src/GraphsDFG/entities/GraphsDFG.jl

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,40 @@ Create an in-memory GraphsDFG with the following parameters:
2929
- V: Variable type
3030
- F: Factor type
3131
"""
32-
function GraphsDFG{T,V,F}(g::FactorGraph{Int,V,F}=FactorGraph{Int,V,F}();
33-
description::String="Graphs.jl implementation",
34-
userLabel::String="DefaultUser",
35-
robotLabel::String="DefaultRobot",
36-
sessionLabel::String="Session_$(string(uuid4())[1:6])",
37-
userData::Dict{Symbol, String} = Dict{Symbol, String}(),
38-
robotData::Dict{Symbol, String} = Dict{Symbol, String}(),
39-
sessionData::Dict{Symbol, String} = Dict{Symbol, String}(),
40-
solverParams::T=T(),
41-
blobstores=Dict{Symbol, AbstractBlobStore}()) where {T <: AbstractParams, V <:AbstractDFGVariable, F<:AbstractDFGFactor}
42-
# Validate the userLabel, robotLabel, and sessionLabel
43-
!isValidLabel(userLabel) && error("'$userLabel' is not a valid User label")
44-
!isValidLabel(robotLabel) && error("'$robotLabel' is not a valid Robot label")
45-
!isValidLabel(sessionLabel) && error("'$sessionLabel' is not a valid Session label")
46-
return GraphsDFG{T,V,F}(g, description, userLabel, robotLabel, sessionLabel, userData, robotData, sessionData, Symbol[], solverParams, blobstores)
32+
function GraphsDFG{T,V,F}(
33+
g::FactorGraph{Int,V,F}=FactorGraph{Int,V,F}();
34+
description::String="Graphs.jl implementation",
35+
userLabel::String="DefaultUser",
36+
robotLabel::String="DefaultRobot",
37+
sessionLabel::String="Session_$(string(uuid4())[1:6])",
38+
userData::Dict{Symbol, String} = Dict{Symbol, String}(),
39+
robotData::Dict{Symbol, String} = Dict{Symbol, String}(),
40+
sessionData::Dict{Symbol, String} = Dict{Symbol, String}(),
41+
solverParams::T=T(),
42+
blobstores=Dict{Symbol, AbstractBlobStore}(),
43+
# deprecating
44+
userId::Union{Nothing, String} = nothing,
45+
robotId::Union{Nothing, String} = nothing,
46+
sessionId::Union{Nothing, String} = nothing,
47+
) where {T <: AbstractParams, V <:AbstractDFGVariable, F<:AbstractDFGFactor}
48+
# Validate the userLabel, robotLabel, and sessionLabel
49+
if userId !== nothing
50+
@error "Obsolete use of userId::String with GraphsDFG, use userLabel::String instead" maxlog=10
51+
userLabel = userId
52+
end
53+
if robotId !== nothing
54+
@error "Obsolete use of robotId::String with GraphsDFG, use robotLabel::String instead" maxlog=10
55+
robotLabel = robotId
56+
end
57+
if sessionId !== nothing
58+
@error "Obsolete use of sessionId::String with GraphsDFG, use sessionLabel::String instead" maxlog=10
59+
sessionLabel = sessionId
60+
end
61+
62+
!isValidLabel(userLabel) && error("'$userLabel' is not a valid User label")
63+
!isValidLabel(robotLabel) && error("'$robotLabel' is not a valid Robot label")
64+
!isValidLabel(sessionLabel) && error("'$sessionLabel' is not a valid Session label")
65+
return GraphsDFG{T,V,F}(g, description, userLabel, robotLabel, sessionLabel, userData, robotData, sessionData, Symbol[], solverParams, blobstores)
4766
end
4867

4968
# GraphsDFG{T}(; kwargs...) where T <: AbstractParams = GraphsDFG{T,DFGVariable,DFGFactor}(;kwargs...)

src/services/Serialization.jl

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,9 @@ import JSON.Writer: StructuralContext, JSONContext, show_json
1212
import JSON.Serializations: CommonSerialization, StandardSerialization
1313
JSON.show_json(io::JSONContext, serialization::CommonSerialization, uuid::UUID) = print(io.io, "\"$uuid\"")
1414

15-
# Need to implement this to allow Unmarshal to deserialize Nullable UUIDs and ZonedDateTimes
16-
# TODO: Move to JSON3.
17-
import Unmarshal: unmarshal
18-
19-
function unmarshal(::Type{Union{UUID, Nothing}}, x, verbose :: Bool = false, verboseLvl :: Int = 0)
20-
if x !== nothing
21-
return UUID(x)
22-
else
23-
return nothing
24-
end
25-
end
26-
function unmarshal(::Type{Union{ZonedDateTime, Nothing}}, x, verbose :: Bool = false, verboseLvl :: Int = 0)
27-
if x !== nothing
28-
return ZonedDateTime(x)
29-
else
30-
return nothing
31-
end
32-
end
3315

3416
## Version checking
17+
# FIXME return VersionNumber
3518
function _getDFGVersion()
3619
if haskey(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"))
3720
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version)

0 commit comments

Comments
 (0)