Skip to content

Commit 250abad

Browse files
authored
Towards removing the UserRobotSession structure (BlobEntry and Data(Metadata)) (#1093)
* Move Factor constructor from SDK * depr BlobEntries _type and move InferenceType from SDK * rename/deprecate node blob entries * Start Agent and Fg Metadata * BE.originId optional + start Agent type * move assembleFactorName and getFncTypeName from SDK * Deprecate [Session/Robot/User] BlobEntry -> [Agent/Graph] BlobEntry * Deprecate [Session/Robot/User] Data -> [Agent/Graph] Metadata
1 parent 35d66bc commit 250abad

19 files changed

+285
-295
lines changed

NEWS.md

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

3+
# v0.24
4+
- Deprecated nouns:
5+
SessionBlobEntry -> GraphBlobEntry
6+
RobotBlobEntry -> AgentBlobEntry
7+
UserBlobEntry -> AgentBlobEntry
8+
RobotData -> AgentMetadata
9+
SessionData -> GraphMetadata
10+
311
# v0.24
412

513
- Remove `FolderStore` `.dat` legacy extension. To upgrade a legacy FolderStore remove extention with something like: `foreach(f->mv(f,split(f,".")[1]), files)`

docs/src/GraphData.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,19 @@ Graphs reside inside a hierarchy made up in the following way:
190190

191191
This data can be retrieved with the follow functions:
192192

193-
- [`getUserData`](@ref)
194-
- [`getRobotData`](@ref)
195-
- [`getSessionData`](@ref)
193+
- [`getAgentMetadata`](@ref)
194+
- [`getGraphMetadata`](@ref)
196195

197196

198197
It can be set using the following functions:
199198

200-
- [`setUserData!`](@ref)
201-
- [`setRobotData!`](@ref)
202-
- [`setSessionData!`](@ref)
199+
- [`setAgentMetadata!`](@ref)
200+
- [`setGraphMetadata!`](@ref)
203201

204202

205203
Example of using graph-level data:
206204

207205
```julia
208-
setUserData!(dfg, Dict(:a => "Hello"))
209-
getUserData(dfg)
206+
setAgentMetadata!(dfg, Dict(:a => "Hello"))
207+
getAgentMetadata(dfg)
210208
```

src/Common.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ end
7070
sortDFG(vars::Vector{Symbol}; lt = natural_lt, kwargs...) = sort(vars; lt = lt, kwargs...)
7171

7272
##==============================================================================
73-
## Validation of session, robot, and user IDs.
73+
## Validation of session, robot, and user labels.
7474
##==============================================================================
7575
global _invalidIds = [
7676
"USER",
7777
"ROBOT",
7878
"SESSION",
79+
"AGENT",
7980
"VARIABLE",
8081
"FACTOR",
81-
"ENVIRONMENT",
8282
"PPE",
83-
"DATA_ENTRY",
83+
"BLOB_ENTRY",
8484
"FACTORGRAPH",
8585
]
8686

87-
global _validLabelRegex = r"^[a-zA-Z][-\w\.\@]*$"
87+
const global _validLabelRegex::Regex = r"^[a-zA-Z][-\w\.\@]*$"
8888

8989
"""
9090
$(SIGNATURES)
@@ -95,8 +95,7 @@ function isValidLabel(id::Union{Symbol, String})
9595
if typeof(id) == Symbol
9696
id = String(id)
9797
end
98-
return all(t -> t != uppercase(id), _invalidIds) &&
99-
match(_validLabelRegex, id) !== nothing
98+
return !in(uppercase(id), _invalidIds) && !isnothing(match(_validLabelRegex, id))
10099
end
101100

102101
"""

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Base.@kwdef struct BlobEntry
1919
""" Machine friendly and globally unique identifier of the 'Blob', usually assigned from a common point in the system. This can be used to guarantee unique retrieval of the large data blob. """
2020
blobId::Union{UUID, Nothing} = nothing
2121
""" Machine friendly and locally assigned identifier of the 'Blob'. `.originId`s are mandatory upon first creation at the origin regardless of network access. Separate from `.blobId` since some architectures do not allow edge processes to assign a uuid4 to data store elements. """
22-
originId::UUID = uuid4()
22+
originId::Union{UUID, Nothing} = nothing
2323
""" Human friendly label of the `Blob` and also used as unique identifier per node on which a `BlobEntry` is added. E.g. do "LEFTCAM_1", "LEFTCAM_2", ... of you need to repeat a label on the same variable. """
2424
label::Symbol
2525
""" A hint about where the `Blob` itself might be stored. Remember that a Blob may be duplicated over multiple blobstores. """
@@ -35,15 +35,13 @@ Base.@kwdef struct BlobEntry
3535
""" MIME description describing the format of binary data in the `Blob`, e.g. 'image/png' or 'application/json; _type=CameraModel'. """
3636
mimeType::String = "application/octet-stream"
3737
""" Additional storage for functional metadata used in some scenarios, e.g. to support advanced features such as `parsejson(base64decode(entry.metadata))['time_sync']`. """
38-
metadata::String = ""
38+
metadata::String = "e30="
3939
""" When the Blob itself was first created. """
4040
timestamp::ZonedDateTime = now(localzone())
4141
""" When the BlobEntry was created. """
4242
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
4343
""" Use carefully, but necessary to support advanced usage such as time synchronization over Blob data. """
4444
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
45-
""" Self type declaration for when duck-typing happens. """
46-
_type::String = "DistributedFactorGraph.BlobEntry"
4745
""" Type version of this BlobEntry. TBD.jl consider upgrading to `::VersionNumber`. """
4846
_version::String = string(_getDFGVersion())
4947
end

src/DataBlobs/services/BlobEntry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function assertHash(de::BlobEntry, db; hashfunction::Function = sha256)
4343
end
4444

4545
function Base.show(io::IO, ::MIME"text/plain", entry::BlobEntry)
46-
println(io, "_type=BlobEntry {")
46+
println(io, "BlobEntry {")
4747
println(io, " id: ", entry.id)
4848
println(io, " blobId: ", entry.blobId)
4949
println(io, " originId: ", entry.originId)

src/DataBlobs/services/HelpersDataWrapEntryBlob.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function BlobEntry(
5757
timestamp::ZonedDateTime = entry.timestamp,
5858
createdTimestamp = entry.createdTimestamp,
5959
lastUpdatedTimestamp = entry.lastUpdatedTimestamp,
60-
_type::String = entry._type,
6160
_version::String = entry._version,
6261
)
6362
return BlobEntry(;
@@ -75,7 +74,6 @@ function BlobEntry(
7574
timestamp,
7675
createdTimestamp,
7776
lastUpdatedTimestamp,
78-
_type,
7977
_version,
8078
)
8179
end

src/Deprecated.jl

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
## ================================================================================
2+
## Deprecated in v0.25
3+
##=================================================================================
4+
@deprecate getSessionBlobEntry(args...) getGraphBlobEntry(args...)
5+
@deprecate getSessionBlobEntries(args...) getGraphBlobEntries(args...)
6+
@deprecate addSessionBlobEntry!(args...) addGraphBlobEntry!(args...)
7+
@deprecate addSessionBlobEntries!(args...) addGraphBlobEntries!(args...)
8+
@deprecate updateSessionBlobEntry!(args...) updateGraphBlobEntry!(args...)
9+
@deprecate deleteSessionBlobEntry!(args...) deleteGraphBlobEntry!(args...)
10+
@deprecate getRobotBlobEntry(args...) getAgentBlobEntry(args...)
11+
@deprecate getRobotBlobEntries(args...) getAgentBlobEntries(args...)
12+
@deprecate addRobotBlobEntry!(args...) addAgentBlobEntry!(args...)
13+
@deprecate addRobotBlobEntries!(args...) addAgentBlobEntries!(args...)
14+
@deprecate updateRobotBlobEntry!(args...) updateAgentBlobEntry!(args...)
15+
@deprecate deleteRobotBlobEntry!(args...) deleteAgentBlobEntry!(args...)
16+
@deprecate getUserBlobEntry(args...) getAgentBlobEntry(args...)
17+
@deprecate getUserBlobEntries(args...) getAgentBlobEntries(args...)
18+
@deprecate addUserBlobEntry!(args...) addAgentBlobEntry!(args...)
19+
@deprecate addUserBlobEntries!(args...) addAgentBlobEntries!(args...)
20+
@deprecate updateUserBlobEntry!(args...) updateAgentBlobEntry!(args...)
21+
@deprecate deleteUserBlobEntry!(args...) deleteAgentBlobEntry!(args...)
22+
@deprecate listSessionBlobEntries(args...) listGraphBlobEntries(args...)
23+
@deprecate listRobotBlobEntries(args...) listAgentBlobEntries(args...)
24+
@deprecate listUserBlobEntries(args...) listAgentBlobEntries(args...)
25+
26+
@deprecate getUserData(args...) getAgentMetadata(args...)
27+
@deprecate getRobotData(args...) getAgentMetadata(args...)
28+
@deprecate getSessionData(args...) getGraphMetadata(args...)
29+
30+
@deprecate setUserData!(args...) setAgentMetadata!(args...)
31+
@deprecate setRobotData!(args...) setAgentMetadata!(args...)
32+
@deprecate setSessionData!(args...) setGraphMetadata!(args...)
33+
34+
#TODO
35+
# @deprecate getUserLabel(dfg) getAgentLabel(dfg)
36+
# @deprecate getRobotLabel(dfg) getAgentLabel(dfg)
37+
# @deprecate getSessionLabel(dfg) getGraphLabel(dfg)
138

239
## ================================================================================
340
## Deprecated in v0.24
@@ -14,39 +51,3 @@
1451
##=================================================================================
1552
#NOTE free up getNeighbors to return the variables or factors
1653
@deprecate getNeighbors(args...; kwargs...) listNeighbors(args...; kwargs...)
17-
18-
## ================================================================================
19-
## Deprecated in v0.22
20-
##=================================================================================
21-
@deprecate BlobEntry(
22-
id,
23-
blobId,
24-
originId::UUID,
25-
label::Symbol,
26-
blobstore::Symbol,
27-
hash::String,
28-
origin::String,
29-
description::String,
30-
mimeType::String,
31-
metadata::String,
32-
timestamp::ZonedDateTime,
33-
_type::String,
34-
_version::String,
35-
) BlobEntry(
36-
id,
37-
blobId,
38-
originId,
39-
label,
40-
blobstore,
41-
hash,
42-
origin,
43-
-1,
44-
description,
45-
mimeType,
46-
metadata,
47-
timestamp,
48-
nothing,
49-
nothing,
50-
_type,
51-
_version,
52-
)

src/DistributedFactorGraphs.jl

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,47 +70,34 @@ export getDescription,
7070
setDescription!,
7171
getSolverParams,
7272
setSolverParams!,
73-
getUserData,
74-
setUserData!,
75-
getRobotData,
76-
setRobotData!,
77-
getSessionData,
78-
setSessionData!,
73+
getAgentMetadata,
74+
setAgentMetadata!,
75+
getGraphMetadata,
76+
setGraphMetadata!,
7977
getAddHistory
8078

81-
export getSessionBlobEntry,
82-
getSessionBlobEntries,
83-
addSessionBlobEntry!,
84-
addSessionBlobEntries!,
85-
updateSessionBlobEntry!,
86-
deleteSessionBlobEntry!,
87-
getRobotBlobEntry,
88-
getRobotBlobEntries,
89-
addRobotBlobEntry!,
90-
addRobotBlobEntries!,
91-
updateRobotBlobEntry!,
92-
deleteRobotBlobEntry!,
93-
getUserBlobEntry,
94-
getUserBlobEntries,
95-
addUserBlobEntry!,
96-
addUserBlobEntries!,
97-
updateUserBlobEntry!,
98-
deleteUserBlobEntry!,
99-
listSessionBlobEntries,
100-
listRobotBlobEntries,
101-
listUserBlobEntries
79+
export getGraphBlobEntry,
80+
getGraphBlobEntries,
81+
addGraphBlobEntry!,
82+
addGraphBlobEntries!,
83+
updateGraphBlobEntry!,
84+
deleteGraphBlobEntry!,
85+
getAgentBlobEntry,
86+
getAgentBlobEntries,
87+
addAgentBlobEntry!,
88+
addAgentBlobEntries!,
89+
updateAgentBlobEntry!,
90+
deleteAgentBlobEntry!,
91+
listGraphBlobEntries,
92+
listAgentBlobEntries
10293

10394
export getBlobStore,
10495
addBlobStore!, updateBlobStore!, deleteBlobStore!, emptyBlobStore!, listBlobStores
10596

10697
# TODO Not sure these are needed or should work everywhere, implement in cloud?
107-
export updateUserData!,
108-
updateRobotData!,
109-
updateSessionData!,
110-
deleteUserData!,
111-
deleteRobotData!,
112-
deleteSessionData!
113-
export emptyUserData!, emptyRobotData!, emptySessionData!
98+
export updateAgentMetadata!,
99+
updateGraphMetadata!, deleteAgentMetadata!, deleteGraphMetadata!
100+
export emptyAgentMetadata!, emptyGraphMetadata!
114101

115102
# Graph Types: exported from modules or @reexport
116103
export InMemoryDFGTypes, LocalDFG
@@ -356,6 +343,8 @@ include("entities/DFGVariable.jl")
356343

357344
include("entities/AbstractDFGSummary.jl")
358345

346+
include("entities/Agent.jl")
347+
359348
include("services/AbstractDFG.jl")
360349

361350
#Blobs

src/GraphsDFG/GraphsDFG.jl

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ import ...DistributedFactorGraphs:
1616
setSolverParams!,
1717
getFactor,
1818
# getLabelDict,
19-
getUserData,
20-
setUserData!,
21-
getRobotData,
22-
setRobotData!,
23-
getSessionData,
24-
setSessionData!,
19+
getAgentMetadata,
20+
setAgentMetadata!,
21+
getGraphMetadata,
22+
setGraphMetadata!,
2523
addVariable!,
2624
getVariable,
2725
getAddHistory,
@@ -49,13 +47,12 @@ import ...DistributedFactorGraphs:
4947
toDot,
5048
toDotFile,
5149
findShortestPathDijkstra,
52-
getSessionBlobEntry,
53-
getSessionBlobEntries,
54-
addSessionBlobEntry!,
55-
addSessionBlobEntries!,
56-
listSessionBlobEntries,
57-
listRobotBlobEntries,
58-
listUserBlobEntries,
50+
getGraphBlobEntry,
51+
getGraphBlobEntries,
52+
addGraphBlobEntry!,
53+
addGraphBlobEntries!,
54+
listGraphBlobEntries,
55+
listAgentBlobEntries,
5956
getTypeDFGVariables,
6057
getTypeDFGFactors
6158

0 commit comments

Comments
 (0)