Skip to content

Commit a37d004

Browse files
authored
Standardize and test cloud graph variable and factor crud (#412)
* apt-get neo4j:3.5 * Variable and Factor CRUD and test (un)packing * decodePackedType only when not running iif
1 parent ca4b9af commit a37d004

File tree

8 files changed

+209
-69
lines changed

8 files changed

+209
-69
lines changed

.travis.yml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: julia
22
sudo: required
3-
# dist: trusty
43

54
os:
65
- linux
@@ -12,7 +11,6 @@ services:
1211
- neo4j
1312

1413
julia:
15-
- 1.2
1614
- 1.4
1715
- nightly
1816

@@ -21,17 +19,12 @@ env:
2119

2220
jobs:
2321
include:
24-
- julia: 1.3
25-
dist: trusty
22+
- julia: 1.4
2623
env: IIF_TEST=true
2724
if: NOT branch =~ ^release.*$
28-
# Set the password for Neo4j to neo4j:test
29-
before_script:
30-
- sleep 10
31-
- curl -v POST http://neo4j:neo4j@localhost:7474/user/neo4j/password -d"password=test"
3225
- arch: arm64
3326
- stage: "Documentation"
34-
julia: 1.3
27+
julia: 1.4
3528
os: linux
3629
script:
3730
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
@@ -41,26 +34,24 @@ jobs:
4134
allow_failures:
4235
- julia: nightly
4336
- arch: arm64
44-
#- env: IIF_TEST=true
4537

4638
notifications:
4739
email: false
4840

49-
5041
# Attempt to install neo4j on Xenial and set the password for Neo4j to neo4j:test
51-
# Cloud tests errors with authentication error
52-
#before_script:
53-
# - sudo add-apt-repository -y ppa:openjdk-r/ppa
54-
# - sudo apt-get update
55-
# - wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
56-
# - echo 'deb https://debian.neo4j.com stable latest' | sudo tee -a /etc/apt/sources.list.d/neo4j.list
57-
# - sudo apt-get update
58-
# - apt list -a neo4j
59-
# - sudo apt-get install neo4j=1:4.0.0
60-
# - sudo service neo4j start
61-
# - sleep 10
62-
# - sudo neo4j-admin set-initial-password test
63-
# - curl -I http://localhost:7474/
42+
before_script:
43+
- sudo add-apt-repository -y ppa:openjdk-r/ppa
44+
- sudo apt-get update
45+
- wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
46+
- echo 'deb https://debian.neo4j.com stable 3.5' | sudo tee /etc/apt/sources.list.d/neo4j.list
47+
- sudo apt-get update
48+
- apt list -a neo4j
49+
- sudo apt-get install neo4j
50+
- sudo service neo4j start
51+
- sleep 10
52+
- curl -v POST http://neo4j:neo4j@localhost:7474/user/neo4j/password -d"password=test"
53+
# - sudo neo4j-admin set-initial-password test
54+
- curl -I http://localhost:7474/
6455

6556
after_success:
6657
- julia -e 'using Pkg; cd(Pkg.dir("DistributedFactorGraphs")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ function getNeighbors(dfg::CloudGraphsDFG, node::T; solvable::Int=0)::Vector{Sym
400400
query = "(n:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId):$(node.label))--(node) where (node:VARIABLE or node:FACTOR) and node.solvable >= $solvable"
401401
@debug "[Query] $query"
402402
neighbors = _getLabelsFromCyphonQuery(dfg.neo4jInstance, query)
403-
# If factor, need to do variable ordering
403+
# If factor, need to do variable ordering TODO, Do we? does it matter if we always use _variableOrderSymbols in calculations?
404404
if T <: DFGFactor
405405
neighbors = intersect(node._variableOrderSymbols, neighbors)
406406
end
@@ -411,7 +411,7 @@ function getNeighbors(dfg::CloudGraphsDFG, label::Symbol; solvable::Int=0)::Vect
411411
query = "(n:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId):$(label))--(node) where (node:VARIABLE or node:FACTOR) and node.solvable >= $solvable"
412412
@debug "[Query] $query"
413413
neighbors = _getLabelsFromCyphonQuery(dfg.neo4jInstance, query)
414-
# If factor, need to do variable ordering
414+
# If factor, need to do variable ordering TODO, Do we? does it matter if we always use _variableOrderSymbols in calculations?
415415
if isFactor(dfg, label)
416416
# Server is authority
417417
serverOrder = Symbol.(JSON2.read(_getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, dfg.sessionId, String(label)], "_variableOrderSymbols")))

src/entities/DFGFactor.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ abstract type PackedInferenceType end
77

88
abstract type FunctorInferenceType <: Function end
99

