Skip to content

Commit 5367d43

Browse files
authored
Restore IIF tests and some fixes (#972)
* Restore IIF tests and some fixes * update deprecated addDataEntry * Fix compare and update fildDFG regression tests * Skip more in compare tests
1 parent d5c3a7d commit 5367d43

File tree

9 files changed

+92
-45
lines changed

9 files changed

+92
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
5959
- name: Run tests
6060
env:
61-
IIF_TEST: false
61+
IIF_TEST: true
6262
DO_CGDFG_TESTS: false
6363
DFG_USE_CGDFG: false
6464
uses: julia-actions/julia-runtest@latest

src/Deprecated.jl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,37 @@ Abstract parent struct for big data entry.
1111
abstract type AbstractBlobEntry end
1212

1313
# should be deprecated by v0.21
14-
export BlobStoreEntry
15-
const BlobStoreEntry = BlobEntry
14+
15+
@deprecate BlobStoreEntry(
16+
label::Symbol,
17+
id::UUID,
18+
blobstore::Symbol,
19+
hash::String,
20+
origin::String,
21+
description::String,
22+
mimeType::String,
23+
createdTimestamp::ZonedDateTime) BlobEntry(;
24+
originId=id,
25+
label,
26+
blobstore,
27+
hash,
28+
origin,
29+
description,
30+
mimeType,
31+
)
32+
1633

1734
@deprecate hasDataEntry(w...;kw...) hasBlobEntry(w...;kw...)
18-
@deprecate getBlobEntry(w...;kw...) getBlobEntry(w...;kw...)
35+
@deprecate getDataEntry(w...;kw...) getBlobEntry(w...;kw...)
36+
@deprecate getDataEntries(w...;kw...) getBlobEntries(w...;kw...)
1937
@deprecate addDataEntry!(w...;kw...) addBlobEntry!(w...;kw...)
2038
@deprecate updateDataEntry!(w...;kw...) updateBlobEntry!(w...;kw...)
2139
@deprecate deleteDataEntry!(w...;kw...) deleteBlobEntry!(w...;kw...)
2240
@deprecate listDataEntry(w...;kw...) listBlobEntry(w...;kw...)
2341
@deprecate listDataEntrySequence(w...;kw...) listBlobEntrySequence(w...;kw...)
2442
@deprecate mergeDataEntry!(w...;kw...) mergeBlobEntry!(w...;kw...)
2543

26-
@deprecate getData(w...;kw...) getBlob(w...;kw...)
44+
# @deprecate getData(w...;kw...) getBlob(w...;kw...)
2745
@deprecate getDataBlob(w...;kw...) getBlob(w...;kw...)
2846
@deprecate addDataBlob!(w...;kw...) addBlob!(w...;kw...)
2947
@deprecate updateDataBlob!(w...;kw...) updateBlob!(w...;kw...)

src/services/CompareUtils.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ function compareField(Allc, Bllc, syms)::Bool
3737
(!isdefined(Allc, syms) && !isdefined(Bllc, syms)) && return true
3838
!isdefined(Allc, syms) && return false
3939
!isdefined(Bllc, syms) && return false
40-
return eval(:($Allc.$syms == $Bllc.$syms))
40+
a = getproperty(Allc, syms)
41+
b = getproperty(Bllc, syms)
42+
if a isa Base.RefValue
43+
return a[] == b[]
44+
else
45+
return a == b
46+
end
4147
end
4248

4349
"""
@@ -57,6 +63,7 @@ function compareFields( Al::T1,
5763
(field in skip) && continue
5864
tp = compareField(Al, Bl, field)
5965
show && @debug(" $tp : $field") === nothing
66+
show && !tp && (@debug " $field" a=getproperty(Al,field) b=getproperty(Bl,field))
6067
!tp && return false
6168
end
6269
return true
@@ -414,7 +421,7 @@ function compareFactorGraphs( fgA::G1,
414421

415422
TP = compareAll(fgA, fgB, skip=skiplist, show=show)
416423
TP = TP && compareSimilarVariables(fgA, fgB, skipsamples=skipsamples, show=show, skip=skiplist )
417-
TP = TP && compareSimilarFactors(fgA, fgB, skipsamples=skipsamples, skipcompute=skipcompute, show=show )
424+
TP = TP && compareSimilarFactors(fgA, fgB, skipsamples=skipsamples, skipcompute=skipcompute, show=show, skip=skiplist )
418425
TP = TP && compareAll(fgA.solverParams, fgB.solverParams, skip=skiplist)
419426

420427
return TP

src/services/Serialization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function packVariable(v::AbstractDFGVariable; includePPEs::Bool=true, includeSol
159159
solvable = v.solvable,
160160
variableType = DFG.typeModuleName(DFG.getVariableType(v)),
161161
dataEntries = collect(values(v.dataDict)),
162-
_version = DFG._getDFGVersion())
162+
_version = string(DFG._getDFGVersion()))
163163
end
164164

165165
function unpackVariable(variable::PackedVariable; skipVersionCheck::Bool=false)

test/data/0_20_0.tar.gz

1.61 KB
Binary file not shown.
File renamed without changes.

test/fileDFGTests.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using DistributedFactorGraphs
22
using IncrementalInference
33
using Test
44
using TimeZones
5-
5+
using UUIDs
66
##
77

88
@testset "FileDFG Tests" begin
@@ -20,12 +20,12 @@ using TimeZones
2020
map(v -> setSolvedCount!(v, Int(round(10*rand()))), verts)
2121

2222
# Add some data entries
23-
map(v -> addDataEntry!(v, BlobStoreEntry(:testing, uuid4(), :store, "", "", "", "", now(localzone()))), verts)
24-
map(v -> addDataEntry!(v, BlobStoreEntry(:testing2, uuid4(), :store, "", "", "", "", ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"))), verts)
23+
map(v -> addBlobEntry!(v, BlobEntry(nothing, nothing, uuid4(), :testing, :store, "", "", "", "", "", now(localzone()), "BlobEntry", string(DFG._getDFGVersion()))), verts)
24+
map(v -> addBlobEntry!(v, BlobEntry(nothing, nothing, uuid4(), :testing2, :store, "", "", "", "", "", ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"), "BlobEntry", string(DFG._getDFGVersion()))), verts)
2525

2626
# Add some PPEs
2727
ppe1 = MeanMaxPPE(:default, [1.0], [0.2], [3.456])
28-
ppe2 = MeanMaxPPE(:other, [1.0], [0.2], [3.456], ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"))
28+
ppe2 = MeanMaxPPE(;solveKey=:other, suggested=[1.0], mean=[0.2], max=[3.456], createdTimestamp=ZonedDateTime(2014, 5, 30, 21, tz"UTC-4"))
2929
map(v -> addPPE!(dfg, getLabel(v), deepcopy(ppe1)), verts)
3030
map(v -> addPPE!(dfg, getLabel(v), deepcopy(ppe2)), verts)
3131

@@ -67,7 +67,7 @@ using TimeZones
6767

6868
# Check data entries
6969
for v in ls(dfg)
70-
@test getDataEntries(getVariable(dfg, v)) == getDataEntries(getVariable(retDFG, v))
70+
@test getBlobEntries(getVariable(dfg, v)) == getBlobEntries(getVariable(retDFG, v))
7171
@test issetequal(listPPEs(dfg, v), listPPEs(retDFG, v))
7272
for ppe in listPPEs(dfg, v)
7373
@test getPPE(dfg, v, ppe) == getPPE(retDFG, v, ppe)
@@ -87,11 +87,11 @@ end
8787
loadFile = joinpath(@__DIR__, "data", file)
8888
global dfg
8989
dfgCopy = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
90-
retDFG = loadDFG!(dfgCopy, loadFile)
90+
retDFG = loadDFG!(dfgCopy, loadFile)
9191
# It should have failed if there were any issues.
9292
# Trivial check as well
9393
@test issetequal(ls(retDFG), [:x1, :x2, :x3, :x4, :x5])
94-
@test issetequal(lsf(retDFG), [:x3x4f1, :x4x5f1, :x1x2f1, :x2x3f1])
94+
@test issetequal(lsf(retDFG), [:x3x4f1, :x4x5f1, :x1x2f1, :x2x3f1, :x1x2x3f1])
9595
end
9696
end
9797

test/iifCompareTests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ using Test
5252

5353
initAll!(fg2)
5454

55-
@test compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim;:ppeDict;:solvedCount])
55+
@test compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:infoPerCoord;:initialized;:inferdim;:ppeDict;:solvedCount])
5656
# fg2 has been solved, so it should fail on the estimate dictionary
5757
@test !compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim])
5858

5959
tree = buildTreeReset!(fg2)
6060

61-
@test compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=true)
61+
@test compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=true, skip=[:fullvariables])
6262

6363
@test !compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=false)
6464

65-
@test compareFactorGraphs(fg, fg2, skipsamples=true, skipcompute=true, skip=[:initialized;:inferdim;:ppeDict; :solvedCount])
65+
@test compareFactorGraphs(fg, fg2, skipsamples=true, skipcompute=true, skip=[:fullvariables; :infoPerCoord; :initialized; :inferdim; :ppeDict; :solvedCount])
6666

6767
end
6868

test/iifInterfaceTests.jl

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -212,48 +212,70 @@ end
212212
end
213213

214214
@testset "Data Entries" begin
215-
oid = zeros(UInt8,12); oid[12] = 0x01
216-
de1 = MongodbDataEntry(:key1, uuid4(), NTuple{12,UInt8}(oid), "", now(localzone()))
217-
218-
oid = zeros(UInt8,12); oid[12] = 0x02
219-
de2 = MongodbDataEntry(:key2, uuid4(), NTuple{12,UInt8}(oid), "", now(localzone()))
220-
221-
oid = zeros(UInt8,12); oid[12] = 0x03
222-
de2_update = MongodbDataEntry(:key2, uuid4(), NTuple{12,UInt8}(oid), "", now(localzone()))
215+
216+
de1 = BlobEntry(
217+
originId = uuid4(),
218+
label = :key1,
219+
blobstore = :test,
220+
hash = "",
221+
origin = "",
222+
description = "",
223+
mimeType = ""
224+
)
225+
226+
de2 = BlobEntry(
227+
originId = uuid4(),
228+
label = :key2,
229+
blobstore = :test,
230+
hash = "",
231+
origin = "",
232+
description = "",
233+
mimeType = ""
234+
)
235+
236+
de2_update = BlobEntry(
237+
originId = uuid4(),
238+
label = :key2,
239+
blobstore = :test,
240+
hash = "",
241+
origin = "",
242+
description = "",
243+
mimeType = "image/jpg"
244+
)
223245

224246
#add
225247
v1 = getVariable(dfg, :a)
226-
@test addDataEntry!(v1, de1) == de1
227-
@test addDataEntry!(dfg, :a, de2) == de2
228-
@test_throws ErrorException addDataEntry!(v1, de1)
229-
@test de2 in getDataEntries(v1)
248+
@test addBlobEntry!(v1, de1) == de1
249+
@test addBlobEntry!(dfg, :a, de2) == de2
250+
@test_throws ErrorException addBlobEntry!(v1, de1)
251+
@test de2 in getBlobEntries(v1)
230252

231253
#get
232-
@test deepcopy(de1) == getDataEntry(v1, :key1)
233-
@test deepcopy(de2) == getDataEntry(dfg, :a, :key2)
234-
@test_throws ErrorException getDataEntry(v2, :key1)
235-
@test_throws ErrorException getDataEntry(dfg, :b, :key1)
254+
@test deepcopy(de1) == getBlobEntry(v1, :key1)
255+
@test deepcopy(de2) == getBlobEntry(dfg, :a, :key2)
256+
@test_throws ErrorException getBlobEntry(v2, :key1)
257+
@test_throws ErrorException getBlobEntry(dfg, :b, :key1)
236258

237259
#update
238-
@test updateDataEntry!(dfg, :a, de2_update) == de2_update
239-
@test deepcopy(de2_update) == getDataEntry(dfg, :a, :key2)
240-
@test @test_logs (:warn, r"does not exist") match_mode=:any updateDataEntry!(dfg, :b, de2_update) == de2_update
260+
@test updateBlobEntry!(dfg, :a, de2_update) == de2_update
261+
@test deepcopy(de2_update) == getBlobEntry(dfg, :a, :key2)
262+
@test @test_logs (:warn, r"does not exist") match_mode=:any updateBlobEntry!(dfg, :b, de2_update) == de2_update
241263

242264
#list
243-
entries = getDataEntries(dfg, :a)
265+
entries = getBlobEntries(dfg, :a)
244266
@test length(entries) == 2
245267
@test issetequal(map(e->e.label, entries), [:key1, :key2])
246-
@test length(getDataEntries(dfg, :b)) == 1
268+
@test length(getBlobEntries(dfg, :b)) == 1
247269

248-
@test issetequal(listDataEntries(dfg, :a), [:key1, :key2])
249-
@test listDataEntries(dfg, :b) == Symbol[:key2]
270+
@test issetequal(listBlobEntries(dfg, :a), [:key1, :key2])
271+
@test listBlobEntries(dfg, :b) == Symbol[:key2]
250272

251273
#delete
252-
@test deleteDataEntry!(v1, :key1) == de1
253-
@test listDataEntries(v1) == Symbol[:key2]
274+
@test deleteBlobEntry!(v1, :key1) == de1
275+
@test listBlobEntries(v1) == Symbol[:key2]
254276
#delete from ddfg
255-
@test deleteDataEntry!(dfg, :a, :key2) == de2_update
256-
@test listDataEntries(v1) == Symbol[]
277+
@test deleteBlobEntry!(dfg, :a, :key2) == de2_update
278+
@test listBlobEntries(v1) == Symbol[]
257279
end
258280

259281
@testset "Updating Nodes and Estimates" begin

0 commit comments

Comments
 (0)