Skip to content

Commit 025e550

Browse files
committed
Updating CGDFG to match normal function behavior
1 parent f5cc726 commit 025e550

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 5 additions & 13 deletions
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
@@ -158,9 +158,7 @@ Add a DFGVariable to a DFG.
158158
"""
159159
function addVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)::Bool
160160
if exists(dfg, variable)
161-
@warn "Variable '$(variable.label)' already exists in the graph, so updating it."
162-
updateVariable!(dfg, variable)
163-
return true
161+
error("Variable '$(variable.label)' already exists in the factor graph")
164162
end
165163
props = Dict{String, Any}()
166164
props["label"] = string(variable.label)
@@ -192,9 +190,7 @@ Add a DFGFactor to a DFG.
192190
"""
193191
function addFactor!(dfg::CloudGraphsDFG, variables::Vector{DFGVariable}, factor::DFGFactor)::Bool
194192
if exists(dfg, factor)
195-
@warn "Factor '$(factor.label)' already exist in the graph, so updating it."
196-
updateFactor!(dfg, variables, factor)
197-
return true
193+
error("Factor '$(variable.label)' already exists in the factor graph")
198194
end
199195

200196
# Update the variable ordering
@@ -363,9 +359,7 @@ Update a complete DFGVariable in the DFG.
363359
"""
364360
function updateVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)::DFGVariable
365361
if !exists(dfg, variable)
366-
@warn "Variable '$(variable.label)' doesn't exist in the graph, so adding it."
367-
addVariable!(dfg, variable)
368-
return variable
362+
error("Variable label '$(variable.label)' does not exist in the factor graph")
369363
end
370364
nodeId = _tryGetNeoNodeIdFromNodeLabel(dfg.neo4jInstance, dfg.userId, dfg.robotId, dfg.sessionId, variable.label)
371365
# Update the node ID
@@ -409,9 +403,7 @@ Update a complete DFGFactor in the DFG.
409403
"""
410404
function updateFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)::DFGFactor
411405
if !exists(dfg, factor)
412-
@warn "Factor '$(factor.label)' doesn't exist in the graph, so adding it."
413-
addFactor!(dfg, factor)
414-
return factor
406+
error("Factor label '$(factor.label)' does not exist in the factor graph")
415407
end
416408
nodeId = _tryGetNeoNodeIdFromNodeLabel(dfg.neo4jInstance, dfg.userId, dfg.robotId, dfg.sessionId, factor.label)
417409
# Update the _internalId

0 commit comments

Comments
 (0)