utils¶
Utility functions for OTEAPI DLite plugin.
RemoveItem
¶
Singleton class used by update_dict() to indicate items that should be removed in the source dictionary.
Source code in oteapi_dlite/utils/utils.py
215 216 217 |
|
TypeMismatchError
¶
Bases: TypeError
Raised by update_dict() if there is a mismatch in value types
between the dct
and update
dictionaries.
Source code in oteapi_dlite/utils/utils.py
209 210 211 212 |
|
get_collection(collection_id=None)
¶
Retrieve a DLite Collection.
Looks for a Collection UUID with collection_id
.
If none exists or collection_id
is not given, a new, empty Collection is
created and returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_id
|
Optional[str]
|
A specific collection ID to retrieve. |
None
|
Return
A DLite Collection to be used throughout the OTEAPI pipeline run.
Source code in oteapi_dlite/utils/utils.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
get_driver(mediaType=None, accessService=None)
¶
Return name of DLite driver for the given media type/access service.
Source code in oteapi_dlite/utils/utils.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_instance(meta, collection_id=None, collection=None, routedict=None, instance_id=None, allow_incomplete=False, **kwargs)
¶
Instantiates and returns an instance of meta
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meta
|
Union[str, Metadata]
|
Metadata to instantiate. Typically its URI. |
required |
collection
|
Optional[Collection]
|
The collection with instances and mappings.
The default is to get the collection from |
None
|
Some less used optional arguments
routedict: Dict mapping property names to route number to select for the given property. The default is to select the route with lowest cost. instance_id: URI of instance to create. allow_incomplete: Whether to allow not populating all properties of the returned instance. kwargs: Additional arguments passed to dlite.mappings.instantiate().
Source code in oteapi_dlite/utils/utils.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
get_meta(uri)
¶
Returns metadata corresponding to given uri.
This function may in the future be connected to a database.
Source code in oteapi_dlite/utils/utils.py
106 107 108 109 110 111 112 113 114 |
|
get_triplestore(kb_settings=None, collection_id=None)
¶
Return a tripper.Triplestore instance for the current kb_settings.
If a 'tripper.triplestore' setting has been added with the SettingsStrategy, it will be used to configure the returned triplestore instance. Otherwise the provided collection ID will be used.
Source code in oteapi_dlite/utils/utils.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
update_collection(collection)
¶
Update collection in DataCache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection
|
Collection
|
The DLite Collection to be updated. |
required |
Source code in oteapi_dlite/utils/utils.py
96 97 98 99 100 101 102 103 |
|
update_dict(dct, update)
¶
Update dictionary dct
using dictionary update
.
This function differ from dict.update()
in that it updates
sub-directories recursively, instead of replacing them with the
content of update
.
If update
has RemoveItem
as a value, the corresponding item
in dct
will be removed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dct
|
dict
|
Dict to update. |
required |
update
|
Optional[dict]
|
Dict used to update |
required |
Returns:
Type | Description |
---|---|
dict
|
The updated dict |
Raises:
Type | Description |
---|---|
TypeMismatchError
|
If there is a mismatch in value types
between the |
Source code in oteapi_dlite/utils/utils.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|