Skip to content

Commit 371eec5

Browse files
committed
Cherrypick: _getDuplicatedEmptyDFG
1 parent 51a526b commit 371eec5

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function _getDuplicatedEmptyDFG(dfg::CloudGraphsDFG)::CloudGraphsDFG
5454
length(_getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId):$(sessionId))")) == 0 && break
5555
end
5656
@debug "Unique+empty copy session name: $sessionId"
57-
return CloudGraphsDFG{typeof(dfg.solverParams)}(dfg.neo4jInstance.connection, dfg.userId, dfg.robotId, sessionId, dfg.encodePackedTypeFunc, dfg.getPackedTypeFunc, dfg.decodePackedTypeFunc, solverParams=deepcopy(dfg.solverParams), description="(Copy of) $(dfg.description)", useCache=dfg.useCache)
57+
return CloudGraphsDFG{typeof(dfg.solverParams)}(dfg.neo4jInstance.connection, dfg.userId, dfg.robotId, sessionId, dfg.encodePackedTypeFunc, dfg.getPackedTypeFunc, dfg.decodePackedTypeFunc, dfg.rebuildFactorMetadata!, solverParams=deepcopy(dfg.solverParams), description="(Copy of) $(dfg.description)", useCache=dfg.useCache)
5858
end
5959

6060
# Accessors

src/LightDFG/LightDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import ...DistributedFactorGraphs: setSolverParams,
3434
getSubgraphAroundNode,
3535
getSubgraph,
3636
getAdjacencyMatrix,
37-
getAdjacencyMatrixSparse
37+
getAdjacencyMatrixSparse,
38+
_getDuplicatedEmptyDFG
3839

3940
include("FactorGraphs/FactorGraphs.jl")
4041
using .FactorGraphs

src/LightDFG/services/LightDFG.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,15 @@ function getAdjacencyMatrixSparse(dfg::LightDFG)::Tuple{LightGraphs.SparseMatrix
426426
adjvf = adj[factIndex, varIndex]
427427
return adjvf, varLabels, factLabels
428428
end
429+
430+
"""
431+
$(SIGNATURES)
432+
Gets an empty and unique CloudGraphsDFG derived from an existing DFG.
433+
"""
434+
function _getDuplicatedEmptyDFG(dfg::LightDFG{P,V,F})::LightDFG where {P <: AbstractParams, V <: AbstractDFGVariable, F <: AbstractDFGFactor}
435+
newDfg = LightDFG{P,V,F}(;
436+
userId=dfg.userId, robotId=dfg.robotId, sessionId=dfg.sessionId,
437+
params=deepcopy(dfg.solverParams))
438+
newDfg.description ="(Copy of) $(dfg.description)"
439+
return newDfg
440+
end

src/MetaGraphsDFG/services/MetaGraphsDFG.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,15 @@ function _toDotFile(dfg::MetaGraphsDFG, fileName::String="/tmp/dfg.dot")::Nothin
564564
end
565565
return nothing
566566
end
567+
568+
"""
569+
$(SIGNATURES)
570+
Gets an empty and unique CloudGraphsDFG derived from an existing DFG.
571+
"""
572+
function _getDuplicatedEmptyDFG(dfg::MetaGraphsDFG{P})::MetaGraphsDFG where {P <: AbstractParams}
573+
newDfg = MetaGraphsDFG{P}(;
574+
userId=dfg.userId, robotId=dfg.robotId, sessionId=dfg.sessionId,
575+
params=deepcopy(dfg.solverParams))
576+
newDfg.description ="(Copy of) $(dfg.description)"
577+
return newDfg
578+
end

src/SymbolDFG/SymbolDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import ...DistributedFactorGraphs: setSolverParams,
3434
getSubgraphAroundNode,
3535
getSubgraph,
3636
getAdjacencyMatrix,
37-
getAdjacencyMatrixSparse
37+
getAdjacencyMatrixSparse,
38+
_getDuplicatedEmptyDFG
3839

3940
include("SymbolFactorGraphs/SymbolFactorGraphs.jl")
4041
using .SymbolFactorGraphs

src/SymbolDFG/services/SymbolDFG.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,15 @@ function toDotFile(dfg::SymbolDFG, fileName::String="/tmp/dfg.dot")::Nothing
518518
return nothing
519519
end
520520
=#
521+
522+
"""
523+
$(SIGNATURES)
524+
Gets an empty and unique CloudGraphsDFG derived from an existing DFG.
525+
"""
526+
function _getDuplicatedEmptyDFG(dfg::SymbolDFG{T,V,F})::SymbolDFG where {T <: AbstractParams, V <: DFGNode, F <:DFGNode}
527+
newDfg = SymbolDFG{T, V, F}(;
528+
userId=dfg.userId, robotId=dfg.robotId, sessionId=dfg.sessionId,
529+
params=deepcopy(dfg.solverParams))
530+
newDfg.description ="(Copy of) $(dfg.description)"
531+
return newDfg
532+
end

0 commit comments

Comments
 (0)