Skip to content

Commit ad89652

Browse files
authored
Merge pull request #352 from JuliaRobotics/fix/1Q20/306
fix save load DFG issues 344
2 parents d67220d + c6f6129 commit ad89652

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Neo4j = "d2adbeaf-5838-5367-8a2f-e46d570981db"
1717
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1818
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1919
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
20+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
2021
Unmarshal = "cbff2730-442d-58d7-89d1-8e530c41eb02"
2122

2223
[compat]

src/DistributedFactorGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ using Unmarshal
2525
using JSON2 # JSON2 requires all properties to be in correct sequence, can't guarantee that from DB.
2626
using LinearAlgebra
2727
using SparseArrays
28+
using UUIDs
2829

2930

3031
##==============================================================================

src/FileDFG/services/FileDFG.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ function saveDFG(dfg::AbstractDFG, folder::String; compress::Symbol=:null)
5858
close(io)
5959
end
6060

61-
savedir = dirname(savepath)
61+
savedir = dirname(savepath) # is this a path of just local name? #344 -- workaround with unique names
6262
savename = basename(string(savepath))
6363
@assert savename != ""
6464
destfile = joinpath(savedir, savename*".tar.gz")
65-
run( pipeline(`tar -zcf - -C $savedir $savename`, stdout="$destfile"))
65+
if length(savedir) != 0
66+
run( pipeline(`tar -zcf - -C $savedir $savename`, stdout="$destfile"))
67+
else
68+
run( pipeline(`tar -zcf - $savename`, stdout="$destfile"))
69+
end
6670
Base.rm(joinpath(savedir,savename), recursive=true)
6771
end
6872

@@ -82,7 +86,14 @@ loadDFG("/tmp/savedgraph.tar.gz", IncrementalInference, dfg)
8286
ls(dfg)
8387
```
8488
"""
85-
function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","tmp","caesar","random")) where G <: AbstractDFG
89+
function loadDFG(dst::String,
90+
iifModule::Module,
91+
dfgLoadInto::G) where G <: AbstractDFG
92+
93+
94+
#
95+
# loaddir gets deleted so needs to be unique
96+
loaddir=joinpath("/","tmp","caesar","random", string(uuid1()))
8697
# Check if zipped destination (dst) by first doing fuzzy search from user supplied dst
8798
folder = dst # working directory for fileDFG variable and factor operations
8899
dstname = dst # path name could either be legacy FileDFG dir or .tar.gz file of FileDFG files.
@@ -149,9 +160,9 @@ function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","t
149160

150161
# remove the temporary unzipped file
151162
if unzip
152-
@info "DFG.loadDFG is deleting a temp folder created during unzip, $folder"
163+
@info "DFG.loadDFG is deleting a temp folder created during unzip, $loaddir"
153164
# need this because the number of files created in /tmp/caesar/random is becoming redonkulous.
154-
Base.rm(folder, recursive=true)
165+
Base.rm(loaddir, recursive=true)
155166
end
156167

157168
return dfgLoadInto

0 commit comments

Comments
 (0)