Skip to content

Commit 2577077

Browse files
committed
allow loadDFG file w wo extension
1 parent 0a43a5d commit 2577077

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/FileDFG/services/FileDFG.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,17 @@ loadDFG("/tmp/savedgraph", IncrementalInference, dfg) # alternative
7575
ls(dfg)
7676
```
7777
"""
78-
function loadDFG(dst::String, iifModule, dfgLoadInto::G) where G <: AbstractDFG
79-
# check if zipped dst first
80-
folder = dst
81-
sdist = split(dst, '.')
82-
if sdist[end] == "gz" && sdist[end-1] == "tar"
83-
caesardir = joinpath("/tmp","caesar","random")
84-
Base.mkpath(caesardir)
85-
folder = joinpath(caesardir, splitpath(string(sdist[end-2]))[end] )
78+
function loadDFG(dst::String, iifModule, dfgLoadInto::G; loaddir=joinpath("/","tmp","caesar","random")) where G <: AbstractDFG
79+
# Check if zipped destination (dst)
80+
folder = Base.isdir(dst) ? dst : dst*".tar.gz"
81+
sdst = split(dst, '.')
82+
if sdst[end] == "gz" && sdst[end-1] == "tar"
83+
Base.mkpath(loaddir)
84+
folder = joinpath(loaddir, splitpath(string(sdst[end-2]))[end] )
8685
@info "loadDF detected a gzip tarball -- unpacking via $folder now..."
8786
Base.rm(folder, recursive=true, force=true)
8887
# unzip the tar file
89-
run(`tar -zxf $dst -C $caesardir`)
88+
run(`tar -zxf $dst -C $loaddir`)
9089
end
9190
variables = DFGVariable[]
9291
factors = DFGFactor[]

test/fileDFGTests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
saveDFG(dfg, saveFolder)
3333

3434
copyDfg = DistributedFactorGraphs._getDuplicatedEmptyDFG(dfg)
35-
retDFG = loadDFG(saveFolder, Main, copyDfg)
35+
@info "Going to load $saveFolder"
36+
retDFG = loadDFG(saveFolder*".tar.gz", Main, copyDfg, loaddir="/tmp")
3637

3738
@test symdiff(ls(dfg), ls(retDFG)) == []
3839
@test symdiff(lsf(dfg), lsf(retDFG)) == []

0 commit comments

Comments
 (0)