10+
# DF suggestion1 (this is a first guess) `ConvolutionObject` --> `FactorInsituObject`
11+
# DF second guess, ConvolutionObject <: FactorInsituObject
12+
# JT Maybe second guess as intermediate step where ConvolutionObject is moved to IIF.
13+
# then it can be removed to CommonConvWrapper <: FactorInsituObject
14+
15+
# DF, Convolution is IIF idea, but DFG should know about "FactorOperationalMemory"
16+
# DF, IIF.CommonConvWrapper <: FactorOperationalMemory # FIXME
17+
# MAYBE rename "FactorOperationalMemory"
1018
abstract type ConvolutionObject <: Function end
1119

1220
abstract type FunctorSingleton <: FunctorInferenceType end
@@ -19,13 +27,22 @@ abstract type FunctorPairwiseMinimize <: FunctorInferenceType end
1927

2028
"""
2129
$(TYPEDEF)
30+
31+
Notes
32+
- S::Symbol
33+
34+
Designing (WIP)
35+
- T <: Union{FactorOperationalMemory, PackedInferenceType}
36+
# in IIF.CCW{T <: DFG.InferenceType}
37+
# in IIF.FunctorPairwiseMinimize <: InferenceType # DFG whatever, something, we'll figure it out
38+
# in Main/User, SomeFactor <: FunctorPairwiseMinimize
2239
"""
23-
mutable struct GenericFunctionNodeData{T, S}
40+
mutable struct GenericFunctionNodeData{T, S} #{T<:Union{PackedInferenceType, FunctorInferenceType, ConvolutionObject}, S<:Union{Symbol, AbstractString}}
2441
fncargvID::Vector{Symbol}
2542
eliminated::Bool
2643
potentialused::Bool
2744
edgeIDs::Array{Int,1}
28-
frommodule::S #Union{Symbol, AbstractString}
45+
frommodule::S # JT TODO remove frommodule, not used at all as far as i can tell
2946
fnc::T
3047
multihypo::Array{Float64} # likely to moved when GenericWrapParam is refactored
3148
certainhypo::Vector{Int}

src/services/Serialization.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G
146146
solvable = packedProps["solvable"]
147147

148148
# Rebuild DFGFactor
149+
#TODO use constuctor to create factor
149150
factor = DFGFactor{typeof(fullFactor.fnc), Symbol}(Symbol(label), 0, timestamp)
150151

151152
union!(factor.tags, tags)
152-
# factor.data = fullFactor #TODO
153+
# factor.data = fullFactor #TODO
153154
setSolverData!(factor, fullFactor)
154155
factor._variableOrderSymbols = _variableOrderSymbols
155156
setSolvable!(factor, solvable)

test/consolInterfaceDev.jl

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using DistributedFactorGraphs
55
using Pkg
66
using Dates
77

8-
using IncrementalInference
8+
# using IncrementalInference
99

1010
include("testBlocks.jl")
1111

@@ -19,8 +19,8 @@ function DFG.CloudGraphsDFG(; params=NoSolverParams())
1919
"description",
2020
nothing,
2121
nothing,
22-
IncrementalInference.decodePackedType,#(dfg,f)->f,
23-
IncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
22+
(dfg,f)->f,#IncrementalInference.decodePackedType,#(dfg,f)->f,
23+
(dfg,f)->f,#ncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
2424
solverParams=params)
2525
createDfgSessionIfNotExist(cgfg)
2626
return cgfg
@@ -49,8 +49,8 @@ function DFG.CloudGraphsDFG(description::String,
4949
description,
5050
nothing,
5151
nothing,
52-
IncrementalInference.decodePackedType,#(dfg,f)->f,
53-
IncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
52+
(dfg,f)->f,#IncrementalInference.decodePackedType,#(dfg,f)->f,
53+
(dfg,f)->f,#IncrementalInference.rebuildFactorMetadata!,#(dfg,f)->f,
5454
solverParams=solverParams)
5555

5656
createDfgSessionIfNotExist(cdfg)
@@ -82,25 +82,15 @@ end
8282
end
8383

8484
# DFGVariable structure construction and accessors
85-
# @testset "DFG Variable" begin
86-
# global var1, var2, var3, v1_tags
87-
# var1, var2, var3, v1_tags = DFGVariableSCA()
88-
# end
89-
newfg = initfg()
90-
var1 = addVariable!(newfg, :a, ContinuousScalar, labels=[:POSE])
91-
var2 = addVariable!(newfg, :b, ContinuousScalar, labels=[:LANDMARK])
92-
var3 = addVariable!(newfg, :c, ContinuousScalar)
93-
v1_tags = Set([:VARIABLE, :POSE])
94-
85+
@testset "DFG Variable" begin
86+
global var1, var2, var3, v1_tags, vorphan
87+
var1, var2, var3, vorphan, v1_tags = DFGVariableSCA()
88+
end
9589

