Skip to content

Commit f88fc36

Browse files
authored
Merge pull request #449 from JuliaRobotics/maint/20Q2/rebuildFactorMetadata#425
Also dispach on solverData type for rebuildFactorMetadata!
2 parents 130c679 + d92b175 commit f88fc36

File tree

18 files changed

+61
-77
lines changed

18 files changed

+61
-77
lines changed

attic/GraphsDFG/entities/GraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mutable struct GraphsNode
88
end
99
const FGType = Graphs.GenericIncidenceList{GraphsNode,Graphs.Edge{GraphsNode},Dict{Int,GraphsNode},Dict{Int,Array{Graphs.Edge{GraphsNode},1}}}
1010

11-
mutable struct GraphsDFG{T <: AbstractParams} <: AbstractDFG
11+
mutable struct GraphsDFG{T <: AbstractParams} <: AbstractDFG{T}
1212
g::FGType
1313
description::String
1414
userId::String

src/CloudGraphsDFG/entities/CloudGraphsDFG.jl

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ mutable struct Neo4jInstance
55
graph::Neo4j.Graph
66
end
77

8-
mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG
8+
mutable struct CloudGraphsDFG{T <: AbstractParams} <: AbstractDFG{T}
99
neo4jInstance::Neo4jInstance
1010
userId::String
1111
robotId::String
1212
sessionId::String
1313
description::String
14-
encodePackedTypeFunc #TODO Is this planed to be used or deprecated?
15-
getPackedTypeFunc #TODO Is this planed to be used or deprecated?
16-
decodePackedTypeFunc #TODO Is this planed to be used or deprecated?
17-
rebuildFactorMetadata!
1814
addHistory::Vector{Symbol}
1915
solverParams::T # Solver parameters
2016
end
@@ -27,11 +23,7 @@ function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
2723
userId::String,
2824
robotId::String,
2925
sessionId::String,
30-
description::String,
31-
encodePackedTypeFunc,
32-
getPackedTypeFunc,
33-
decodePackedTypeFunc,
34-
rebuildFactorMetadata!;
26+
description::String;
3527
solverParams::T=NoSolverParams(),
3628
createSessionNodes::Bool=true) where T <: AbstractParams
3729
# Validate the userId, robotId, and sessionId
@@ -41,7 +33,7 @@ function CloudGraphsDFG{T}(neo4jConnection::Neo4j.Connection,
4133

4234
graph = Neo4j.getgraph(neo4jConnection)
4335
neo4jInstance = Neo4jInstance(neo4jConnection, graph)
44-
dfg = CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, Symbol[], solverParams)
36+
dfg = CloudGraphsDFG{T}(neo4jInstance, userId, robotId, sessionId, description, Symbol[], solverParams)
4537
# Create the session if it doesn't already exist
4638
createSessionNodes && createDfgSessionIfNotExist(dfg)
4739
return dfg
@@ -57,15 +49,11 @@ function CloudGraphsDFG{T}(host::String,
5749
userId::String,
5850
robotId::String,
5951
sessionId::String,
60-
description::String,
61-
encodePackedTypeFunc,
62-
getPackedTypeFunc,
63-
decodePackedTypeFunc,
64-
rebuildFactorMetadata!;
52+
description::String;
6553
solverParams::T=NoSolverParams(),
6654
createSessionNodes::Bool=true) where T <: AbstractParams
6755
neo4jConnection = Neo4j.Connection(host, port=port, user=dbUser, password=dbPassword);
68-
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, description, encodePackedTypeFunc, getPackedTypeFunc, decodePackedTypeFunc, rebuildFactorMetadata!, solverParams=solverParams, createSessionNodes=createSessionNodes)
56+
return CloudGraphsDFG{T}(neo4jConnection, userId, robotId, sessionId, description, solverParams=solverParams, createSessionNodes=createSessionNodes)
6957
end
7058

7159

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ function _getDuplicatedEmptyDFG(dfg::CloudGraphsDFG)::CloudGraphsDFG
1818
dfg.robotId,
1919
sessionId,
2020
dfg.description,
21-
dfg.encodePackedTypeFunc,
22-
dfg.getPackedTypeFunc,
23-
dfg.decodePackedTypeFunc,
24-
dfg.rebuildFactorMetadata!,
2521
solverParams=deepcopy(dfg.solverParams))
2622
end
2723

@@ -242,7 +238,7 @@ function getFactor(dfg::CloudGraphsDFG, label::Union{Symbol, String})::DFGFactor
242238
factor = unpackFactor(dfg, props)
243239

