Skip to content

Commit

Permalink
Towards removing the UserRobotSession structure (BlobEntry and Data(M…
Browse files Browse the repository at this point in the history
…etadata)) (#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
  • Loading branch information
Affie authored Oct 16, 2024
1 parent 35d66bc commit 250abad
Show file tree
Hide file tree
Showing 19 changed files with 285 additions and 295 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Listing news on any major breaking changes in DFG. For regular changes, see integrated Github.com project milestones for DFG.

# v0.24
- Deprecated nouns:
SessionBlobEntry -> GraphBlobEntry
RobotBlobEntry -> AgentBlobEntry
UserBlobEntry -> AgentBlobEntry
RobotData -> AgentMetadata
SessionData -> GraphMetadata

# v0.24

- Remove `FolderStore` `.dat` legacy extension. To upgrade a legacy FolderStore remove extention with something like: `foreach(f->mv(f,split(f,".")[1]), files)`
Expand Down
14 changes: 6 additions & 8 deletions docs/src/GraphData.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,19 @@ Graphs reside inside a hierarchy made up in the following way:

This data can be retrieved with the follow functions:

- [`getUserData`](@ref)
- [`getRobotData`](@ref)
- [`getSessionData`](@ref)
- [`getAgentMetadata`](@ref)
- [`getGraphMetadata`](@ref)


It can be set using the following functions:

- [`setUserData!`](@ref)
- [`setRobotData!`](@ref)
- [`setSessionData!`](@ref)
- [`setAgentMetadata!`](@ref)
- [`setGraphMetadata!`](@ref)


Example of using graph-level data:

```julia
setUserData!(dfg, Dict(:a => "Hello"))
getUserData(dfg)
setAgentMetadata!(dfg, Dict(:a => "Hello"))
getAgentMetadata(dfg)
```
11 changes: 5 additions & 6 deletions src/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ end
sortDFG(vars::Vector{Symbol}; lt = natural_lt, kwargs...) = sort(vars; lt = lt, kwargs...)

##==============================================================================
## Validation of session, robot, and user IDs.
## Validation of session, robot, and user labels.
##==============================================================================
global _invalidIds = [
"USER",
"ROBOT",
"SESSION",
"AGENT",
"VARIABLE",
"FACTOR",
"ENVIRONMENT",
"PPE",
"DATA_ENTRY",
"BLOB_ENTRY",
"FACTORGRAPH",
]

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

"""
$(SIGNATURES)
Expand All @@ -95,8 +95,7 @@ function isValidLabel(id::Union{Symbol, String})
if typeof(id) == Symbol
id = String(id)
end
return all(t -> t != uppercase(id), _invalidIds) &&
match(_validLabelRegex, id) !== nothing
return !in(uppercase(id), _invalidIds) && !isnothing(match(_validLabelRegex, id))
end

"""
Expand Down
6 changes: 2 additions & 4 deletions src/DataBlobs/entities/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Base.@kwdef struct BlobEntry
""" 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. """
blobId::Union{UUID, Nothing} = nothing
""" 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. """
originId::UUID = uuid4()
originId::Union{UUID, Nothing} = nothing
""" 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. """
label::Symbol
""" A hint about where the `Blob` itself might be stored. Remember that a Blob may be duplicated over multiple blobstores. """
Expand All @@ -35,15 +35,13 @@ Base.@kwdef struct BlobEntry
""" MIME description describing the format of binary data in the `Blob`, e.g. 'image/png' or 'application/json; _type=CameraModel'. """
mimeType::String = "application/octet-stream"
""" Additional storage for functional metadata used in some scenarios, e.g. to support advanced features such as `parsejson(base64decode(entry.metadata))['time_sync']`. """
metadata::String = ""
metadata::String = "e30="
""" When the Blob itself was first created. """
timestamp::ZonedDateTime = now(localzone())
""" When the BlobEntry was created. """
createdTimestamp::Union{ZonedDateTime, Nothing} = nothing
""" Use carefully, but necessary to support advanced usage such as time synchronization over Blob data. """
lastUpdatedTimestamp::Union{ZonedDateTime, Nothing} = nothing
""" Self type declaration for when duck-typing happens. """
_type::String = "DistributedFactorGraph.BlobEntry"
""" Type version of this BlobEntry. TBD.jl consider upgrading to `::VersionNumber`. """
_version::String = string(_getDFGVersion())
end
Expand Down
2 changes: 1 addition & 1 deletion src/DataBlobs/services/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function assertHash(de::BlobEntry, db; hashfunction::Function = sha256)
end

function Base.show(io::IO, ::MIME"text/plain", entry::BlobEntry)
println(io, "_type=BlobEntry {")
println(io, "BlobEntry {")
println(io, " id: ", entry.id)
println(io, " blobId: ", entry.blobId)
println(io, " originId: ", entry.originId)
Expand Down
2 changes: 0 additions & 2 deletions src/DataBlobs/services/HelpersDataWrapEntryBlob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function BlobEntry(
timestamp::ZonedDateTime = entry.timestamp,
createdTimestamp = entry.createdTimestamp,
lastUpdatedTimestamp = entry.lastUpdatedTimestamp,
_type::String = entry._type,
_version::String = entry._version,
)
return BlobEntry(;
Expand All @@ -75,7 +74,6 @@ function BlobEntry(
timestamp,
createdTimestamp,
lastUpdatedTimestamp,
_type,
_version,
)
end
Expand Down
73 changes: 37 additions & 36 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## ================================================================================
## Deprecated in v0.25
##=================================================================================
@deprecate getSessionBlobEntry(args...) getGraphBlobEntry(args...)
@deprecate getSessionBlobEntries(args...) getGraphBlobEntries(args...)
@deprecate addSessionBlobEntry!(args...) addGraphBlobEntry!(args...)
@deprecate addSessionBlobEntries!(args...) addGraphBlobEntries!(args...)
@deprecate updateSessionBlobEntry!(args...) updateGraphBlobEntry!(args...)
@deprecate deleteSessionBlobEntry!(args...) deleteGraphBlobEntry!(args...)
@deprecate getRobotBlobEntry(args...) getAgentBlobEntry(args...)
@deprecate getRobotBlobEntries(args...) getAgentBlobEntries(args...)
@deprecate addRobotBlobEntry!(args...) addAgentBlobEntry!(args...)
@deprecate addRobotBlobEntries!(args...) addAgentBlobEntries!(args...)
@deprecate updateRobotBlobEntry!(args...) updateAgentBlobEntry!(args...)
@deprecate deleteRobotBlobEntry!(args...) deleteAgentBlobEntry!(args...)
@deprecate getUserBlobEntry(args...) getAgentBlobEntry(args...)
@deprecate getUserBlobEntries(args...) getAgentBlobEntries(args...)
@deprecate addUserBlobEntry!(args...) addAgentBlobEntry!(args...)
@deprecate addUserBlobEntries!(args...) addAgentBlobEntries!(args...)
@deprecate updateUserBlobEntry!(args...) updateAgentBlobEntry!(args...)
@deprecate deleteUserBlobEntry!(args...) deleteAgentBlobEntry!(args...)
@deprecate listSessionBlobEntries(args...) listGraphBlobEntries(args...)
@deprecate listRobotBlobEntries(args...) listAgentBlobEntries(args...)
@deprecate listUserBlobEntries(args...) listAgentBlobEntries(args...)

@deprecate getUserData(args...) getAgentMetadata(args...)
@deprecate getRobotData(args...) getAgentMetadata(args...)
@deprecate getSessionData(args...) getGraphMetadata(args...)

@deprecate setUserData!(args...) setAgentMetadata!(args...)
@deprecate setRobotData!(args...) setAgentMetadata!(args...)
@deprecate setSessionData!(args...) setGraphMetadata!(args...)

#TODO
# @deprecate getUserLabel(dfg) getAgentLabel(dfg)
# @deprecate getRobotLabel(dfg) getAgentLabel(dfg)
# @deprecate getSessionLabel(dfg) getGraphLabel(dfg)

## ================================================================================
## Deprecated in v0.24
Expand All @@ -14,39 +51,3 @@
##=================================================================================
#NOTE free up getNeighbors to return the variables or factors
@deprecate getNeighbors(args...; kwargs...) listNeighbors(args...; kwargs...)

## ================================================================================
## Deprecated in v0.22
##=================================================================================
@deprecate BlobEntry(
id,
blobId,
originId::UUID,
label::Symbol,
blobstore::Symbol,
hash::String,
origin::String,
description::String,
mimeType::String,
metadata::String,
timestamp::ZonedDateTime,
_type::String,
_version::String,
) BlobEntry(
id,
blobId,
originId,
label,
blobstore,
hash,
origin,
-1,
description,
mimeType,
metadata,
timestamp,
nothing,
nothing,
_type,
_version,
)
57 changes: 23 additions & 34 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,47 +70,34 @@ export getDescription,
setDescription!,
getSolverParams,
setSolverParams!,
getUserData,
setUserData!,
getRobotData,
setRobotData!,
getSessionData,
setSessionData!,
getAgentMetadata,
setAgentMetadata!,
getGraphMetadata,
setGraphMetadata!,
getAddHistory

export getSessionBlobEntry,
getSessionBlobEntries,
addSessionBlobEntry!,
addSessionBlobEntries!,
updateSessionBlobEntry!,
deleteSessionBlobEntry!,
getRobotBlobEntry,
getRobotBlobEntries,
addRobotBlobEntry!,
addRobotBlobEntries!,
updateRobotBlobEntry!,
deleteRobotBlobEntry!,
getUserBlobEntry,
getUserBlobEntries,
addUserBlobEntry!,
addUserBlobEntries!,
updateUserBlobEntry!,
deleteUserBlobEntry!,
listSessionBlobEntries,
listRobotBlobEntries,
listUserBlobEntries
export getGraphBlobEntry,
getGraphBlobEntries,
addGraphBlobEntry!,
addGraphBlobEntries!,
updateGraphBlobEntry!,
deleteGraphBlobEntry!,
getAgentBlobEntry,
getAgentBlobEntries,
addAgentBlobEntry!,
addAgentBlobEntries!,
updateAgentBlobEntry!,
deleteAgentBlobEntry!,
listGraphBlobEntries,
listAgentBlobEntries

export getBlobStore,
addBlobStore!, updateBlobStore!, deleteBlobStore!, emptyBlobStore!, listBlobStores

# TODO Not sure these are needed or should work everywhere, implement in cloud?
export updateUserData!,
updateRobotData!,
updateSessionData!,
deleteUserData!,
deleteRobotData!,
deleteSessionData!
export emptyUserData!, emptyRobotData!, emptySessionData!
export updateAgentMetadata!,
updateGraphMetadata!, deleteAgentMetadata!, deleteGraphMetadata!
export emptyAgentMetadata!, emptyGraphMetadata!

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

include("entities/AbstractDFGSummary.jl")

include("entities/Agent.jl")

include("services/AbstractDFG.jl")

#Blobs
Expand Down
23 changes: 10 additions & 13 deletions src/GraphsDFG/GraphsDFG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import ...DistributedFactorGraphs:
setSolverParams!,
getFactor,
# getLabelDict,
getUserData,
setUserData!,
getRobotData,
setRobotData!,
getSessionData,
setSessionData!,
getAgentMetadata,
setAgentMetadata!,
getGraphMetadata,
setGraphMetadata!,
addVariable!,
getVariable,
getAddHistory,
Expand Down Expand Up @@ -49,13 +47,12 @@ import ...DistributedFactorGraphs:
toDot,
toDotFile,
findShortestPathDijkstra,
getSessionBlobEntry,
getSessionBlobEntries,
addSessionBlobEntry!,
addSessionBlobEntries!,
listSessionBlobEntries,
listRobotBlobEntries,
listUserBlobEntries,
getGraphBlobEntry,
getGraphBlobEntries,
addGraphBlobEntry!,
addGraphBlobEntries!,
listGraphBlobEntries,
listAgentBlobEntries,
getTypeDFGVariables,
getTypeDFGFactors

Expand Down
Loading

0 comments on commit 250abad

Please sign in to comment.