mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +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 to define Files.
|
||||
Class to define JobInputs.
|
||||
"""
|
||||
__tablename__ = 'job_inputs'
|
||||
# Primary key
|
||||
@ -260,10 +260,21 @@ class JobInput(db.Model):
|
||||
filename = db.Column(db.String(255))
|
||||
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 to define Files.
|
||||
Class to define JobResults.
|
||||
"""
|
||||
__tablename__ = 'job_results'
|
||||
# Primary key
|
||||
@ -271,6 +282,17 @@ class JobResult(db.Model):
|
||||
filename = db.Column(db.String(255))
|
||||
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):
|
||||
"""
|
||||
@ -319,8 +341,10 @@ class Job(db.Model):
|
||||
'description': self.description,
|
||||
'end_date': (self.end_date.timestamp() if self.end_date else
|
||||
None),
|
||||
'inputs': [input.to_dict() for input in self.inputs],
|
||||
'mem_mb': self.mem_mb,
|
||||
'n_cores': self.n_cores,
|
||||
'results': [result.to_dict() for result in self.results],
|
||||
'service': self.service,
|
||||
'service_args': self.service_args,
|
||||
'service_version': self.service_version,
|
||||
|
Loading…
Reference in New Issue
Block a user