Skip to content

Commit 8715427

Browse files
committed
_version -> VersionNumber
1 parent 19b6210 commit 8715427

File tree

9 files changed

+28
-42
lines changed

9 files changed

+28
-42
lines changed

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Base.@kwdef struct Blobentry
4141
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
4242
""" Use carefully, but necessary to support advanced usage such as time synchronization over Blob data. """
4343
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
44-
""" Type version of this Blobentry. TBD.jl consider upgrading to `::VersionNumber`. """
45-
_version::String = string(_getDFGVersion())
44+
""" Type version of this Blobentry."""
45+
_version::VersionNumber = _getDFGVersion()
4646
end
4747

4848
StructTypes.StructType(::Type{Blobentry}) = StructTypes.UnorderedStruct()

src/DataBlobs/services/HelpersDataWrapEntryBlob.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function Blobentry(
5757
timestamp::ZonedDateTime = entry.timestamp,
5858
createdTimestamp = entry.createdTimestamp,
5959
lastUpdatedTimestamp = entry.lastUpdatedTimestamp,
60-
_version::String = entry._version,
60+
_version = entry._version,
6161
)
6262
return Blobentry(;
6363
id,
@@ -267,7 +267,7 @@ function updateData!(
267267
blobstore = getLabel(blobstore),
268268
hash = string(bytes2hex(hashfunction(blob))),
269269
origin = buildSourceString(dfg, label),
270-
_version = string(_getDFGVersion()),
270+
_version = _getDFGVersion(),
271271
)
272272
mergeBlobentry!(dfg, label, newEntry)
273273
updateBlob!(blobstore, newEntry, blob)

src/FileDFG/FileDFG.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11

2-
# Entities
3-
include("entities/FileDFG.jl")
4-
52
# Services
63
include("services/FileDFG.jl")

src/FileDFG/entities/FileDFG.jl

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/entities/DFGFactor.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Base.@kwdef struct FactorDFG <: AbstractDFGFactor
6464
solvable::Int
6565
data::Union{Nothing, String} = nothing #TODO v0.27 deprecate data completely, left as a bridge to old serialization structure
6666
metadata::String
67-
_version::String = string(_getDFGVersion())
67+
_version::VersionNumber = _getDFGVersion()
6868
state::FactorState
6969
observJSON::String # serialized observation
7070
# blobEntries::Vector{Blobentry}#TODO should factor have blob entries?
@@ -91,7 +91,7 @@ function FactorDFG(
9191
solvable::Int,
9292
data::Union{Nothing, String},
9393
metadata::String,
94-
_version::String,
94+
_version,
9595
state::Union{Nothing, FactorState} = nothing,
9696
observJSON::Union{Nothing, String} = nothing,
9797
)

src/entities/DFGVariable.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Base.@kwdef mutable struct PackedVariableState
122122
solvedCount::Int
123123
solveKey::Symbol
124124
covar::Vector{Float64}
125-
_version::String = string(_getDFGVersion())
125+
_version::VersionNumber = _getDFGVersion()
126126
end
127127
# maybe add
128128
# createdTimestamp::DateTime#!
@@ -158,7 +158,7 @@ Base.@kwdef struct MeanMaxPPE <: AbstractPointParametricEst
158158
max::Vector{Float64}
159159
mean::Vector{Float64}
160160
_type::String = "MeanMaxPPE"
161-
_version::String = string(_getDFGVersion())
161+
_version::VersionNumber = _getDFGVersion()
162162
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
163163
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
164164
end
@@ -185,7 +185,7 @@ function MeanMaxPPE(
185185
max,
186186
mean,
187187
"MeanMaxPPE",
188-
string(_getDFGVersion()),
188+
_getDFGVersion(),
189189
now(tz"UTC"),
190190
now(tz"UTC"),
191191
)
@@ -223,7 +223,7 @@ Base.@kwdef struct VariableDFG <: AbstractDFGVariable
223223
ppes::Vector{MeanMaxPPE} = MeanMaxPPE[]
224224
blobEntries::Vector{Blobentry} = Blobentry[]
225225
variableType::String
226-
_version::String = string(_getDFGVersion())
226+
_version::VersionNumber = _getDFGVersion()
227227
metadata::String = "e30="
228228
solvable::Int = 1
229229
solverData::Vector{PackedVariableState} = PackedVariableState[]

src/services/Serialization.jl

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
## Version checking
22
#NOTE fixed really bad function but kept similar as fallback #TODO upgrade to use pkgversion(m::Module)
33
function _getDFGVersion()
4-
if VERSION >= v"1.9"
5-
return pkgversion(DistributedFactorGraphs)
6-
end
7-
#TODO when we drop jl<1.9 remove the rest here
8-
pkgorigin = get(Base.pkgorigins, Base.PkgId(DistributedFactorGraphs), nothing)
9-
if !isnothing(pkgorigin) && !isnothing(pkgorigin.version)
10-
return pkgorigin.version
11-
end
12-
dep =
13-
get(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"), nothing)
14-
if !isnothing(dep)
15-
return dep.version
16-
else
17-
# This is arguably slower, but needed for Travis.
18-
return Pkg.TOML.parse(
19-
read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String),
20-
)["version"] |> VersionNumber
21-
end
4+
return pkgversion(DistributedFactorGraphs)
225
end
236

247
function _versionCheck(node::Union{<:VariableDFG, <:FactorDFG})
25-
if VersionNumber(node._version).minor < _getDFGVersion().minor
8+
if node._version.minor < _getDFGVersion().minor
269
@warn "This data was serialized using DFG $(node._version) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog =
2710
10
2811
end
@@ -159,7 +142,7 @@ function packVariableState(d::VariableState{T}) where {T <: VariableStateType}
159142
d.solvedCount,
160143
d.solveKey,
161144
isempty(d.covar) ? Float64[] : vec(d.covar[1]),
162-
string(_getDFGVersion()),
145+
_getDFGVersion(),
163146
)
164147
end
165148

