merlin_db
This module contains the functionality necessary to interact with everything stored in Merlin's database.
MerlinDatabase
High-level interface for accessing Merlin database entities.
This class provides a unified interface to all entity managers in Merlin.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
ResultsBackend
|
A |
logical_workers |
LogicalWorkerManager
|
A |
physical_workers |
PhysicalWorkerManager
|
A |
runs |
RunManager
|
A |
studies |
StudyManager
|
A |
Methods:
| Name | Description |
|---|---|
get_db_type |
Retrieve the type of the backend being used (e.g., Redis, SQL). |
get_db_version |
Retrieve the version of the backend. |
get_connection_string |
Retrieve the backend connection string. |
create |
Create a new entity of the specified type. |
get |
Get an entity by type and identifier. |
get_all |
Get all entities of a specific type. |
delete |
Delete an entity by type and identifier. |
delete_all |
Delete all entities of a specific type. |
get_everything |
Get all entities from all entity managers. |
delete_everything |
Delete all entities from all entity managers. |
Source code in merlin/db_scripts/merlin_db.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
logical_workers
property
Get the logical worker manager.
Returns:
| Type | Description |
|---|---|
LogicalWorkerManager
|
A |
physical_workers
property
Get the physical worker manager.
Returns:
| Type | Description |
|---|---|
PhysicalWorkerManager
|
A |
runs
property
studies
property
__init__()
Initialize a new MerlinDatabase instance.
Source code in merlin/db_scripts/merlin_db.py
create(entity_type, *args, **kwargs)
Create a new entity of the specified type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
The type of entity to create (study, run, logical_worker, physical_worker). |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The created entity. |
Raises:
| Type | Description |
|---|---|
EntityManagerNotSupportedError
|
If the entity type is not supported. |
Source code in merlin/db_scripts/merlin_db.py
delete(entity_type, *args, **kwargs)
Delete an entity by type and identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
The type of entity to delete (study, run, logical_worker, physical_worker). |
required |
Raises:
| Type | Description |
|---|---|
EntityManagerNotSupportedError
|
If the entity type is not supported. |
Source code in merlin/db_scripts/merlin_db.py
delete_all(entity_type, **kwargs)
Delete all entities of a specific type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
The type of entities to delete (study, run, logical_worker, physical_worker). |
required |
Raises:
| Type | Description |
|---|---|
EntityManagerNotSupportedError
|
If the entity type is not supported. |
Source code in merlin/db_scripts/merlin_db.py
delete_everything(force=False)
Delete all entities from all entity managers.
This method deletes studies last to ensure proper cleanup of dependencies.
Source code in merlin/db_scripts/merlin_db.py
get(entity_type, *args, **kwargs)
Get an entity by type and identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
The type of entity to get (study, run, logical_worker, physical_worker). |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The requested entity. |
Raises:
| Type | Description |
|---|---|
EntityManagerNotSupportedError
|
If the entity type is not supported. |
Source code in merlin/db_scripts/merlin_db.py
get_all(entity_type, filters=None)
Get all entities of a specific type, optionally filtering results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
The type of entities to get (study, run, logical_worker, physical_worker). |
required |
filters
|
Dict
|
A dictionary of filter keys and values used to narrow down the query results. Filter keys must correspond to supported filters defined in the ENTITY_REGISTRY for the given entity type. Values are compared against entity attributes or accessor methods (e.g., {"name": "foo"}, {"queues": ["queue1", "queue2"]}). |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
A list of all entities of the specified type matching the filters. |
Raises:
| Type | Description |
|---|---|
EntityManagerNotSupportedError
|
If the entity type is not supported. |
Source code in merlin/db_scripts/merlin_db.py
get_connection_string()
Get the connection string to the backend.
Returns:
| Type | Description |
|---|---|
str
|
The connection string to the backend. |
get_db_type()
Retrieve the type of backend.
Returns:
| Type | Description |
|---|---|
str
|
The type of backend (e.g. redis, sql, etc.). |
get_db_version()
Get the version of the backend.
Returns:
| Type | Description |
|---|---|
str
|
The version number of the backend. |
get_everything()
Get all entities from all entity managers.
Returns:
| Type | Description |
|---|---|
List[Any]
|
A dictionary mapping entity types to lists of entities. |
Source code in merlin/db_scripts/merlin_db.py
info(max_preview=3)
Print summarized information about the database contents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_preview
|
int
|
Number of recent entries to preview per entity type. |
3
|