Skip to content

Commit d40d848

Browse files
committed
fixes from local testing, reducing use of Unmarshal
1 parent 7f5368a commit d40d848

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

src/DataBlobs/entities/AbstractDataEntries.jl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,39 @@ General Data Store Entry.
2828
origin::String # E.g. user|robot|session|varlabel
2929
description::String
3030
mimeType::String
31-
metadata::String
31+
metadata::String = ""
3232
timestamp::ZonedDateTime = now(localzone())
3333
_type::String = "BlobStoreEntry"
3434
_version::String = _getDFGVersion()
3535
end
3636

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

39-
# needed for deserialization from JSON during DFG v0.19 transition, see #867
40-
# TODO this function can likely be removed, since julia automatically tries type conversion on constructors.
41-
function BlobStoreEntry(;
42-
id,
43-
label,
44-
blobstore,
45-
hash,
46-
origin,
47-
description,
48-
mimeType,
49-
timestamp,
50-
kwargs... # drop excessive fields
51-
)
52-
#
53-
BlobStoreEntry(;
54-
id=UUID(id),
55-
label=Symbol(label),
56-
blobstore=Symbol(blobstore),
57-
hash,
58-
origin,
59-
description,
60-
mimeType,
61-
timestamp=_fixtimezone(timestamp),
62-
)
63-
end
39+
# # needed for deserialization from JSON during DFG v0.19 transition, see #867
40+
# # TODO this function can likely be removed, since julia automatically tries type conversion on constructors.
41+
# function BlobStoreEntry(;
42+
# id,
43+
# label,
44+
# blobstore,
45+
# hash,
46+
# origin,
47+
# description,
48+
# mimeType,
49+
# timestamp,
50+
# kwargs... # drop excessive fields
51+
# )
52+
# #
53+
# BlobStoreEntry(;
54+
# id=UUID(id),
55+
# label=Symbol(label),
56+
# blobstore=Symbol(blobstore),
57+
# hash,
58+
# origin,
59+
# description,
60+
# mimeType,
61+
# timestamp=_fixtimezone(timestamp),
62+
# )
63+
# end
6464

6565
# TODO
6666
"""

src/services/Serialization.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181
function standardizeZDTStrings!(T, interm::Dict)
8282

8383
for (name, typ) in zip(fieldnames(T), T.types)
84-
if typ <: ZonedDateTime
84+
if typ <: ZonedDateTime && haskey(interm, name)
8585
namestr = string(name)
8686
interm[namestr] = getStandardZDTString(interm[namestr])
8787
end
@@ -144,6 +144,14 @@ end
144144
$SIGNATURES
145145
Should be a highly reusable function for any transcoding of intermediate type (or dict) to a desired output type.
146146
147+
Notes:
148+
- Using Base.@kwdef and JSON3.jl probably has better conversion logic than this function.
149+
- This function was written to reduce dependency on Unmarshal.jl which was becoming stale.
150+
151+
DevNotes
152+
- See if this function just be deprecated to use JSON3 or similar.
153+
- Do better with Union{Nothing, T} types (if this function is not replaced by JSON3)
154+
147155
examples
148156
```julia
149157
Base.@kwdef struct HardType
@@ -200,6 +208,7 @@ function transcodeType(
200208
# specializations as inner functions (don't have to be inners)
201209
# these few special cases came up with examples below, note recursions
202210
_instance(S::Type, x) = S(x)
211+
_instance(S::Type{Union{Nothing, UUID}}, x::String) = UUID(x) # special case
203212
_instance(_::Type{S}, x::S) where S = x # if ambiguous, delete and do alternative `_instance(S::Type, x) = S===Any ? x : S(x)`
204213
_instance(S::Type{I}, x::AbstractString) where I <: Number = Base.parse(I, x)
205214
_instance(S::Type{E}, x::AbstractVector) where E <: AbstractVector = _instance.(eltype(E),x)
@@ -452,7 +461,8 @@ function unpackVariable(
452461
interm = _doparse(bdeInter) # JSON.parse(bdeInter) # bdeInter
453462
objType = getfield(DistributedFactorGraphs, Symbol(dataElemTypes[k]))
454463
standardizeZDTStrings!(objType, interm)
455-
fullVal = Unmarshal.unmarshal(objType, interm)
464+
fullVal = transcodeType(objType, interm)
465+
# fullVal = Unmarshal.unmarshal(objType, interm)
456466
variable.dataDict[k] = fullVal
457467
end
458468
end

0 commit comments

Comments
 (0)