@@ -234,7 +217,7 @@ function packVariable(
234217
solvable = v.solvable,
235218
variableType = stringVariableType(DFG.getVariableType(v)),
236219
blobEntries = collect(values(v.dataDict)),
237-
_version = string(DFG._getDFGVersion()),
220+
_version = _getDFGVersion(),
238221
)
239222
end
240223

@@ -312,7 +295,7 @@ function packFactor(f::FactorCompute)
312295
solvable = getSolvable(f),
313296
metadata = base64encode(JSON3.write(f.smallData)),
314297
# Pack the node data
315-
_version = string(_getDFGVersion()),
298+
_version = _getDFGVersion(),
316299
state = f.state,
317300
observJSON = JSON3.write(packObservation(f)),
318301
)

test/fileDFGTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ using UUIDs
161161
end
162162

163163
##
164-
# file = filter(f -> endswith(f, ".tar.gz"), readdir(joinpath(@__DIR__, "data")))[2]
164+
# file = filter(f -> endswith(f, ".tar.gz"), readdir(joinpath(@__DIR__, "data")))[1]
165165
# loadFile = joinpath(@__DIR__, "data", file)
166166
# fg = loadDFG(loadFile)
167167
##

test/testBlocks.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ function blobsStoresTestBlock!(fg)
10891089
@test listBlobstores(fg) == [fs.label]
10901090
# Getting
10911091
@test getBlobstore(fg, fs.label) == fs
1092+
@test_throws LabelNotFoundError getBlobstore(fg, :notfound)
10921093
# Deleting
10931094
@test deleteBlobstore!(fg, fs.label) == 1
10941095
# Updating
@@ -1100,8 +1101,18 @@ function blobsStoresTestBlock!(fg)
11001101
# Add it back
11011102
addBlobstore!(fg, fs)
11021103

1103-
# Data functions
1104+
# Blob
11041105
testData = rand(UInt8, 50)
1106+
blobId = addBlob!(fs, testData)
1107+
@test blobId isa UUID
1108+
@test_throws DFG.IdExistsError addBlob!(fs, blobId, testData)
1109+
@test getBlob(fs, blobId) == testData
1110+
@test_throws DFG.IdNotFoundError getBlob(fs, uuid4())
1111+
@test_throws DFG.IdNotFoundError deleteBlob!(fs, uuid4())
1112+
@test deleteBlob!(fs, blobId) == 1
1113+
@test_throws DFG.IdNotFoundError getBlob(fs, blobId)
1114+
1115+
# Data functions
11051116
# Adding
11061117
newData = addData!(fg, fs.label, :a, :testing, testData) # convenience wrapper over addBlob!
11071118
# Listing

0 commit comments

Comments
 (0)