File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ function getBlobEntry(var::VariableDFG, key::Symbol)
8484 return var. blobEntries[findfirst (x -> x. label == key, var. blobEntries)]
8585end
8686
87+ # TODO maybe rename to getBlobEntryFirst
8788function getBlobEntry (var:: AbstractDFGVariable , blobId:: UUID )
8889 for (k, v) in var. dataDict
8990 if blobId in [v. originId, v. blobId]
@@ -121,7 +122,14 @@ function getBlobEntryFirst(var::VariableDFG, key::Regex)
121122end
122123
123124function getBlobEntryFirst (dfg:: AbstractDFG , label:: Symbol , key:: Regex )
124- return getBlobEntryFirst (getVariable (dfg, label), key)
125+ els = listBlobEntries (dfg, label)
126+ firstIdx = findfirst (contains (key), string .(els))
127+ isnothing (firstIdx) && throw (
128+ KeyError (
129+ " No blobEntry with label matching regex $(key) found in variable $(label) " ,
130+ ),
131+ )
132+ return getBlobEntry (dfg, label, els[firstIdx])
125133end
126134
127135# TODO Consider autogenerating all methods of the form:
Original file line number Diff line number Diff line change 8383# #==============================================================================
8484
8585function getBlob (dfg:: AbstractDFG , entry:: BlobEntry )
86- # cannot use entry.blobstore because the blob can be in any one of the blobstores
8786 stores = getBlobStores (dfg)
88- for (k, store) in stores
87+ storekeys = collect (keys (stores))
88+ # first check the saved blobstore and then fall back to the rest
89+ fidx = findfirst (== (entry. blobstore), storekeys)
90+ if ! isnothing (fidx)
91+ skey = storekeys[fidx]
92+ popat! (storekeys, fidx)
93+ pushfirst! (storekeys, skey)
94+ end
95+ for k in storekeys
96+ store = stores[k]
8997 try
9098 blob = getBlob (store, entry)
9199 return blob
@@ -181,6 +189,9 @@ struct FolderStore{T} <: AbstractBlobStore{T}
181189 folder:: String
182190end
183191
192+ # TODO added in v0.25 to avoid a breaking change in deserialization old DFGs, remove.
193+ StructTypes. StructType (:: Type{<:FolderStore} ) = StructTypes. OrderedStruct ()
194+
184195function FolderStore (foldername:: String ; label = :default_folder_store , createfolder = true )
185196 if createfolder && ! isdir (foldername)
186197 @info " Folder '$foldername ' doesn't exist - creating."
Original file line number Diff line number Diff line change @@ -527,9 +527,17 @@ function getGraphBlobEntry(fg::GraphsDFG, label::Symbol)
527527 return fg. graphBlobEntries[label]
528528end
529529
530- function getGraphBlobEntries (fg:: GraphsDFG , startwith:: Union{Nothing, String} = nothing )
530+ function getGraphBlobEntries (
531+ fg:: GraphsDFG ,
532+ filt:: Union{Nothing, String, Base.Fix2} = nothing ,
533+ )
531534 entries = collect (values (fg. graphBlobEntries))
532- ! isnothing (startwith) && filter! (e -> startswith (string (e. label), startwith), entries)
535+ if ! isnothing (filt) && isa (filt, String)
536+ @warn " String filter is deprecated, use startswith(filt_string) instead"
537+ filter! (e -> startswith (string (e. label), filt), entries)
538+ elseif ! isnothing (filt)
539+ filter! (e -> filt (string (e. label)), entries)
540+ end
533541 return entries
534542end
535543
You can’t perform that action at this time.
0 commit comments