Skip to content

Commit 0f83ee2

Browse files
authored
Merge pull request #356 from JuliaRobotics/fix/1Q20/354
fix integration tests 354
2 parents 0b9efc4 + 8bc0263 commit 0f83ee2

File tree

11 files changed

+65
-51
lines changed

11 files changed

+65
-51
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ matrix:
4141
allow_failures:
4242
- julia: nightly
4343
- arch: arm64
44-
- env: IIF_TEST=true
44+
#- env: IIF_TEST=true
4545

4646
# Set the password for Neo4j to neo4j:test
4747
before_script:

docs/src/GraphData.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Example of PPE operations:
111111
# Add a new PPE of type MeanMaxPPE to :x0
112112
ppe = MeanMaxPPE(:default, [0.0], [0.0], [0.0])
113113
addPPE!(dfg, :x0, ppe)
114-
@show listPPE(dfg, :x0)
114+
@show listPPEs(dfg, :x0)
115115
# Get the data back - note that this is a reference to above.
116116
v = getPPE(dfg, :x0, :default)
117117
# Delete it

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function getVariable(dfg::CloudGraphsDFG, label::Union{Symbol, String})::DFGVari
181181
variable = unpackVariable(dfg, props)
182182

183183
# TODO - make this get PPE's in batch
184-
for ppe in listPPE(dfg, label)
184+
for ppe in listPPEs(dfg, label)
185185
variable.ppeDict[ppe] = getPPE(dfg, label, ppe)
186186
end
187187
return variable
@@ -220,11 +220,12 @@ function updateVariable!(dfg::CloudGraphsDFG, variable::DFGVariable)::DFGVariabl
220220
return variable
221221
end
222222

