"""
This function updates the field's value for given trainingjob.
"""
-
try:
trainingjob_max_version = TrainingJob.query.filter(TrainingJob.trainingjob_name == trainingjob_name).order_by(TrainingJob.version.desc()).first()
if field == "notification_url":
trainingjob_max_version.run_id = field_value
trainingjob_max_version.updation_time = datetime.datetime.utcnow()
db.session.commit()
-
except Exception as err:
raise DBException("Failed to execute query in change_field_of_latest_version," + str(err))
db.session.commit()
except Exception as err:
raise DBException("Failed to execute query in change_field_value_by_version," + str(err))
+
+def change_field_value(traininigjob_id, field, value):
+ """
+ This function updates field's value to field_value of trainingjob.
+ """
+ try:
+ trainingjob = TrainingJob.query.filter(TrainingJob.id==traininigjob_id).one()
+ setattr(trainingjob, field, value)
+ db.session.commit()
+ except Exception as err:
+ raise DBException("Failed to execute query in change_field_value," + str(err))
def delete_trainingjob_version(trainingjob_name, version):
"""