models
persistence.models
BatchSimulationModel
Bases: SimulationModel
Batch simulation model
Source code in yaptide/persistence/models.py
143 144 145 146 147 148 149 150 151 152 153 |
|
__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"
)
BatchTaskModel
Bases: TaskModel
Batch task model
Source code in yaptide/persistence/models.py
258 259 260 261 262 263 264 |
|
__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
133 134 135 136 137 138 139 140 |
|
__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
242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
__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
249 250 251 252 253 |
|
ClusterModel
Bases: Model
Cluster info for specific user
Source code in yaptide/persistence/models.py
60 61 62 63 64 65 66 |
|
__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
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
__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')
simulation_id
class-attribute
instance-attribute
simulation_id = Column(
Integer, ForeignKey("Simulation.id"), nullable=False
)
InputModel
Bases: Model
Simulation inputs model
Source code in yaptide/persistence/models.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
__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"))
KeycloakUserModel
Bases: UserModel
, Model
PLGrid user model
Source code in yaptide/persistence/models.py
49 50 51 52 53 54 55 56 57 |
|
__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
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
|
__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"), nullable=False
)
PageModel
Bases: Model
Estimator single page model
Source code in yaptide/persistence/models.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
__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"), 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
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 |
|
__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')
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')",
)
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')",
)
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')
title
class-attribute
instance-attribute
title = Column(String, nullable=False, doc='Job title')
update_key_hash
class-attribute
instance-attribute
update_key_hash = Column(
String,
doc="Update key shared by tasks granting access to update themselves",
)
user_id
class-attribute
instance-attribute
user_id = Column(
Integer, ForeignKey("User.id"), doc="User ID"
)
check_update_key
check_update_key(update_key)
Checks update key correctness
Source code in yaptide/persistence/models.py
106 107 108 |
|
set_update_key
set_update_key(update_key)
Sets hashed update key
Source code in yaptide/persistence/models.py
102 103 104 |
|
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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
TaskModel
Bases: Model
Simulation task model
Source code in yaptide/persistence/models.py
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 |
|
__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"),
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
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
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
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 |
|
UserModel
Bases: Model
User model
Source code in yaptide/persistence/models.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
__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
27 28 |
|
YaptideUserModel
Bases: UserModel
, Model
Yaptide user model
Source code in yaptide/persistence/models.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
__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
44 45 46 |
|
set_password
set_password(password)
Sets hashed password
Source code in yaptide/persistence/models.py
40 41 42 |
|
compress
compress(data)
Serializes JSON and compresses data
Source code in yaptide/persistence/models.py
278 279 280 281 282 283 284 285 286 287 |
|
create_all
create_all()
Creates all tables, to be used with Flask app context.
Source code in yaptide/persistence/models.py
364 365 366 |
|
decompress
decompress(data)
Decompresses data and deserializes JSON
Source code in yaptide/persistence/models.py
267 268 269 270 271 272 273 274 275 |
|