244240
# Lastly, rebuild the metadata
245-
factor = dfg.rebuildFactorMetadata!(dfg, factor)
241+
factor = rebuildFactorMetadata!(dfg, factor)
246242

247243
return factor
248244
end

src/Deprecated.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ include("../attic/GraphsDFG/GraphsDFG.jl")
1111
@reexport using .GraphsDFGs
1212

1313

14+
@deprecate loadDFG(source::String, iifModule::Module, dest::AbstractDFG) loadDFG!(dest, source)
15+
1416
@deprecate buildSubgraphFromLabels!(dfg::AbstractDFG, varList::Vector{Symbol}) buildSubgraph(dfg, varList, 1)
1517

1618

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export setSerializationModule!, getSerializationModule
212212
export packVariable, unpackVariable, packFactor, unpackFactor
213213

214214
# File import and export
215-
export saveDFG, loadDFG
215+
export saveDFG, loadDFG!
216216
export toDot, toDotFile
217217

218218
# Comparisons

src/FileDFG/services/FileDFG.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ loadDFG("/tmp/savedgraph.tar.gz", IncrementalInference, dfg)
8282
ls(dfg)
8383
```
8484
"""
85-
function loadDFG(dst::String,
86-
iifModule::Module,
87-
dfgLoadInto::G) where G <: AbstractDFG
85+
function loadDFG!(dfgLoadInto::AbstractDFG, dst::String)
8886

8987

9088
#
@@ -151,7 +149,7 @@ function loadDFG(dst::String,
151149
# Finally, rebuild the CCW's for the factors to completely reinflate them
152150
@info "Rebuilding CCW's for the factors..."
153151
for factor in factors
154-
iifModule.rebuildFactorMetadata!(dfgLoadInto, factor)
152+
rebuildFactorMetadata!(dfgLoadInto, factor)
155153
end
156154

157155
# remove the temporary unzipped file

src/LightDFG/entities/LightDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ An in-memory DistributedFactorGraph based on LightGraphs.jl with parameters:
77
- V: Variable type
88
- F: Factor type
99
"""
10-
mutable struct LightDFG{T <: AbstractParams, V <: AbstractDFGVariable, F <:AbstractDFGFactor} <: AbstractDFG
10+
mutable struct LightDFG{T <: AbstractParams, V <: AbstractDFGVariable, F <:AbstractDFGFactor} <: AbstractDFG{T}
1111
g::FactorGraph{Int, V, F}
1212
description::String
1313
userId::String

src/entities/AbstractDFG.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ end
3232

3333
"""
3434
$(TYPEDEF)
35-
Abstract parent struct for a DFG graph.
35+
Abstract parent struct for solver parameters.
3636
"""
37-
abstract type AbstractDFG
38-
end
37+
abstract type AbstractParams end
3938

4039
"""
4140
$(TYPEDEF)
42-
Abstract parent struct for solver parameters.
43-
"""
44-
abstract type AbstractParams end
41+
Abstract parent struct for a DFG graph.
42+
"""
43+
abstract type AbstractDFG{T<:AbstractParams} end
4544

4645
"""
4746
$(TYPEDEF)

src/services/AbstractDFG.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Method must be overloaded by the user for Serialization to work. E.g. Increment
6060
getFactorOperationalMemoryType(dummy) = error("Please extend your workspace with function getFactorOperationalMemoryType(<:AbstractParams) for your usecase, e.g. IncrementalInference uses `CommonConvWrapper <: FactorOperationalMemory`")
6161
getFactorOperationalMemoryType(dfg::AbstractDFG) = getFactorOperationalMemoryType(getSolverParams(dfg))
6262

63+
"""
64+
$(SIGNATURES)
65+
66+
Method must be overloaded by the user for Serialization to work.
67+
"""
68+
rebuildFactorMetadata!(dfg::AbstractDFG{<:AbstractParams}, factor::AbstractDFGFactor) = error("rebuildFactorMetadata! is not implemented for $(typeof(dfg))")
6369

6470
##------------------------------------------------------------------------------
6571
## Setters

src/services/Serialization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
167167
factor._variableOrderSymbols = _variableOrderSymbols
168168
setSolvable!(factor, solvable)
169169

170-
# Note, once inserted, you still need to call IIF.rebuildFactorMetadata!
170+
# Note, once inserted, you still need to call rebuildFactorMetadata!
171171
return factor
172172
end
173173

0 commit comments

Comments
 (0)