223-
function mergeUpdateVariableSolverData!(dfg::CloudGraphsDFG, sourceVariable::DFGVariable)::DFGVariable
223+
function mergeVariableData!(dfg::CloudGraphsDFG, sourceVariable::DFGVariable)::DFGVariable
224224
if !exists(dfg, sourceVariable)
225225
error("Source variable '$(sourceVariable.label)' doesn't exist in the graph.")
226226
end
227227
for (k,v) in sourceVariable.ppeDict
228+
# TODO what is happening inside, is this truely an update or is it a merge? (API consistency hounds are apon you)
228229
updatePPE!(dfg, getLabel(sourceVariable), v, k)
229230
end
230231
for (k,v) in sourceVariable.solverDataDict
@@ -233,6 +234,11 @@ function mergeUpdateVariableSolverData!(dfg::CloudGraphsDFG, sourceVariable::DFG
233234
return sourceVariable
234235
end
235236

237+
function mergeUpdateVariableSolverData!(dfg::CloudGraphsDFG, sourceVariable::DFGVariable)::DFGVariable
238+
@warn "Deprecated CloudGraphsDFG.mergeUpdateVariableSolverData!, use mergeVariableData! instead."
239+
mergeVariableData!(dfg, sourceVariable)
240+
end
241+
236242
function updateFactor!(dfg::CloudGraphsDFG, factor::DFGFactor)::DFGFactor
237243
if !exists(dfg, factor)
238244
@warn "Factor label '$(factor.label)' does not exist in the factor graph, adding"
@@ -435,7 +441,7 @@ end
435441

436442
### PPEs with DB calls
437443

438-
function listPPE(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
444+
function listPPEs(dfg::CloudGraphsDFG, variablekey::Symbol; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::Vector{Symbol}
439445
query = "match (ppe:$(join(_getLabelsForType(dfg, MeanMaxPPE, parentKey=variablekey),':'))) return ppe.solverKey"
440446
@debug "[Query] PPE read query:\r\n$query"
441447
result = nothing
@@ -469,7 +475,7 @@ function getPPE(dfg::CloudGraphsDFG, variablekey::Symbol, ppekey::Symbol=:defaul
469475
end
470476

471477
function addPPE!(dfg::CloudGraphsDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default; currentTransaction::Union{Nothing, Neo4j.Transaction}=nothing)::AbstractPointParametricEst where P <: AbstractPointParametricEst
472-
if ppekey in listPPE(dfg, variablekey, currentTransaction=currentTransaction)
478+
if ppekey in listPPEs(dfg, variablekey, currentTransaction=currentTransaction)
473479
error("PPE '$(ppekey)' already exists")
474480
end
475481
return updatePPE!(dfg, variablekey, ppe, ppekey, currentTransaction=currentTransaction)

src/Deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@deprecate getFactorIds(dfg, regexFilter=nothing; solvable=0) listFactors(dfg, regexFilter, solvable=solvable)
1414

15+
@deprecate listPPE(args...) listPPEs(args...)
1516

1617
export getLabelDict
1718
getLabelDict(dfg::AbstractDFG) = error("getLabelDict is deprecated, consider using listing functions")

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,15 @@ export getMaxPPE, getMeanPPE, getSuggestedPPE, getLastUpdatedTimestamp
141141

142142
# accessors
143143

144-
export getPPEDict
144+
export getPPEDict, getVariablePPEDict, getVariablePPE
145145

146146
# CRUD & SET
147147
export getPPE,
148-
getPPEs,
149148
getVariablePPE,
150-
getVariablePPEs,
151149
addPPE!,
152150
updatePPE!,
153151
deletePPE!,
154-
listPPE,
152+
listPPEs,
155153
mergePPEs! #TODO look at rename to just mergePPE to match with cloud?
156154

157155

src/needsahome.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ printVariable(dfg::AbstractDFG, sym::Symbol, solveKey::Symbol=:default) = print(
104104
print(dfg::AbstractDFG, sym::Symbol) = isVariable(dfg,sym) ? printVariable(dfg, sym) : printFactor(dfg, sym)
105105

106106

107-
#NOT too many aliases on PPE, brought back from deprecated DF
108-
109-
getVariablePPEs(v::VariableDataLevel1) = getPPEDict(v)
110-
111-
getPPEs(vari::VariableDataLevel1) = getPPEDict(v)
112-
113-
getVariablePPE(args...) = getPPE(args...)
114107

115108
## KEEPING COMMENT, WANT TO BE CONSOLIDATED WITH FUNCTION ABOVE -- KEEPING ONLY ONE FOR MAINTAINABILITY
116109
## STILL NEEDS TO BE CONSOLIDATED WITH `DFG._copyIntoGraph`

src/services/DFGVariable.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ end
196196
"""
197197
$SIGNATURES
198198
199-
Get the PPE dictionary for a variable. Its direct use is not recomended.
199+
Get the PPE dictionary for a variable. Recommended to use CRUD operations instead, [`getPPE`](@ref), [`addPPE!`](@ref), [`updatePPE!`](@ref), [`deletePPE!`](@ref).
200200
"""
201201
getPPEDict(v::VariableDataLevel1) = v.ppeDict
202202

@@ -219,14 +219,25 @@ function getPPE(vari::VariableDataLevel1, solveKey::Symbol=:default)
219219
# return haskey(ppeDict, solveKey) ? ppeDict[solveKey] : nothing
220220
end
221221

222+
# afew more aliases on PPE, brought back from deprecated DF
223+
224+
"""
225+
$SIGNATURES
226+
227+
Return full dictionary of PPEs in a variable, recommended to rather use CRUD: [`getPPE`](@ref),
228+
"""
229+
getVariablePPEDict(vari::VariableDataLevel1) = getPPEDict(vari)
230+
231+
getVariablePPE(args...) = getPPE(args...)
232+
222233
##------------------------------------------------------------------------------
223234
## solverDataDict
224235
##------------------------------------------------------------------------------
225236

226237
"""
227238
$SIGNATURES
228239
229-
Get solver data dictionary for a variable.
240+
Get solver data dictionary for a variable. Advised to use graph CRUD operations instead.
230241
"""
231242
getSolverDataDict(v::DFGVariable) = v.solverDataDict
232243

@@ -427,6 +438,9 @@ function mergeVariableSolverData!(destVariable::DFGVariable, sourceVariable::DFG
427438
return destVariable
428439
end
429440

441+
mergeVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable) = mergeVariableSolverData!(getVariable(dfg,getLabel(sourceVariable)), sourceVariable)
442+
443+
430444
##==============================================================================
431445
## Point Parametric Estimates
432446
##==============================================================================
@@ -478,7 +492,7 @@ addPPE!(dfg::AbstractDFG, sourceVariable::DFGVariable, ppekey::Symbol=:default)
478492

479493
"""
480494
$(SIGNATURES)
481-
Update PPE data if it exists, otherwise add it.
495+
Update PPE data if it exists, otherwise add it -- one call per `key::Symbol=:default`.
482496
"""
483497
function updatePPE!(dfg::AbstractDFG, variablekey::Symbol, ppe::P, ppekey::Symbol=:default)::P where P <: AbstractPointParametricEst
484498

@@ -539,7 +553,7 @@ deletePPE!(dfg::AbstractDFG, sourceVariable::DFGVariable, ppekey::Symbol=:defaul
539553
$(SIGNATURES)
540554
List all the PPE data keys in the variable.
541555
"""
542-
function listPPE(dfg::AbstractDFG, variablekey::Symbol)::Vector{Symbol}
556+
function listPPEs(dfg::AbstractDFG, variablekey::Symbol)::Vector{Symbol}
543557
v = getVariable(dfg, variablekey)
544558
return collect(keys(v.ppeDict))
545559
end

test/LightDFGSummaryTypes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040

4141
if VARTYPE == DFGVariableSummary
4242
@test getTimestamp(v1) == v1.timestamp
43-
@test getVariablePPEs(v1) == v1.ppeDict
43+
@test getVariablePPEDict(v1) == v1.ppeDict
4444
@test_throws KeyError getVariablePPE(v1, :notfound)
4545
@test getSofttypename(v1) == :Pose2
4646
@test getInternalId(v1) == v1._internalId

test/fileDFGTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using Test
4040

4141
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
4242
@info "Going to load $filename"
43-
retDFG = loadDFG(filename, Main, copyDfg, loaddir="/tmp")
43+
retDFG = loadDFG(filename, Main, copyDfg) #, loaddir="/tmp")
4444

4545
@test issetequal(ls(dfg), ls(retDFG))
4646
@test issetequal(lsf(dfg), lsf(retDFG))

test/iifInterfaceTests.jl

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ end
132132
@test @test_deprecated getFactorIds(dfg) == listFactors(dfg)
133133

134134

135-
@test @test_deprecated getfnctype(f1.solverData) === getFactorType(f1.solverData)
136-
@test @test_deprecated getfnctype(f1) === getFactorType(f1)
137-
@test @test_deprecated getfnctype(dfg, :abf1) === getFactorType(dfg, :abf1)
138-
139135
@test getFactorType(f1.solverData) === f1.solverData.fnc.usrfnc!
140136
@test getFactorType(f1) === f1.solverData.fnc.usrfnc!
141137
@test getFactorType(dfg, :abf1) === f1.solverData.fnc.usrfnc!
@@ -186,15 +182,15 @@ end
186182
@test getLabel(v1) == v1.label
187183
@test getTags(v1) == v1.tags
188184
@test getTimestamp(v1) == v1.timestamp
189-
@test getVariablePPEs(v1) == v1.ppeDict
185+
@test getVariablePPEDict(v1) == v1.ppeDict
190186
@test_throws Exception DistributedFactorGraphs.getVariablePPE(v1, :notfound)
191-
@test solverData(v1) === v1.solverDataDict[:default]
192187
@test getSolverData(v1) === v1.solverDataDict[:default]
193-
@test solverData(v1, :default) === v1.solverDataDict[:default]
188+
@test getSolverData(v1) === v1.solverDataDict[:default]
189+
@test getSolverData(v1, :default) === v1.solverDataDict[:default]
194190
@test getSolverDataDict(v1) == v1.solverDataDict
195191
@test getInternalId(v1) == v1._internalId
196192
# legacy compat test
197-
@test getVariablePPEs(v1) == v1.estimateDict # changed to .ppeDict -- delete by DFG v0.7
193+
@test getVariablePPEDict(v1) == v1.ppeDict # changed to .ppeDict -- delete by DFG v0.7
198194

199195

200196
@test typeof(getSofttype(v1)) == ContinuousScalar
@@ -203,10 +199,10 @@ end
203199

204200
@test getLabel(f1) == f1.label
205201
@test getTags(f1) == f1.tags
206-
@test solverData(f1) == f1.solverData
202+
@test getSolverData(f1) == f1.solverData
207203

208204
# Internal function
209-
@test @test_deprecated internalId(f1) == f1._internalId
205+
# @test @test_deprecated internalId(f1) == f1._internalId
210206

211207
@test getSolverParams(dfg) != nothing
212208
@test setSolverParams!(dfg, getSolverParams(dfg)) == getSolverParams(dfg)
@@ -284,42 +280,48 @@ end
284280
var1 = getVariable(dfg, :a)
285281
#make a copy and simulate external changes
286282
newvar = deepcopy(var1)
287-
getVariablePPEs(newvar)[:default] = MeanMaxPPE(:default, [150.0], [100.0], [50.0])
283+
getVariablePPEDict(newvar)[:default] = MeanMaxPPE(:default, [150.0], [100.0], [50.0])
288284
#update
289-
mergeUpdateVariableSolverData!(dfg, newvar)
285+
# mergeUpdateVariableSolverData!(dfg, newvar)
286+
# mergeVariableSolverData!(getVariable(dfg,getLabel(newvar)), newvar)
287+
# mergeVariableData!(getVariable(dfg,getLabel(newvar)), newvar)
288+
mergeVariableData!(dfg, newvar)
290289

291290
#Check if variable is updated
292291
var1 = getVariable(dfg, :a)
293-
@test getVariablePPEs(newvar) == getVariablePPEs(var1)
292+
@test getVariablePPEDict(newvar) == getVariablePPEDict(var1)
294293

295294
# Add a new estimate.
296-
getVariablePPEs(newvar)[:second] = MeanMaxPPE(:second, [15.0], [10.0], [5.0])
295+
getVariablePPEDict(newvar)[:second] = MeanMaxPPE(:second, [15.0], [10.0], [5.0])
297296

298297
# Confirm they're different
299-
@test getVariablePPEs(newvar) != getVariablePPEs(var1)
298+
@test getVariablePPEDict(newvar) != getVariablePPEDict(var1)
300299
# Persist it.
301-
mergeUpdateVariableSolverData!(dfg, newvar)
300+
# mergeUpdateVariableSolverData!(dfg, newvar)
301+
# mergeVariableSolverData!(getVariable(dfg, getLabel(newvar)), newvar)
302+
mergeVariableData!(dfg, newvar)
302303
# Get the latest
303304
var1 = getVariable(dfg, :a)
304-
@test symdiff(collect(keys(getVariablePPEs(var1))), [:default, :second]) == Symbol[]
305+
@test symdiff(collect(keys(getVariablePPEDict(var1))), [:default, :second]) == Symbol[]
305306

306307
#Check if variable is updated
307-
@test getVariablePPEs(newvar) == getVariablePPEs(var1)
308+
@test getVariablePPEDict(newvar) == getVariablePPEDict(var1)
308309

309310

310311
# Delete :default and replace to see if new ones can be added
311-
delete!(getVariablePPEs(newvar), :default)
312+
delete!(getVariablePPEDict(newvar), :default)
312313
#confirm delete
313-
@test symdiff(collect(keys(getVariablePPEs(newvar))), [:second]) == Symbol[]
314-
# Persist it.
315-
mergeUpdateVariableSolverData!(dfg, newvar)
314+
@test symdiff(collect(keys(getVariablePPEDict(newvar))), [:second]) == Symbol[]
315+
# Persist it., and test
316+
mergeVariableData!(dfg, newvar)
317+
# mergeUpdateVariableSolverData!(dfg, newvar) #357 #358
316318

317319
# Get the latest and confirm they're the same, :second
318320
var1 = getVariable(dfg, :a)
319321

320322
# TODO issue #166
321-
@test getVariablePPEs(newvar) != getVariablePPEs(var1)
322-
@test collect(keys(getVariablePPEs(var1))) == [:default, :second]
323+
@test getVariablePPEDict(newvar) != getVariablePPEDict(var1)
324+
@test collect(keys(getVariablePPEDict(var1))) == [:default, :second]
323325

324326
# @test symdiff(collect(keys(getVariablePPE(getVariable(dfg, :a)))), [:default, :second]) == Symbol[]
325327
end
@@ -395,7 +397,7 @@ verts = map(n -> addVariable!(dfg, Symbol("x$n"), ContinuousScalar, labels = [:P
395397
#TODO fix this to use accessors
396398
setSolvable!(verts[7], 1)
397399
setSolvable!(verts[8], 0)
398-
solverData(verts[8]).solveInProgress = 1
400+
getSolverData(verts[8]).solveInProgress = 1
399401
#call update to set it on cloud
400402
updateVariable!(dfg, verts[7])
401403
updateVariable!(dfg, verts[8])

0 commit comments

Comments
 (0)