9690
# DFGFactor structure construction and accessors
97-
# @testset "DFG Factor" begin
98-
# global fac0, fac1, fac2 = DFGFactorSCA()
99-
# end
100-
101-
fac0 = addFactor!(newfg, [:a], Prior(Normal()))
102-
fac1 = addFactor!(newfg, [:a, :b], LinearConditional(Normal()))
103-
fac2 = addFactor!(newfg, [:b, :c], LinearConditional(Normal()))
91+
@testset "DFG Factor" begin
92+
global fac0, fac1, fac2 = DFGFactorSCA()
93+
end
10494

10595
@testset "Variables and Factors CRUD and SET" begin
10696
VariablesandFactorsCRUD_SET!(fg1, var1, var2, var3, fac0, fac1, fac2)
@@ -109,6 +99,66 @@ end
10999
@testset "tags" begin
110100
tagsTestBlock!(fg1, var1, v1_tags)
111101
end
102+
103+
# @testset "Parametric Point Estimates" begin
104+
# PPETestBlock!(fg1, var1)
105+
# end
106+
107+
@testset "Variable Solver Data" begin
108+
VSDTestBlock!(fg1, var1)
109+
end
110+
111+
@testset "BigData Entries" begin
112+
@test_skip BigDataEntriesTestBlock!(fg1, var2)
113+
end
114+
115+
# @testset "TODO Sorteer groep" begin
116+
# testGroup!(fg1, var1, var2, fac0, fac1)
117+
# end
118+
119+
120+
@testset "Adjacency Matrices" begin
121+
fg = testDFGAPI()
122+
clearRobot!!(fg)
123+
124+
DFGVariable(:a, TestSofttype1())
125+
addVariable!(fg, var1)
126+
setSolvable!(fg, :a, 1)
127+
addVariable!(fg, var2)
128+
addFactor!(fg, fac1)
129+
addVariable!(fg, vorphan)
130+
131+
AdjacencyMatricesTestBlock(fg)
132+
end
133+
134+
135+
@testset "Getting Neighbors" begin
136+
GettingNeighbors(testDFGAPI)
137+
end
138+
139+
140+
@testset "Getting Subgraphs" begin
141+
GettingSubgraphs(testDFGAPI)
142+
end
143+
144+
# @testset "Building Subgraphs" begin
145+
# BuildingSubgraphs(testDFGAPI)
146+
# end
147+
#
148+
# #TODO Summaries and Summary Graphs
149+
# @testset "Summaries and Summary Graphs" begin
150+
# Summaries(testDFGAPI)
151+
# end
152+
#
153+
# @testset "Producing Dot Files" begin
154+
# ProducingDotFiles(testDFGAPI)
155+
# end
156+
#
157+
# @testset "Connectivity Test" begin
158+
# ConnectivityTest(testDFGAPI)
159+
# end
160+
161+
112162
#
113163
#
114164
# fg = fg1

test/interfaceTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414
# DFGVariable structure construction and accessors
1515
@testset "DFG Variable" begin
1616
global var1, var2, var3, v1_tags
17-
var1, var2, var3, v1_tags = DFGVariableSCA()
17+
var1, var2, var3, vorphan, v1_tags = DFGVariableSCA()
1818
end
1919

2020
# DFGFactor structure construction and accessors

test/runtests.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ for api in apis
4040
end
4141
end
4242

43+
if get(ENV, "IIF_TEST", "") != "true"
44+
@testset "Consolidation WIP Testing Driver: CloudGraphsDFG" begin
45+
global decodePackedType
46+
function decodePackedType(dfg::G, packeddata::GenericFunctionNodeData{PT,<:AbstractString}) where {PT, G <: AbstractDFG}
47+
# usrtyp = convert(FunctorInferenceType, packeddata.fnc)
48+
# Also look at parentmodule
49+
usrtyp = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
50+
fulltype = DFG.FunctionNodeData{TestCCW{usrtyp}}
51+
factor = convert(fulltype, packeddata)
52+
return factor
53+
end
54+
@info "Testing Driver: CloudGraphsDFG"
55+
global testDFGAPI = CloudGraphsDFG
56+
include("consolInterfaceDev.jl")
57+
end
58+
end
4359

4460
# Test special cases
4561
@testset "Plotting Tests" begin
@@ -76,12 +92,6 @@ if get(ENV, "IIF_TEST", "") == "true"
7692

7793
using IncrementalInference
7894

79-
@testset "Consolidation WIP Testing Driver: CloudGraphsDFG" begin
80-
@info "Testing Driver: CloudGraphsDFG"
81-
global testDFGAPI = CloudGraphsDFG
82-
include("consolInterfaceDev.jl")
83-
end
84-
8595
apis = [
8696
GraphsDFG{SolverParams}(),
8797
LightDFG{SolverParams}(),

0 commit comments

Comments
 (0)