Skip to content

Commit a8dc6f6

Browse files
authored
Merge pull request #950 from JuliaRobotics/23Q1/fix/tryquickkwfix
getDFGVersion does VersionNumber and NEWS
2 parents 3e96d0e + 16983d2 commit a8dc6f6

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.
22

3+
# v0.19
4+
5+
- Add ids and metadata to data types.
6+
- Use `Base.@kwdef` on stuct types for default values and serialization.
7+
- Dropped dependency on Unmarshal.jl.
8+
- Note src/Serialization.jl was refactored and currently contains lots of legacy code for DFG v0.18 compat, and much will be deleted in DFG v0.20 to standardize serialization around JSON3.jl, see #590.
9+
- `Neo4jDFG` has been removed.
10+
- `LightDFG` has been removed, and `GraphsDFG` is not the standard in-memory driver for alias `LocalDFG`.
11+
- Standardize all timestamp fields to `ZonedDateTime` from previous `DateTime` so that time zones will always be available.
12+
- internal `getDFGVersion()` function now returns a `::VersionNumber`.
13+
314
# v0.18.0
415

516
- Unpack of GenericFactorNodeData with `reconstrFactorData` now gets `dfg::AbstractDFG` and `varOrder::Vector{Symbol}`, deprecating previous use of `convert` without the graph context (#832).

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ General Data Store Entry.
3131
metadata::String = ""
3232
timestamp::ZonedDateTime = now(localzone())
3333
_type::String = "BlobStoreEntry"
34-
_version::String = _getDFGVersion()
34+
_version::String = string(_getDFGVersion()) # TBD consider upgrading to ::VersionNumber
3535
end
3636

3737
_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime*"+00")

src/DataBlobs/services/BlobStores.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function updateData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symb
105105
# Recalculate the hash - NOTE Assuming that this is going to be a BlobStoreEntry. TBD.
106106
newEntry = BlobStoreEntry(entry.id, entry.label, blobstore.key, bytes2hex(hashfunction(blob)),
107107
buildSourceString(dfg, label),
108-
entry.description, entry.mimeType, entry.metadata, entry.timestamp, entry._type, _getDFGVersion())
108+
entry.description, entry.mimeType, entry.metadata, entry.timestamp, entry._type, string(_getDFGVersion()))
109109

110110
de = updateDataEntry!(dfg, label, newEntry)
111111
db = updateDataBlob!(blobstore, de, blob)

src/Deprecated.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ end
1414
## Add @deprecate in v0.19, remove after v0.20
1515
##=================================================================================
1616

17+
function Base.convert(::Type{String}, v::VersionNumber)
18+
@warn "Artificial conversion of VersionNumber to String will be deprected in future versions of DFG"
19+
string(v)
20+
end
1721

1822
# TODO ADD DEPRECATION
1923
packVariable(::AbstractDFG, v::DFGVariable) = packVariable(v)

src/entities/DFGVariable.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Base.@kwdef mutable struct PackedVariableNodeData
129129
solveInProgress::Int
130130
solvedCount::Int
131131
solveKey::Symbol
132-
_version::String = _getDFGVersion()
132+
_version::String = string(_getDFGVersion())
133133
end
134134

135135
##==============================================================================
@@ -158,15 +158,15 @@ Base.@kwdef struct MeanMaxPPE <: AbstractPointParametricEst
158158
max::Vector{Float64}
159159
mean::Vector{Float64}
160160
_type::String = "MeanMaxPPE"
161-
_version::String = _getDFGVersion()
161+
_version::String = string(_getDFGVersion())
162162
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
163163
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
164164
end
165165

166166
##------------------------------------------------------------------------------
167167
## Constructors
168168

169-
MeanMaxPPE(solveKey::Symbol, suggested::Vector{Float64}, max::Vector{Float64}, mean::Vector{Float64}) = MeanMaxPPE(nothing, solveKey, suggested, max, mean, "MeanMaxPPE", _getDFGVersion(), now(tz"UTC"), now(tz"UTC"))
169+
MeanMaxPPE(solveKey::Symbol, suggested::Vector{Float64}, max::Vector{Float64}, mean::Vector{Float64}) = MeanMaxPPE(nothing, solveKey, suggested, max, mean, "MeanMaxPPE", string(_getDFGVersion()), now(tz"UTC"), now(tz"UTC"))
170170

171171
## Metadata
172172
"""

src/services/Serialization.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ JSON.show_json(io::JSONContext, serialization::CommonSerialization, uuid::UUID)
1717
# FIXME return VersionNumber
1818
function _getDFGVersion()
1919
if haskey(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"))
20-
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version)
20+
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version) |> VersionNumber
2121
else
2222
# This is arguably slower, but needed for Travis.
23-
return Pkg.TOML.parse(read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String))["version"]
23+
return Pkg.TOML.parse(read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String))["version"] |> VersionNumber
2424
end
2525
end
2626

2727
function _versionCheck(props::Dict{String, Any})
2828
if haskey(props, "_version")
29-
if props["_version"] != _getDFGVersion()
29+
if VersionNumber(props["_version"]) < _getDFGVersion()
3030
@warn "This data was serialized using DFG $(props["_version"]) but you have $(_getDFGVersion()) installed, there may be deserialization issues." maxlog=10
3131
end
3232
else
33-
@warn "There isn't a version tag in this data so it's older than v0.10, there may be deserialization issues."
33+
error("There isn't a version tag in this data so it's older than v0.10, deserialization expected to fail.")
3434
end
3535
end
3636

@@ -245,7 +245,7 @@ function packVariable(v::DFGVariable)
245245
props["variableType"] = typeModuleName(getVariableType(v))
246246
props["dataEntry"] = (Dict(keys(v.dataDict) .=> values(v.dataDict))) # map(bde -> JSON.json(bde), values(v.dataDict))))
247247
props["dataEntryType"] = (Dict(keys(v.dataDict) .=> map(bde -> typeof(bde), values(v.dataDict))))
248-
props["_version"] = _getDFGVersion()
248+
props["_version"] = string(_getDFGVersion())
249249
return props #::Dict{String, Any}
250250
end
251251

@@ -478,7 +478,7 @@ function packVariableNodeData(d::VariableNodeData{T}) where {T <: InferenceVaria
478478
d.solveInProgress,
479479
d.solvedCount,
480480
d.solveKey,
481-
_getDFGVersion())
481+
string(_getDFGVersion()))
482482
end
483483

484484
function unpackVariableNodeData(d::PackedVariableNodeData)
@@ -565,7 +565,7 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
565565
props["fnctype"] = String(_getname(fnctype))
566566
props["_variableOrderSymbols"] = f._variableOrderSymbols # JSON2.write(f._variableOrderSymbols)
567567
props["solvable"] = getSolvable(f)
568-
props["_version"] = _getDFGVersion()
568+
props["_version"] = string(_getDFGVersion())
569569
return props
570570
end
571571

0 commit comments

Comments
 (0)