run_entity
Module for managing database entities related to runs.
This module provides functionality for interacting with runs stored in a database,
including creating, retrieving, updating, and deleting runs. It defines the RunEntity
class, which extends the abstract base class DatabaseEntity,
to encapsulate run-specific operations and behaviors.
RunEntity
Bases: DatabaseEntity[RunModel], QueueManagementMixin
A class representing a run in the database.
This class provides methods to interact with and manage a run's data, including retrieving information about the run, updating its state, and saving or deleting it from the database.
Attributes:
| Name | Type | Description |
|---|---|---|
entity_info |
RunModel
|
An instance of the |
backend |
ResultsBackend
|
An instance of the |
Methods:
| Name | Description |
|---|---|
__repr__ |
Provide a string representation of the |
__str__ |
Provide a human-readable string representation of the |
reload_data |
Reload the latest data for this run from the database. |
get_id |
Retrieve the ID of the run. Implementation found in
|
get_additional_data |
Retrieve any additional data saved to this run. Implementation found in
|
get_run_status |
Get the current status of the run. |
set_run_status |
Update the status of the run. |
is_active |
Check if this run is currently active (RUNNING or INITIALIZED). |
is_finished |
Check if this run has reached a terminal state. |
get_metadata_file |
Retrieve the path to the metadata file for this run. |
get_metadata_filepath |
(classmethod) Retrieve the path to the metadata file for a given workspace. |
get_study_id |
Retrieve the ID of the study associated with this run. |
get_workspace |
Retrieve the path to the output workspace for this run. |
get_queues |
Retrieve the task queues used for this run. |
get_workers |
Retrieve the workers used for this run. |
add_worker |
Add a worker to the list of workers used for this run. |
remove_worker |
Remove a worker from the list of workers used for this run. |
get_parent |
Retrieve the ID of the parent run that launched this run (if any). |
get_child |
Retrieve the ID of the child run launched by this run (if any). |
save |
Save the current state of the run to the database and dump its metadata. |
dump_metadata |
Dump all metadata for this run to a JSON file. |
load |
(classmethod) Load a |
delete |
(classmethod) Delete a run from the database by its ID or workspace. |
Source code in merlin/db_scripts/entities/run_entity.py
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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
run_complete
property
writable
Backwards compatibility property for old code/databases using run_complete.
Returns:
| Type | Description |
|---|---|
bool
|
True if the run has completed (successfully or otherwise), False otherwise. |
Deprecated: Use run_status instead.
__init__(run_info, backend)
Initialize a RunEntity instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_info
|
RunModel
|
The data model containing information about the run. |
required |
backend
|
ResultsBackend
|
The backend instance used to interact with the database. |
required |
Source code in merlin/db_scripts/entities/run_entity.py
__repr__()
Provide a string representation of the RunEntity instance.
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string representation of the |
Source code in merlin/db_scripts/entities/run_entity.py
__str__()
Provide a string representation of the RunEntity instance.
Returns:
| Type | Description |
|---|---|
str
|
A human-readable string representation of the |
Source code in merlin/db_scripts/entities/run_entity.py
add_worker(worker_id)
Add a new worker id to the list of workers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker_id
|
str
|
The id of the worker to add. |
required |
delete(entity_identifier, backend)
classmethod
Delete a run from the database by id or workpsace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_identifier
|
str
|
The ID or workspace of the run to delete. |
required |
backend
|
ResultsBackend
|
A |
required |
Source code in merlin/db_scripts/entities/run_entity.py
dump_metadata()
get_child()
Get the ID of the run that was launched by this run (if any).
This will only be set for iterative workflows with greater than 1 iteration.
Returns:
| Type | Description |
|---|---|
str
|
The ID of the run that was launched by this run. |
Source code in merlin/db_scripts/entities/run_entity.py
get_metadata_file()
Get the path to the metadata file for this run.
Returns:
| Type | Description |
|---|---|
str
|
The path to the metadata file for this run |
get_metadata_filepath(workspace)
classmethod
Get the path to the metadata file for a given workspace.
This is needed for the load
method when loading from workspace as it can't use the non-classmethod version
of this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace
|
str
|
The workspace directory for the run. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path to the metadata file. |
Source code in merlin/db_scripts/entities/run_entity.py
get_parent()
Get the ID of the run that launched this run (if any).
This will only be set for iterative workflows with greater than 1 iteration.
Returns:
| Type | Description |
|---|---|
str
|
The ID of the run that launched this run. |
Source code in merlin/db_scripts/entities/run_entity.py
get_run_status()
Get the current status of the run.
Returns:
| Type | Description |
|---|---|
RunStatus
|
The current RunStatus of the run. |
Source code in merlin/db_scripts/entities/run_entity.py
get_study_id()
Get the ID for the study associated with this run.
Returns:
| Type | Description |
|---|---|
str
|
The ID for the study associated with this run. |
get_workers()
Get the logical workers that this run is using.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of logical worker ids. |
get_workspace()
Get the path to the output workspace for this run.
Returns:
| Type | Description |
|---|---|
str
|
A string representing the output workspace for this run. |
is_active()
Check if this run is currently active (RUNNING or INITIALIZED).
Returns:
| Type | Description |
|---|---|
bool
|
True if the run is active, False otherwise. |
Source code in merlin/db_scripts/entities/run_entity.py
is_finished()
Check if this run has reached a terminal state.
Returns:
| Type | Description |
|---|---|
bool
|
True if the run is in a terminal state (COMPLETED, CANCELLED, FAILED). |
Source code in merlin/db_scripts/entities/run_entity.py
load(entity_identifier, backend)
classmethod
Load a run from the database by id or workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_identifier
|
str
|
The ID or workspace of the run to load. |
required |
backend
|
ResultsBackend
|
A |
required |
Returns:
| Type | Description |
|---|---|
RunEntity
|
A |
Raises:
| Type | Description |
|---|---|
RunNotFoundError
|
If an entry for run was not found in the database. |
Source code in merlin/db_scripts/entities/run_entity.py
remove_worker(worker_id)
Remove a worker id from the list of workers associated with this run.
Does not delete a LogicalWorkerEntity
from the database. This will only remove the worker's id from the list in this run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
worker_id
|
str
|
The ID of the worker to remove. |
required |
Source code in merlin/db_scripts/entities/run_entity.py
set_run_status(status)
Update the status of the run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
RunStatus
|
The new RunStatus for the run. |
required |