mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Add to_dict methods
This commit is contained in:
parent
9b4f29a849
commit
85b2100e60
@ -252,7 +252,7 @@ class AnonymousUser(AnonymousUserMixin):
|
|||||||
|
|
||||||
class JobInput(db.Model):
|
class JobInput(db.Model):
|
||||||
"""
|
"""
|
||||||
Class to define Files.
|
Class to define JobInputs.
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'job_inputs'
|
__tablename__ = 'job_inputs'
|
||||||
# Primary key
|
# Primary key
|
||||||
@ -260,10 +260,21 @@ class JobInput(db.Model):
|
|||||||
filename = db.Column(db.String(255))
|
filename = db.Column(db.String(255))
|
||||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""
|
||||||
|
String representation of the JobInput. For human readability.
|
||||||
|
"""
|
||||||
|
return '<JobInput %r>' % self.filename
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {'id': self.id,
|
||||||
|
'filename': self.filename,
|
||||||
|
'job_id': self.job_id}
|
||||||
|
|
||||||
|
|
||||||
class JobResult(db.Model):
|
class JobResult(db.Model):
|
||||||
"""
|
"""
|
||||||
Class to define Files.
|
Class to define JobResults.
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'job_results'
|
__tablename__ = 'job_results'
|
||||||
# Primary key
|
# Primary key
|
||||||
@ -271,6 +282,17 @@ class JobResult(db.Model):
|
|||||||
filename = db.Column(db.String(255))
|
filename = db.Column(db.String(255))
|
||||||
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
job_id = db.Column(db.Integer, db.ForeignKey('jobs.id'))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""
|
||||||
|
String representation of the JobResult. For human readability.
|
||||||
|
"""
|
||||||
|
return '<JobResult %r>' % self.filename
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {'id': self.id,
|
||||||
|
'filename': self.filename,
|
||||||
|
'job_id': self.job_id}
|
||||||
|
|
||||||
|
|
||||||
class Job(db.Model):
|
class Job(db.Model):
|
||||||
"""
|
"""
|
||||||
@ -319,8 +341,10 @@ class Job(db.Model):
|
|||||||
'description': self.description,
|
'description': self.description,
|
||||||
'end_date': (self.end_date.timestamp() if self.end_date else
|
'end_date': (self.end_date.timestamp() if self.end_date else
|
||||||
None),
|
None),
|
||||||
|
'inputs': [input.to_dict() for input in self.inputs],
|
||||||
'mem_mb': self.mem_mb,
|
'mem_mb': self.mem_mb,
|
||||||
'n_cores': self.n_cores,
|
'n_cores': self.n_cores,
|
||||||
|
'results': [result.to_dict() for result in self.results],
|
||||||
'service': self.service,
|
'service': self.service,
|
||||||
'service_args': self.service_args,
|
'service_args': self.service_args,
|
||||||
'service_version': self.service_version,
|
'service_version': self.service_version,
|
||||||
|
Loading…
Reference in New Issue
Block a user