File tree 3 files changed +32
-5
lines changed
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)
84
84
return var. blobEntries[findfirst (x -> x. label == key, var. blobEntries)]
85
85
end
86
86
87
+ # TODO maybe rename to getBlobEntryFirst
87
88
function getBlobEntry (var:: AbstractDFGVariable , blobId:: UUID )
88
89
for (k, v) in var. dataDict
89
90
if blobId in [v. originId, v. blobId]
@@ -121,7 +122,14 @@ function getBlobEntryFirst(var::VariableDFG, key::Regex)
121
122
end
122
123
123
124
function 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])
125
133
end
126
134
127
135
# TODO Consider autogenerating all methods of the form:
Original file line number Diff line number Diff line change 83
83
# #==============================================================================
84
84
85
85
function getBlob (dfg:: AbstractDFG , entry:: BlobEntry )
86
- # cannot use entry.blobstore because the blob can be in any one of the blobstores
87
86
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]
89
97
try
90
98
blob = getBlob (store, entry)
91
99
return blob
@@ -181,6 +189,9 @@ struct FolderStore{T} <: AbstractBlobStore{T}
181
189
folder:: String
182
190
end
183
191
192
+ # TODO added in v0.25 to avoid a breaking change in deserialization old DFGs, remove.
193
+ StructTypes. StructType (:: Type{<:FolderStore} ) = StructTypes. OrderedStruct ()
194
+
184
195
function FolderStore (foldername:: String ; label = :default_folder_store , createfolder = true )
185
196
if createfolder && ! isdir (foldername)
186
197
@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)
527
527
return fg. graphBlobEntries[label]
528
528
end
529
529
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
+ )
531
534
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
533
541
return entries
534
542
end
535
543
You can’t perform that action at this time.
0 commit comments