Skip to content

Commit 9fd1b28

Browse files
authored
Merge pull request #173 from JuliaRobotics/backport/v04_2_cgdfg
Backport of the CGDFG code and unit tests
2 parents b352b1c + c2ef385 commit 9fd1b28

File tree

21 files changed

+888
-256
lines changed

21 files changed

+888
-256
lines changed

.travis.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
language: julia
2+
sudo: required
3+
dist: trusty
24

35
os:
46
- linux
@@ -13,37 +15,35 @@ julia:
1315
- 1.3
1416
- nightly
1517

16-
notifications:
17-
email: false
18-
19-
matrix:
20-
allow_failures:
21-
- julia: nightly
22-
23-
# script:
24-
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
25-
# - julia --project --check-bounds=yes -e 'using UUIDs; write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"$(uuid4())\"\n"));
26-
# import Pkg; Pkg.build("DistributedFactorGraphs"); Pkg.test("DistributedFactorGraphs"; coverage=true)'
27-
28-
# script:
29-
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
30-
# - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("DistributedFactorGraphs"); Pkg.test("DistributedFactorGraphs"; coverage=true)'
31-
32-
# can be used if master of package is required
33-
# script:
34-
# - julia --project --color=yes --check-bounds=yes -e 'using Pkg; Pkg.add(PackageSpec(name="MetaGraphs", rev="master")); Pkg.build(); Pkg.test(coverage=true)'
35-
36-
after_success:
37-
- julia -e 'using Pkg; cd(Pkg.dir("DistributedFactorGraphs")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder()); Coveralls.submit(process_folder())'
18+
env:
19+
- IIF_TEST=false
3820

3921
jobs:
4022
include:
23+
- julia: 1.2
24+
env: IIF_TEST=true
4125
- stage: "Documentation"
4226
julia: 1.0
4327
os: linux
4428
script:
45-
- julia -e 'import Pkg; Pkg.add("Documenter"); Pkg.add("DataFrames")'
29+
- julia -e 'import Pkg; Pkg.add("Documenter"); Pkg.add("Neo4j"); Pkg.add("GraphPlot")'
4630
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
4731
Pkg.instantiate()'
4832
- julia --project=docs/ docs/make.jl
4933
after_success: skip
34+
35+
notifications:
36+
email: false
37+
38+
matrix:
39+
allow_failures:
40+
- julia: nightly
41+
- env: IIF_TEST=true
42+
43+
# Set the password for Neo4j to neo4j:test
44+
before_script:
45+
- sleep 10
46+
- curl -v POST http://neo4j:neo4j@localhost:7474/user/neo4j/password -d"password=test"
47+
48+
after_success:
49+
- julia -e 'using Pkg; cd(Pkg.dir("DistributedFactorGraphs")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder()); Coveralls.submit(process_folder())'

Project.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DistributedFactorGraphs"
22
uuid = "b5cc3c7e-6572-11e9-2517-99fb8daf2f04"
3-
version = "0.4.1"
3+
version = "0.4.2"
44

55
[deps]
66
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
@@ -13,23 +13,25 @@ JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
1313
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
16+
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1617
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1718
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1819
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1920

2021
[compat]
21-
Distributions = "≥ 0.18"
22-
DocStringExtensions = "≥ 0.7"
23-
Graphs = "≥ 0.10.3"
24-
MetaGraphs = "≥ 0.6.4"
25-
Reexport = "≥ 0.2"
26-
Requires = "≥ 0.5"
22+
Distributions = "0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 1"
23+
DocStringExtensions = "0.7, 0.8, 0.9, 0.10, 1"
24+
Graphs = "0.10.2, 0.11, 1"
25+
MetaGraphs = "^0.6.3"
26+
Neo4j = "2"
27+
Reexport = "0.2, 0.3, 0.4, 0.5, 1"
28+
Requires = "0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 1"
2729
julia = "0.7, 1"
2830

2931
[extras]
3032
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3133
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
32-
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
34+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3335

3436
[targets]
35-
test = ["Test", "GraphPlot", "Neo4j"]
37+
test = ["Test", "GraphPlot", "Pkg"]

src/CloudGraphsDFG/CloudGraphsDFG.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ include("entities/CloudGraphsDFG.jl")
55

