Skip to content

Commit b9b04be

Browse files
committed
deprecate getLabelDict,setSolverParams, setDescription
1 parent 0b3b6cd commit b9b04be

File tree

11 files changed

+154
-67
lines changed

11 files changed

+154
-67
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ end
3636
# Accessors
3737
getLabelDict(dfg::CloudGraphsDFG) = dfg.labelDict
3838
getDescription(dfg::CloudGraphsDFG) = dfg.description
39-
setDescription(dfg::CloudGraphsDFG, description::String) = dfg.description = description
39+
setDescription!(dfg::CloudGraphsDFG, description::String) = dfg.description = description
4040
getAddHistory(dfg::CloudGraphsDFG) = dfg.addHistory
4141
getSolverParams(dfg::CloudGraphsDFG) = dfg.solverParams
42-
function setSolverParams(dfg::CloudGraphsDFG, solverParams::T)::T where T <: AbstractParams
42+
function setSolverParams!(dfg::CloudGraphsDFG, solverParams::T)::T where T <: AbstractParams
4343
return dfg.solverParams = solverParams
4444
end
4545

src/Deprecated.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,9 @@ function data(f::DFGFactor)::GenericFunctionNodeData
156156
@warn "data() is deprecated, please use getSolverData()"
157157
return f.data
158158
end
159+
160+
161+
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")
162+
163+
setSolverParams(args...) = error("setSolverParams is deprecated, use setSolverParams!")
164+
setDescription(args...) = error("setSolverParams is deprecated, use setDescription!")

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export MeanMaxPPE
9191
# AbstractDFG Interface
9292
#--------
9393
export setSerializationModule!, getSerializationModule
94-
export getLabelDict, getDescription, setDescription, getAddHistory, getSolverParams, setSolverParams
94+
export getDescription, setDescription!, getAddHistory, getSolverParams, setSolverParams!
9595
export getUserData, setUserData!, getRobotData, setRobotData!, getSessionData, setSessionData!
9696

9797
# Not sure these are going to work everywhere, TODO implement in cloud?
@@ -108,6 +108,7 @@ export getBiadjacencyMatrix
108108
export toDot, toDotFile
109109
# Deprecated
110110
export getAdjacencyMatrix, getAdjacencyMatrixSparse
111+
export getLabelDict, setSolverParams, setDescription
111112
#--------
112113

113114
# File import and export

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ end
1616
vertex_index(v::GraphsNode) = v.index
1717

1818
# Accessors
19-
getLabelDict(dfg::GraphsDFG) = dfg.labelDict
20-
getDescription(dfg::GraphsDFG) = dfg.description
21-
setDescription(dfg::GraphsDFG, description::String) = dfg.description = description
22-
getAddHistory(dfg::GraphsDFG) = dfg.addHistory
23-
getSolverParams(dfg::GraphsDFG) = dfg.solverParams
24-
function setSolverParams(dfg::GraphsDFG, solverParams::T) where T <: AbstractParams
25-
dfg.solverParams = solverParams
26-
end
19+
# getLabelDict(dfg::GraphsDFG) = dfg.labelDict
20+
# getDescription(dfg::GraphsDFG) = dfg.description
21+
# setDescription(dfg::GraphsDFG, description::String) = dfg.description = description
22+
# getAddHistory(dfg::GraphsDFG) = dfg.addHistory
23+
# getSolverParams(dfg::GraphsDFG) = dfg.solverParams
24+
# function setSolverParams(dfg::GraphsDFG, solverParams::T) where T <: AbstractParams
25+
# dfg.solverParams = solverParams
26+
# end
2727

