models
persistence.models
BatchSimulationModel
Bases: SimulationModel
Batch simulation model
Source code in yaptide/persistence/models.py
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 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": value,
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'BatchSimulation'
array_id
class-attribute
instance-attribute
array_id = Column(
Integer, nullable=True, doc="Batch array jon ID"
)
cluster_id
class-attribute
instance-attribute
cluster_id = Column(
Integer,
ForeignKey("Cluster.id"),
nullable=False,
doc="Cluster ID",
)
collect_id
class-attribute
instance-attribute
collect_id = Column(
Integer, nullable=True, doc="Batch collect job ID"
)
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("Simulation.id", ondelete="CASCADE"),
primary_key=True,
)
job_dir
class-attribute
instance-attribute
job_dir = Column(
String, nullable=True, doc="Simulation folder name"
)
update_state
update_state(update_dict)
Used to update fields in BatchSimulation. Returns boolean value if commit to database is reuqired
Source code in yaptide/persistence/models.py
151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
BatchTaskModel
Bases: TaskModel
Batch task model
Source code in yaptide/persistence/models.py
282 283 284 285 286 287 288 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": value,
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'BatchTask'
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("Task.id", ondelete="CASCADE"),
primary_key=True,
)
CelerySimulationModel
Bases: SimulationModel
Celery simulation model
Source code in yaptide/persistence/models.py
129 130 131 132 133 134 135 136 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": value,
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'CelerySimulation'
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("Simulation.id", ondelete="CASCADE"),
primary_key=True,
)
merge_id
class-attribute
instance-attribute
merge_id = Column(
String, nullable=True, doc="Celery collect job ID"
)
CeleryTaskModel
Bases: TaskModel
Celery task model
Source code in yaptide/persistence/models.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": value,
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'CeleryTask'
celery_id
class-attribute
instance-attribute
celery_id = Column(
String, nullable=False, default="", doc="Celery task ID"
)
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("Task.id", ondelete="CASCADE"),
primary_key=True,
)
update_state
update_state(update_dict)
Update method for CeleryTaskModel
Source code in yaptide/persistence/models.py
273 274 275 276 277 |
|
ClusterModel
Bases: Model
Cluster info for specific user
Source code in yaptide/persistence/models.py
63 64 65 66 67 68 69 |
|
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Cluster'
cluster_name
class-attribute
instance-attribute
cluster_name = Column(String, nullable=False)
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
simulations
class-attribute
instance-attribute
simulations = relationship('BatchSimulationModel')
EstimatorModel
Bases: Model
Simulation single estimator model
Source code in yaptide/persistence/models.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Estimator'
compressed_data
class-attribute
instance-attribute
compressed_data = Column(
LargeBinary, doc="Estimator metadata"
)
data
property
writable
data
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
name
class-attribute
instance-attribute
name = Column(String, nullable=False, doc='Estimator name')
pages
class-attribute
instance-attribute
pages = relationship('PageModel', cascade='delete')
simulation_id
class-attribute
instance-attribute
simulation_id = Column(
Integer,
ForeignKey("Simulation.id", ondelete="CASCADE"),
nullable=False,
)
InputModel
Bases: Model
Simulation inputs model
Source code in yaptide/persistence/models.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Input'
compressed_data
class-attribute
instance-attribute
compressed_data = Column(LargeBinary)
data
property
writable
data
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
simulation_id
class-attribute
instance-attribute
simulation_id = Column(
Integer, ForeignKey("Simulation.id", ondelete="CASCADE")
)
KeycloakUserModel
Bases: UserModel
, Model
PLGrid user model
Source code in yaptide/persistence/models.py
52 53 54 55 56 57 58 59 60 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": "KeycloakUser",
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'KeycloakUser'
cert
class-attribute
instance-attribute
cert = Column(String, nullable=True)
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("User.id", ondelete="CASCADE"),
primary_key=True,
)
private_key
class-attribute
instance-attribute
private_key = Column(String, nullable=True)
LogfilesModel
Bases: Model
Simulation logfiles model
Source code in yaptide/persistence/models.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Logfiles'
compressed_data
class-attribute
instance-attribute
compressed_data = Column(
LargeBinary, doc="Json object containing logfiles"
)
data
property
writable
data
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
simulation_id
class-attribute
instance-attribute
simulation_id = Column(
Integer,
ForeignKey("Simulation.id", ondelete="CASCADE"),
nullable=False,
)
PageModel
Bases: Model
Estimator single page model
Source code in yaptide/persistence/models.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Page'
compressed_data
class-attribute
instance-attribute
compressed_data = Column(
LargeBinary,
doc="Page json object - data, axes and metadata",
)
data
property
writable
data
estimator_id
class-attribute
instance-attribute
estimator_id = Column(
Integer,
ForeignKey("Estimator.id", ondelete="CASCADE"),
nullable=False,
)
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
page_number
class-attribute
instance-attribute
page_number = Column(
Integer, nullable=False, doc="Page number"
)
SimulationModel
Bases: Model
Simulation model
Source code in yaptide/persistence/models.py
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 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": "Simulation",
"polymorphic_on": platform,
"with_polymorphic": "*",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Simulation'
end_time
class-attribute
instance-attribute
end_time = Column(
DateTime(timezone=True),
nullable=True,
doc="Job end time (including merging)",
)
estimators
class-attribute
instance-attribute
estimators = relationship(
"EstimatorModel", cascade="delete"
)
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
input_type
class-attribute
instance-attribute
input_type = Column(
String,
nullable=False,
doc="Input type (i.e. 'yaptide_project', 'input_files')",
)
inputs
class-attribute
instance-attribute
inputs = relationship('InputModel', cascade='delete')
job_id
class-attribute
instance-attribute
job_id = Column(
String,
nullable=False,
unique=True,
doc="Simulation job ID",
)
job_state
class-attribute
instance-attribute
job_state = Column(
String,
nullable=False,
default=value,
doc="Simulation state (i.e. 'pending', 'running', 'completed', 'failed')",
)
logfiles
class-attribute
instance-attribute
logfiles = relationship('LogfilesModel', cascade='delete')
platform
class-attribute
instance-attribute
platform = Column(
String,
nullable=False,
doc="Execution platform name (i.e. 'direct', 'batch')",
)
sim_type
class-attribute
instance-attribute
sim_type = Column(
String,
nullable=False,
doc="Simulator type (i.e. 'shieldhit', 'topas', 'fluka')",
)
start_time
class-attribute
instance-attribute
start_time = Column(
DateTime(timezone=True),
default=now(),
doc="Submission time",
)
tasks
class-attribute
instance-attribute
tasks = relationship('TaskModel', cascade='delete')
title
class-attribute
instance-attribute
title = Column(String, nullable=False, doc='Job title')
user_id
class-attribute
instance-attribute
user_id = Column(
Integer, ForeignKey("User.id"), doc="User ID"
)
update_state
update_state(update_dict)
Updating database is more costly than a simple query. Therefore we check first if update is needed and perform it only for such fields which exists and which have updated values. Returns bool value telling if it is required to commit changes to db.
Source code in yaptide/persistence/models.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
TaskModel
Bases: Model
Simulation task model
Source code in yaptide/persistence/models.py
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 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": "Task",
"polymorphic_on": platform,
"with_polymorphic": "*",
}
__table_args__
class-attribute
instance-attribute
__table_args__ = UniqueConstraint(
"simulation_id",
"task_id",
name="_simulation_id_task_id_uc",
)
__tablename__
class-attribute
instance-attribute
__tablename__ = 'Task'
end_time
class-attribute
instance-attribute
end_time = Column(
DateTime(timezone=True),
nullable=True,
doc="Task end time",
)
estimated_time
class-attribute
instance-attribute
estimated_time = Column(
Integer, nullable=True, doc="Estimated time in seconds"
)
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
last_update_time
class-attribute
instance-attribute
last_update_time = Column(
DateTime(timezone=True),
default=now(),
doc="Task last update time",
)
platform
class-attribute
instance-attribute
platform = Column(
String,
nullable=False,
doc="Execution platform name (i.e. 'direct', 'batch')",
)
requested_primaries
class-attribute
instance-attribute
requested_primaries = Column(
Integer,
nullable=False,
default=0,
doc="Requested number of primaries",
)
simulated_primaries
class-attribute
instance-attribute
simulated_primaries = Column(
Integer,
nullable=False,
default=0,
doc="Simulated number of primaries",
)
simulation_id
class-attribute
instance-attribute
simulation_id = Column(
Integer,
ForeignKey("Simulation.id", ondelete="CASCADE"),
doc="Simulation job ID (foreign key)",
)
start_time
class-attribute
instance-attribute
start_time = Column(
DateTime(timezone=True),
nullable=True,
doc="Task start time",
)
task_id
class-attribute
instance-attribute
task_id = Column(Integer, nullable=False, doc='Task ID')
task_state
class-attribute
instance-attribute
task_state = Column(
String,
nullable=False,
default=value,
doc="Task state (i.e. 'pending', 'running', 'completed', 'failed')",
)
get_status_dict
get_status_dict()
Returns task information as a dictionary
Source code in yaptide/persistence/models.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
update_state
update_state(update_dict)
Updating database is more costly than a simple query. Therefore we check first if update is needed and perform it only for such fields which exists and which have updated values.
Source code in yaptide/persistence/models.py
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 |
|
UserModel
Bases: Model
User model
Source code in yaptide/persistence/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": "User",
"polymorphic_on": auth_provider,
"with_polymorphic": "*",
}
__table_args__
class-attribute
instance-attribute
__table_args__ = UniqueConstraint(
"username",
"auth_provider",
name="_username_provider_uc",
)
__tablename__
class-attribute
instance-attribute
__tablename__ = 'User'
auth_provider
class-attribute
instance-attribute
auth_provider = Column(String, nullable=False)
id
class-attribute
instance-attribute
id = Column(Integer, primary_key=True)
simulations
class-attribute
instance-attribute
simulations = relationship('SimulationModel')
username
class-attribute
instance-attribute
username = Column(String, nullable=False)
__repr__
__repr__()
Source code in yaptide/persistence/models.py
30 31 |
|
YaptideUserModel
Bases: UserModel
, Model
Yaptide user model
Source code in yaptide/persistence/models.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
__mapper_args__
class-attribute
instance-attribute
__mapper_args__ = {
"polymorphic_identity": "YaptideUser",
"polymorphic_load": "inline",
}
__tablename__
class-attribute
instance-attribute
__tablename__ = 'YaptideUser'
id
class-attribute
instance-attribute
id = Column(
Integer,
ForeignKey("User.id", ondelete="CASCADE"),
primary_key=True,
)
password_hash
class-attribute
instance-attribute
password_hash = Column(String, nullable=False)
check_password
check_password(password)
Checks password correctness
Source code in yaptide/persistence/models.py
47 48 49 |
|
set_password
set_password(password)
Sets hashed password
Source code in yaptide/persistence/models.py
43 44 45 |
|
allowed_state_change
allowed_state_change(current_state, next_state)
Ensures that no such change like Completed -> Canceled happens
Source code in yaptide/persistence/models.py
166 167 168 169 |
|
compress
compress(data)
Serializes JSON and compresses data
Source code in yaptide/persistence/models.py
302 303 304 305 306 307 308 309 310 311 |
|
create_all
create_all()
Creates all tables, to be used with Flask app context.
Source code in yaptide/persistence/models.py
393 394 395 |
|
decompress
decompress(data)
Decompresses data and deserializes JSON
Source code in yaptide/persistence/models.py
291 292 293 294 295 296 297 298 299 |
|
value_changed
value_changed(current_value, new_value)
checks if value from update_dict differs from object in database
Source code in yaptide/persistence/models.py
172 173 174 |
|