Skip to content

Commit 05d16ac

Browse files
committed
Some automatic session ids and tests
1 parent 9b33394 commit 05d16ac

File tree

3 files changed

+43
-24
lines changed

3 files changed

+43
-24
lines changed

src/services/AbstractDFG.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,16 @@ function deepcopyGraph(::Type{T},
877877
sourceDFG::AbstractDFG,
878878
variableLabels::Vector{Symbol} = ls(sourceDFG),
879879
factorLabels::Vector{Symbol} = lsf(sourceDFG);
880+
sessionId::String = "",
880881
kwargs...) where T <: AbstractDFG
881-
destDFG = T(getDFGInfo(sourceDFG)...)
882+
883+
ginfo = [getDFGInfo(sourceDFG)...]
884+
if sessionId == ""
885+
ginfo[4] *= "_copy$(string(uuid4())[1:6])"
886+
else
887+
ginfo[4] = sessionId
888+
end
889+
destDFG = T(ginfo...)
882890
copyGraph!(destDFG, sourceDFG, variableLabels, factorLabels; deepcopyNodes=true, kwargs...)
883891
return destDFG
884892
end

test/consolInterfaceDev.jl

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Neo4j
44
using DistributedFactorGraphs
55
using Pkg
66
using Dates
7-
7+
using UUIDs
88
# using IncrementalInference
99

1010
include("testBlocks.jl")
@@ -15,14 +15,20 @@ testDFGAPI = CloudGraphsDFG
1515
# TODO maybe move to cloud graphs permanantly as standard easy to use functions
1616
function DFG.CloudGraphsDFG(; params=NoSolverParams())
1717
cgfg = CloudGraphsDFG{typeof(params)}("localhost", 7474, "neo4j", "test",
18-
"testUser", "testRobot", "testSession",
18+
"testUser", "testRobot", "testSession_$(string(uuid4())[1:6])",
1919
"description",
2020
nothing,
2121
nothing,
22-
(dfg,f)->f,#IncrementalInference.decodePackedType,#(dfg,f)->f,
23-
(dfg,f)->f,#ncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
22+
(dfg,f)->f,#IncrementalInference.decodePackedType,
23+
(dfg,f)->f,#ncrementalInference.rebuildFactorMetadata!,
2424
solverParams=params)
2525
createDfgSessionIfNotExist(cgfg)
26+
27+
setUserData!(cgfg, Dict{Symbol, String}())
28+
setRobotData!(cgfg, Dict{Symbol, String}())
29+
setSessionData!(cgfg, Dict{Symbol, String}())
30+
setDescription!(cgfg, cgfg.description)
31+
2632
return cgfg
2733
end
2834

@@ -49,8 +55,8 @@ function DFG.CloudGraphsDFG(description::String,
4955
description,
5056
nothing,
5157
nothing,
52-
(dfg,f)->f,#IncrementalInference.decodePackedType,#(dfg,f)->f,
53-
(dfg,f)->f,#IncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
58+
(dfg,f)->f,#IncrementalInference.decodePackedType,
59+
(dfg,f)->f,#IncrementalInference.rebuildFactorMetadata!,
5460
solverParams=solverParams)
5561

5662
createDfgSessionIfNotExist(cdfg)
@@ -119,7 +125,7 @@ end
119125

120126
@testset "Adjacency Matrices" begin
121127
fg = testDFGAPI()
122-
clearRobot!!(fg)
128+
clearUser!!(fg)
123129

124130
DFGVariable(:a, TestSofttype1())
125131
addVariable!(fg, var1)
@@ -133,17 +139,23 @@ end
133139

134140

135141
@testset "Getting Neighbors" begin
142+
fg = testDFGAPI()
143+
clearUser!!(fg)
136144
GettingNeighbors(testDFGAPI)
137145
end
138146

139147

140148
@testset "Getting Subgraphs" begin
149+
fg = testDFGAPI()
150+
clearUser!!(fg)
141151
GettingSubgraphs(testDFGAPI)
142152
end
143153

144-
# @testset "Building Subgraphs" begin
145-
# BuildingSubgraphs(testDFGAPI)
146-
# end
154+
@testset "Building Subgraphs" begin
155+
fg = testDFGAPI()
156+
clearUser!!(fg)
157+
BuildingSubgraphs(testDFGAPI)
158+
end
147159
#
148160
# #TODO Summaries and Summary Graphs
149161
# @testset "Summaries and Summary Graphs" begin
@@ -160,11 +172,12 @@ end
160172

161173

162174
#
163-
#
164-
# fg = fg1
165-
# v1 = var1
166-
# v2 = var2
167-
# v3 = var3
168-
# f0 = fac0
169-
# f1 = fac1
170-
# f2 = fac2
175+
#=
176+
fg = fg1
177+
v1 = var1
178+
v2 = var2
179+
v3 = var3
180+
f0 = fac0
181+
f1 = fac1
182+
f2 = fac2
183+
=#

test/testBlocks.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,10 @@ function testGroup!(fg, v1, v2, f0, f1)
820820
@test_skip varNearTs[1][1] == [:b]
821821

822822
## SORT copied from CRUD
823-
@test all(getVariables(fg, r"a") .== [v1])
824-
@test all(getVariables(fg, solvable=1) .== [v2])
823+
@test all(getVariables(fg, r"a") .== [getVariable(fg,v1.label)])
824+
@test all(getVariables(fg, solvable=1) .== [getVariable(fg,v2.label)])
825825
@test getVariables(fg, r"a", solvable=1) == []
826-
@test getVariables(fg, tags=[:LANDMARK])[1] == v2
826+
@test getVariables(fg, tags=[:LANDMARK])[1] == getVariable(fg, v2.label)
827827

828828
@test getFactors(fg, r"nope") == []
829829
@test issetequal(getLabel.(getFactors(fg, solvable=1)), [:af1, :abf1])
@@ -980,8 +980,6 @@ function connectivityTestGraph(::Type{T}; VARTYPE=DFGVariable, FACTYPE=DFGFactor
980980

981981
dfg = T()
982982

983-
isa(dfg, CloudGraphsDFG) && clearUser!!(dfg)
984-
985983
vars = vcat(map(n -> VARTYPE(Symbol("x$n"), VariableNodeData{TestSofttype1}()), 1:numNodesType1),
986984
map(n -> VARTYPE(Symbol("x$(numNodesType1+n)"), VariableNodeData{TestSofttype2}()), 1:numNodesType2))
987985

0 commit comments

Comments
 (0)