66
# Services
77
include("services/CommonFunctions.jl")
8+
include("services/CGStructure.jl")
89
include("services/CloudGraphsDFG.jl")
910

1011
# Exports
1112
export Neo4jInstance, CloudGraphsDFG
1213
export exists
1314
export clearSession!
14-
export getLabelDict, getDescription, setDescription, getInnerGraph, getAddHistory, getSolverParams, setSolverParams
15+
export getLabelDict, getDescription, setDescription, getAddHistory, getSolverParams, setSolverParams
1516

1617
export getAddHistory, getDescription, getLabelDict
1718
export addVariable!, addFactor!
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Additional exports
2+
export copySession!
3+
# Please be careful with these
4+
# With great power comes great "Oh crap, I deleted everything..."
5+
export clearSession!!, clearRobot!!, clearUser!!
6+
7+
8+
"""
9+
$(SIGNATURES)
10+
DANGER: Clears the whole session from the database.
11+
"""
12+
function clearSession!!(dfg::CloudGraphsDFG)::Nothing
13+
# Perform detach+deletion
14+
_getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId):$(dfg.sessionId)) detach delete node ")
15+
16+
# Clearing history
17+
dfg.addHistory = Symbol[]
18+
empty!(dfg.variableCache)
19+
empty!(dfg.factorCache)
20+
empty!(dfg.labelDict)
21+
return nothing
22+
end
23+
24+
"""
25+
$(SIGNATURES)
26+
DANGER: Clears the whole robot + sessions from the database.
27+
"""
28+
function clearRobot!!(dfg::CloudGraphsDFG)::Nothing
29+
# Perform detach+deletion
30+
_getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId):$(dfg.robotId)) detach delete node ")
31+
32+
# Clearing history
33+
dfg.addHistory = Symbol[]
34+
empty!(dfg.variableCache)
35+
empty!(dfg.factorCache)
36+
empty!(dfg.labelDict)
37+
return nothing
38+
end
39+
40+
"""
41+
$(SIGNATURES)
42+
DANGER: Clears the whole user + robot + sessions from the database.
43+
"""
44+
function clearUser!!(dfg::CloudGraphsDFG)::Nothing
45+
# Perform detach+deletion
46+
_getNeoNodesFromCyphonQuery(dfg.neo4jInstance, "(node:$(dfg.userId)) detach delete node ")
47+
48+
# Clearing history
49+
dfg.addHistory = Symbol[]
50+
empty!(dfg.variableCache)
51+
empty!(dfg.factorCache)
52+
empty!(dfg.labelDict)
53+
return nothing
54+
end
55+
56+
"""
57+
$(SIGNATURES)
58+
DANGER: Copies and overwrites the destination session.
59+
If no destination specified then it creates a unique one.
60+
"""
61+
function copySession!(sourceDFG::CloudGraphsDFG, destDFG::Union{Nothing, CloudGraphsDFG})::CloudGraphsDFG
62+
if destDFG == nothing
63+
destDFG = _getDuplicatedEmptyDFG(sourceDFG)
64+
end
65+
_copyIntoGraph!(sourceDFG, destDFG, union(getVariableIds(sourceDFG), getFactorIds(sourceDFG)), true)
66+
return destDFG
67+
end
68+
"""
69+
$(SIGNATURES)
70+
DANGER: Copies the source to a new unique destination.
71+
"""
72+
copySession!(sourceDFG::CloudGraphsDFG)::CloudGraphsDFG = copySession!(sourceDFG, nothing)
73+
74+
75+
getUserData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, "USER"])
76+
function setUserData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
77+
error("Not implemented yet")
78+
return true
79+
end
80+
getRobotData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, "ROBOT"])
81+
function setRobotData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
82+
error("Not implemented yet")
83+
return true
84+
end
85+
getSessionData(dfg::CloudGraphsDFG)::Dict{Symbol, String} = _getNodeProperty(dfg.neo4jInstance, [dfg.userId, dfg.robotId, dfg.sessionId, "SESSION"])
86+
function setSessionData(dfg::CloudGraphsDFG, data::Dict{Symbol, String})::Bool
87+
error("Not implemented yet")
88+
return true
89+
end

0 commit comments

Comments
 (0)