2828
"""
2929
$(SIGNATURES)

src/LightDFG/LightDFG.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ using DocStringExtensions
66
import ...DistributedFactorGraphs: AbstractDFG, DFGNode, AbstractDFGVariable, AbstractDFGFactor, AbstractDFGSummary, AbstractParams, NoSolverParams, DFGVariable, DFGFactor
77

88
# import DFG functions to extend
9-
import ...DistributedFactorGraphs: setSolverParams,
9+
import ...DistributedFactorGraphs: setSolverParams!,
1010
getFactor,
11-
setDescription,
12-
getLabelDict,
11+
setDescription!,
12+
# getLabelDict,
1313
getUserData,
1414
setUserData!,
1515
getRobotData,

src/LightDFG/entities/LightDFG.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ LightDFG{T}(g::FactorGraph{Int,DFGVariable,DFGFactor}=FactorGraph{Int,DFGVariabl
5656
LightDFG(g::FactorGraph{Int,DFGVariable,DFGFactor}=FactorGraph{Int,DFGVariable,DFGFactor}(); params::T=NoSolverParams(), kwargs...) where T =
5757
LightDFG{T,DFGVariable,DFGFactor}(g; params=params, kwargs...)
5858

59+
60+
LigthDFG(description::String,
61+
userId::String,
62+
robotId::String,
63+
sessionId::String,
64+
userData::Dict{Symbol, String},
65+
robotData::Dict{Symbol, String},
66+
sessionData::Dict{Symbol, String},
67+
solverParams::AbstractParams) =
68+
LigthDFG(FactorGraph{Int,DFGVariable,DFGFactor}(), description, userId, robotId, sessionId, userData, robotData, sessionData, Symbol[], solverParams)
69+
70+
5971
# Fully depcrecate nodeCounter and labelDict
6072
# Base.propertynames(x::LightDFG, private::Bool=false) =
6173
# (:g, :description, :userId, :robotId, :sessionId, :nodeCounter, :labelDict, :addHistory, :solverParams)

src/LightDFG/services/LightDFG.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

22

3-
# Accessors
4-
getLabelDict(dfg::LightDFG) = copy(dfg.g.labels.sym_int)
5-
getDescription(dfg::LightDFG) = dfg.description
6-
setDescription(dfg::LightDFG, description::String) = dfg.description = description
7-
getAddHistory(dfg::LightDFG) = dfg.addHistory
8-
getSolverParams(dfg::LightDFG) = dfg.solverParams
9-
10-
# setSolverParams(dfg::LightDFG, solverParams) = dfg.solverParams = solverParams
11-
function setSolverParams(dfg::LightDFG, solverParams::P) where P <: AbstractParams
12-
dfg.solverParams = solverParams
13-
end
3+
# # Accessors
4+
# getLabelDict(dfg::LightDFG) = copy(dfg.g.labels.sym_int)
5+
# getDescription(dfg::LightDFG) = dfg.description
6+
# setDescription(dfg::LightDFG, description::String) = dfg.description = description
7+
# getAddHistory(dfg::LightDFG) = dfg.addHistory
8+
# getSolverParams(dfg::LightDFG) = dfg.solverParams
9+
#
10+
# # setSolverParams(dfg::LightDFG, solverParams) = dfg.solverParams = solverParams
11+
# function setSolverParams(dfg::LightDFG, solverParams::P) where P <: AbstractParams
12+
# dfg.solverParams = solverParams
13+
# end
1414

1515
function exists(dfg::LightDFG{P,V,F}, node::V) where {P <: AbstractParams, V <: AbstractDFGVariable, F <: AbstractDFGFactor}
1616
return haskey(dfg.g.variables, node.label)

src/services/AbstractDFG.jl

Lines changed: 104 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,89 @@
1+
## ===== Interface for an AbstractDFG =====
12

3+
# Standard recommended fields to implement for AbstractDFG
4+
# - `description::String`
5+
# - `userId::String`
6+
# - `robotId::String`
7+
# - `sessionId::String`
8+
# - `userData::Dict{Symbol, String}`
9+
# - `robotData::Dict{Symbol, String}`
10+
# - `sessionData::Dict{Symbol, String}`
11+
# - `solverParams::T<:AbstractParams`
12+
# - `addHistory::Vector{Symbol}`
13+
# AbstractDFG Accessors
214

3-
## ===== Interface for an AbstractDFG =====
15+
# Getters
16+
"""
17+
$(SIGNATURES)
18+
"""
19+
getDFGInfo(dfg::AbstractDFG) = (dfg.description, dfg.userId, dfg.robotId, dfg.sessionId, dfg.userData, dfg.robotData, dfg.sessionData, dfg.solverParams)
420

521
"""
622
$(SIGNATURES)
23+
"""
24+
getDescription(dfg::AbstractDFG) = dfg.description
725

8-
Deserialization of IncrementalInference objects require discovery of foreign types.
26+
"""
27+
$(SIGNATURES)
28+
"""
29+
getUserId(dfg::AbstractDFG) = dfg.userId
930

10-
Example:
31+
"""
32+
$(SIGNATURES)
33+
"""
34+
getRobotId(dfg::AbstractDFG) = dfg.robotId
1135

12-
Template to tunnel types from a user module:
13-
```julia
14-
# or more generic solution -- will always try Main if available
15-
IIF.setSerializationNamespace!(Main)
36+
"""
37+
$(SIGNATURES)
38+
"""
39+
getSessionId(dfg::AbstractDFG) = dfg.sessionId
1640

17-
# or a specific package such as RoME if you import all variable and factor types into a specific module.
18-
using RoME
19-
IIF.setSerializationNamespace!(RoME)
20-
```
2141
"""
22-
function setSerializationModule!(dfg::G, mod::Module)::Nothing where G <: AbstractDFG
23-
@warn "Setting serialization module from AbstractDFG - override this in the '$(typeof(dfg)) structure! This is being ignored."
24-
end
42+
$(SIGNATURES)
43+
"""
44+
getAddHistory(dfg::AbstractDFG) = dfg.addHistory
2545

26-
function getSerializationModule(dfg::G)::Module where G <: AbstractDFG
27-
@warn "Retrieving serialization module from AbstractDFG - override this in the '$(typeof(dfg)) structure! This is returning Main"
28-
return Main
29-
end
46+
"""
47+
$(SIGNATURES)
48+
"""
49+
getSolverParams(dfg::AbstractDFG) = dfg.solverParams
3050

31-
# Accessors
32-
function getLabelDict(dfg::G) where G <: AbstractDFG
33-
error("getLabelDict not implemented for $(typeof(dfg))")
34-
end
35-
function getDescription(dfg::G) where G <: AbstractDFG
36-
error("getDescription not implemented for $(typeof(dfg))")
37-
end
38-
function setDescription(dfg::G, description::String) where G <: AbstractDFG
39-
error("setDescription not implemented for $(typeof(dfg))")
40-
end
41-
function getAddHistory(dfg::G) where G <: AbstractDFG
42-
error("getAddHistory not implemented for $(typeof(dfg))")
43-
end
44-
function getSolverParams(dfg::G) where G <: AbstractDFG
45-
error("getSolverParams not implemented for $(typeof(dfg))")
46-
end
47-
function setSolverParams(dfg::G, solverParams::T) where {G <: AbstractDFG, T <: AbstractParams}
48-
error("setSolverParams not implemented for $(typeof(dfg))")
49-
end
51+
52+
# Setters
53+
"""
54+
$(SIGNATURES)
55+
"""
56+
setDescription!(dfg::AbstractDFG, description::String) = dfg.description = description
5057

58+
"""
59+
$(SIGNATURES)
60+
"""
61+
setUserId!(dfg::AbstractDFG, userId::String) = dfg.userId = userId
62+
63+
"""
64+
$(SIGNATURES)
65+
"""
66+
setRobotId!(dfg::AbstractDFG, robotId::String) = dfg.robotId = robotId
67+
68+
"""
69+
$(SIGNATURES)
70+
"""
71+
setSessionId!(dfg::AbstractDFG, sessionId::String) = dfg.sessionId = sessionId
72+
73+
"""
74+
$(SIGNATURES)
75+
"""
76+
#TODO don't know what error will be thrown if solverParams type does not mach the one in dfg
77+
setSolverParams!(dfg::AbstractDFG, solverParams::AbstractParams) = dfg.solverParams = solverParams
78+
79+
# Accessors and CRUD for user/robot/session Data
5180
"""
5281
$SIGNATURES
5382
5483
Get the user data associated with the graph.
5584
"""
5685
getUserData(dfg::AbstractDFG)::Union{Nothing, Dict{Symbol, String}} = return dfg.userData
86+
5787
"""
5888
$SIGNATURES
5989
@@ -63,12 +93,14 @@ function setUserData!(dfg::AbstractDFG, data::Dict{Symbol, String})::Union{Nothi
6393
dfg.userData = data
6494
return dfg.userData
6595
end
96+
6697
"""
6798
$SIGNATURES
6899
69100
Get the robot data associated with the graph.
70101
"""
71102
getRobotData(dfg::AbstractDFG)::Union{Nothing, Dict{Symbol, String}} = return dfg.robotData
103+
72104
"""
73105
$SIGNATURES
74106
@@ -78,12 +110,14 @@ function setRobotData!(dfg::AbstractDFG, data::Dict{Symbol, String})::Union{Noth
78110
dfg.robotData = data
79111
return dfg.robotData
80112
end
113+
81114
"""
82115
$SIGNATURES
83116
84117
Get the session data associated with the graph.
85118
"""
86119
getSessionData(dfg::AbstractDFG)::Dict{Symbol, String} = return dfg.sessionData
120+
87121
"""
88122
$SIGNATURES
89123
@@ -112,6 +146,38 @@ emptyUserData!(dfg::AbstractDFG) = empty!(dfg.userData)
112146
emptyRobotData!(dfg::AbstractDFG) = empty!(dfg.userData)
113147
emptySessionData!(dfg::AbstractDFG) = empty!(dfg.userData)
114148

149+
150+
151+
152+
##
153+
"""
154+
$(SIGNATURES)
155+
156+
Deserialization of IncrementalInference objects require discovery of foreign types.
157+
158+
Example:
159+
160+
Template to tunnel types from a user module:
161+
```julia
162+
# or more generic solution -- will always try Main if available
163+
IIF.setSerializationNamespace!(Main)
164+
165+
# or a specific package such as RoME if you import all variable and factor types into a specific module.
166+
using RoME
167+
IIF.setSerializationNamespace!(RoME)
168+
```
169+
"""
170+
function setSerializationModule!(dfg::G, mod::Module)::Nothing where G <: AbstractDFG
171+
@warn "Setting serialization module from AbstractDFG - override this in the '$(typeof(dfg)) structure! This is being ignored."
172+
end
173+
174+
function getSerializationModule(dfg::G)::Module where G <: AbstractDFG
175+
@warn "Retrieving serialization module from AbstractDFG - override this in the '$(typeof(dfg)) structure! This is returning Main"
176+
return Main
177+
end
178+
179+
180+
115181
"""
116182
$(SIGNATURES)
117183
True if the variable or factor exists in the graph.
@@ -777,6 +843,7 @@ function getBiadjacencyMatrix(dfg::AbstractDFG; solvable::Int=0)::NamedTuple{(:B
777843
end
778844

779845
function getAdjacencyMatrixSparse(dfg::AbstractDFG; solvable::Int=0)
846+
@warn "Deprecated function, please use getBiadjacencyMatrix as this will be removed in v0.6.1"
780847
return getBiadjacencyMatrix(dfg, solvable)
781848
end
782849
# -------------------------

test/LightDFGSummaryTypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ end
6363
# Accessors
6464
@test getAddHistory(dfg) == [:a, :b] #, :f1
6565
@test getDescription(dfg) != nothing
66-
@test getLabelDict(dfg) != nothing
66+
@test_throws ErrorException getLabelDict(dfg)
6767
# Existence
6868
@test exists(dfg, :a) == true
6969
@test exists(dfg, v1) == true

test/iifInterfaceTests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ end
110110
# Accessors
111111
@test getAddHistory(dfg) == [:a, :b] #, :abf1
112112
@test getDescription(dfg) != nothing
113-
@test getLabelDict(dfg) != nothing
113+
#TODO Deprecate
114+
@test_throws ErrorException getLabelDict(dfg)
114115
# Existence
115116
@test exists(dfg, :a) == true
116117
@test exists(dfg, v1) == true
@@ -171,7 +172,7 @@ end
171172
@test internalId(f1) == f1._internalId
172173

173174
@test getSolverParams(dfg) != nothing
174-
@test setSolverParams(dfg, getSolverParams(dfg)) == getSolverParams(dfg)
175+
@test setSolverParams!(dfg, getSolverParams(dfg)) == getSolverParams(dfg)
175176

176177
#solver data is initialized
177178
@test !isInitialized(dfg, :a)

0 commit comments

Comments
 (0)