Skip to content

Commit

Permalink
Merge pull request #950 from JuliaRobotics/23Q1/fix/tryquickkwfix
Browse files Browse the repository at this point in the history
getDFGVersion does VersionNumber and NEWS
  • Loading branch information
dehann authored Feb 2, 2023
2 parents 3e96d0e + 16983d2 commit a8dc6f6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.

# v0.19

- Add ids and metadata to data types.
- Use `Base.@kwdef` on stuct types for default values and serialization.
- Dropped dependency on Unmarshal.jl.
- 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.
- `Neo4jDFG` has been removed.
- `LightDFG` has been removed, and `GraphsDFG` is not the standard in-memory driver for alias `LocalDFG`.
- Standardize all timestamp fields to `ZonedDateTime` from previous `DateTime` so that time zones will always be available.
- internal `getDFGVersion()` function now returns a `::VersionNumber`.

# v0.18.0

- Unpack of GenericFactorNodeData with `reconstrFactorData` now gets `dfg::AbstractDFG` and `varOrder::Vector{Symbol}`, deprecating previous use of `convert` without the graph context (#832).
Expand Down
2 changes: 1 addition & 1 deletion src/DataBlobs/entities/AbstractDataEntries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ General Data Store Entry.
metadata::String = ""
timestamp::ZonedDateTime = now(localzone())
_type::String = "BlobStoreEntry"
_version::String = _getDFGVersion()
_version::String = string(_getDFGVersion()) # TBD consider upgrading to ::VersionNumber
end

_fixtimezone(cts::NamedTuple) = ZonedDateTime(cts.utc_datetime*"+00")
Expand Down
2 changes: 1 addition & 1 deletion src/DataBlobs/services/BlobStores.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function updateData!(dfg::AbstractDFG, blobstore::AbstractBlobStore, label::Symb
# Recalculate the hash - NOTE Assuming that this is going to be a BlobStoreEntry. TBD.
newEntry = BlobStoreEntry(entry.id, entry.label, blobstore.key, bytes2hex(hashfunction(blob)),
buildSourceString(dfg, label),
entry.description, entry.mimeType, entry.metadata, entry.timestamp, entry._type, _getDFGVersion())
entry.description, entry.mimeType, entry.metadata, entry.timestamp, entry._type, string(_getDFGVersion()))

de = updateDataEntry!(dfg, label, newEntry)
db = updateDataBlob!(blobstore, de, blob)
Expand Down
4 changes: 4 additions & 0 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ end
## Add @deprecate in v0.19, remove after v0.20
##=================================================================================

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

# TODO ADD DEPRECATION
packVariable(::AbstractDFG, v::DFGVariable) = packVariable(v)
Expand Down
6 changes: 3 additions & 3 deletions src/entities/DFGVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Base.@kwdef mutable struct PackedVariableNodeData
solveInProgress::Int
solvedCount::Int
solveKey::Symbol
_version::String = _getDFGVersion()
_version::String = string(_getDFGVersion())
end

##==============================================================================
Expand Down Expand Up @@ -158,15 +158,15 @@ Base.@kwdef struct MeanMaxPPE <: AbstractPointParametricEst
max::Vector{Float64}
mean::Vector{Float64}
_type::String = "MeanMaxPPE"
_version::String = _getDFGVersion()
_version::String = string(_getDFGVersion())
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
end

##------------------------------------------------------------------------------
## Constructors

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"))
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"))

## Metadata
"""
Expand Down
14 changes: 7 additions & 7 deletions src/services/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ JSON.show_json(io::JSONContext, serialization::CommonSerialization, uuid::UUID)
# FIXME return VersionNumber
function _getDFGVersion()
if haskey(Pkg.dependencies(), Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04"))
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version)
return string(Pkg.dependencies()[Base.UUID("b5cc3c7e-6572-11e9-2517-99fb8daf2f04")].version) |> VersionNumber
else
# This is arguably slower, but needed for Travis.
return Pkg.TOML.parse(read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String))["version"]
return Pkg.TOML.parse(read(joinpath(dirname(pathof(@__MODULE__)), "..", "Project.toml"), String))["version"] |> VersionNumber
end
end

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

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

Expand Down Expand Up @@ -478,7 +478,7 @@ function packVariableNodeData(d::VariableNodeData{T}) where {T <: InferenceVaria
d.solveInProgress,
d.solvedCount,
d.solveKey,
_getDFGVersion())
string(_getDFGVersion()))
end

function unpackVariableNodeData(d::PackedVariableNodeData)
Expand Down Expand Up @@ -565,7 +565,7 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
props["fnctype"] = String(_getname(fnctype))
props["_variableOrderSymbols"] = f._variableOrderSymbols # JSON2.write(f._variableOrderSymbols)
props["solvable"] = getSolvable(f)
props["_version"] = _getDFGVersion()
props["_version"] = string(_getDFGVersion())
return props
end

Expand Down

0 comments on commit a8dc6f6

Please sign in to comment.