Skip to content

Commit cc4e7a2

Browse files
committed
Backport of the CGDFG code and unit tests
1 parent b352b1c commit cc4e7a2

File tree

9 files changed

+748
-200
lines changed

9 files changed

+748
-200
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ julia = "0.7, 1"
3030
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3131
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
3232
Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
33+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3334

3435
[targets]
35-
test = ["Test", "GraphPlot", "Neo4j"]
36+
test = ["Test", "GraphPlot", "Neo4j", "Pkg"]

src/CloudGraphsDFG/CloudGraphsDFG.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ 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!
1819
export ls, lsf, getVariables, getFactors, getVariableIds, getFactorIds
1920
export getVariable, getFactor
20-
export updateVariable!, updateFactor!, updateVariableSolverData!
21+
export updateVariable!, updateFactor!, mergeUpdateVariableSolverData!
2122
export deleteVariable!, deleteFactor!
2223
export getAdjacencyMatrix
2324
export getNeighbors
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)